| 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; |
| import org.apache.asterix.bad.lang.statement.CreateProcedureStatement; |
| |
| |
| @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() | stmt = ProcedureSpecification()) |
| { |
| // 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; |
| boolean distributed = false; |
| } |
| { |
| ( |
| "repetitive" "channel" nameComponents = QualifiedName() |
| <USING> appliedFunction = FunctionSignature() |
| "period" period = FunctionCallExpr() ("distributed" { distributed = true; })? |
| { |
| ccs = new CreateChannelStatement(nameComponents.first, |
| nameComponents.second, appliedFunction, period, distributed); |
| } |
| ) |
| { |
| return ccs; |
| } |
| } |
| |
| |
| @new |
| CreateProcedureStatement ProcedureSpecification() throws ParseException: |
| { |
| Pair<Identifier,Identifier> nameComponents = null; |
| FunctionSignature signature; |
| List<VarIdentifier> paramList = new ArrayList<VarIdentifier>(); |
| String functionBody; |
| Token beginPos; |
| Token endPos; |
| Expression functionBodyExpr; |
| } |
| { |
| "procedure" nameComponents = QualifiedName() |
| paramList = ParameterList() |
| <LEFTBRACE> |
| { |
| beginPos = token; |
| } |
| functionBodyExpr = Expression() <RIGHTBRACE> |
| { |
| endPos = token; |
| functionBody = extractFragment(beginPos.beginLine, beginPos.beginColumn, endPos.beginLine, endPos.beginColumn); |
| signature = new FunctionSignature(nameComponents.first.toString(), nameComponents.second.toString(), paramList.size()); |
| removeCurrentScope(); |
| return new CreateProcedureStatement(signature, paramList, functionBody); |
| } |
| } |
| |
| |
| |
| |
| @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; |
| } |
| } |