Initial Commit
diff --git a/src/main/resources/lang-extension/lang.txt b/src/main/resources/lang-extension/lang.txt
new file mode 100644
index 0000000..233ec97
--- /dev/null
+++ b/src/main/resources/lang-extension/lang.txt
@@ -0,0 +1,178 @@
+import org.apache.asterix.bad.lang.statement.BrokerDropStatement;
+import org.apache.asterix.bad.lang.statement.ChannelDropStatement;
+import org.apache.asterix.bad.lang.statement.ChannelSubscribeStatement;
+import org.apache.asterix.bad.lang.statement.ChannelUnsubscribeStatement;
+import org.apache.asterix.bad.lang.statement.CreateBrokerStatement;
+import org.apache.asterix.bad.lang.statement.CreateChannelStatement;
+
+
+@merge
+Statement SingleStatement() throws ParseException:
+{
+ // merge area 1
+ before:
+ after:
+}
+{
+ (
+ // merge area 2
+ before:
+ after: | stmt = ChannelSubscriptionStatement())
+ {
+ // merge area 3
+ }
+}
+
+@merge
+Statement CreateStatement() throws ParseException:
+{
+ // merge area 1
+ before:
+ after:
+}
+{
+ (
+ // merge area 2
+ before:
+ after: | stmt = ChannelSpecification() | stmt = BrokerSpecification())
+ {
+ // merge area 3
+ }
+}
+
+@merge
+Statement DropStatement() throws ParseException:
+{
+ // merge area 1
+ before:
+ after:
+}
+{
+ (
+ // merge area 2
+ before:
+ after: | "channel" pairId = QualifiedName() ifExists = IfExists()
+ {
+ stmt = new ChannelDropStatement(pairId.first, pairId.second, ifExists);
+ }
+ | <BROKER> pairId = QualifiedName() ifExists = IfExists()
+ {
+ stmt = new BrokerDropStatement(pairId.first, pairId.second, ifExists);
+ }
+ )
+ {
+ // merge area 3
+ }
+}
+
+@new
+CreateChannelStatement ChannelSpecification() throws ParseException:
+{
+ Pair<Identifier,Identifier> nameComponents = null;
+ FunctionSignature appliedFunction = null;
+ CreateChannelStatement ccs = null;
+ String fqFunctionName = null;
+ Expression period = null;
+}
+{
+ (
+ "repetitive" "channel" nameComponents = QualifiedName()
+ <USING> appliedFunction = FunctionSignature()
+ "period" period = FunctionCallExpr()
+ {
+ ccs = new CreateChannelStatement(nameComponents.first,
+ nameComponents.second, appliedFunction, period);
+ }
+ )
+ {
+ return ccs;
+ }
+}
+
+@new
+CreateBrokerStatement BrokerSpecification() throws ParseException:
+{
+ CreateBrokerStatement cbs = null;
+ Pair<Identifier,Identifier> name = null;
+ String endPoint = null;
+}
+{
+ (
+ <BROKER> name = QualifiedName()
+ <AT> endPoint = StringLiteral()
+ {
+ cbs = new CreateBrokerStatement(name.first, name.second,endPoint);
+ }
+ )
+ {
+ return cbs;
+ }
+}
+
+@new
+Statement ChannelSubscriptionStatement() throws ParseException:
+{
+ Statement stmt = null;
+ Pair<Identifier,Identifier> nameComponents = null;
+ List<Expression> argList = new ArrayList<Expression>();
+ Expression tmp = null;
+ String id = null;
+ String subscriptionId = null;
+ Pair<Identifier,Identifier> brokerName = null;
+}
+{
+ (
+ "subscribe" <TO> nameComponents = QualifiedName()
+ <LEFTPAREN> (tmp = Expression()
+ {
+ argList.add(tmp);
+ }
+ (<COMMA> tmp = Expression()
+ {
+ argList.add(tmp);
+ }
+ )*)? <RIGHTPAREN> <ON> brokerName = QualifiedName()
+ {
+ stmt = new ChannelSubscribeStatement(nameComponents.first, nameComponents.second, argList, getVarCounter(), brokerName.first, brokerName.second, subscriptionId);
+ }
+ | "unsubscribe" id = StringLiteral() <FROM> nameComponents = QualifiedName()
+ {
+ setDataverses(new ArrayList<String>());
+ setDatasets(new ArrayList<String>());
+ VariableExpr varExp = new VariableExpr();
+ VarIdentifier var = new VarIdentifier();
+ varExp.setVar(var);
+ var.setValue("$subscriptionPlaceholder");
+ getCurrentScope().addNewVarSymbolToScope(varExp.getVar());
+ List<String> dataverses = getDataverses();
+ List<String> datasets = getDatasets();
+ // we remove the pointer to the dataverses and datasets
+ setDataverses(null);
+ setDatasets(null);
+ stmt = new ChannelUnsubscribeStatement(varExp, nameComponents.first, nameComponents.second, id, getVarCounter(), dataverses, datasets);
+ }
+ | "change" "subscription" subscriptionId = StringLiteral() <ON> nameComponents = QualifiedName()
+ <LEFTPAREN> (tmp = Expression()
+ {
+ argList.add(tmp);
+ }
+ (<COMMA> tmp = Expression()
+ {
+ argList.add(tmp);
+ }
+ )*)? <RIGHTPAREN>
+ <TO> brokerName = QualifiedName()
+ {
+ stmt = new ChannelSubscribeStatement(nameComponents.first, nameComponents.second, argList, getVarCounter(), brokerName.first, brokerName.second, subscriptionId);
+ }
+ )
+ {
+ return stmt;
+ }
+}
+
+<DEFAULT,IN_DBL_BRACE>
+TOKEN [IGNORE_CASE]:
+{
+ <BROKER : "broker">
+}
\ No newline at end of file