blob: 233ec972bf92bad9d6e23e975d2ff6589a2b4422 [file] [log] [blame]
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -07001import org.apache.asterix.bad.lang.statement.BrokerDropStatement;
2import org.apache.asterix.bad.lang.statement.ChannelDropStatement;
3import org.apache.asterix.bad.lang.statement.ChannelSubscribeStatement;
4import org.apache.asterix.bad.lang.statement.ChannelUnsubscribeStatement;
5import org.apache.asterix.bad.lang.statement.CreateBrokerStatement;
6import org.apache.asterix.bad.lang.statement.CreateChannelStatement;
7
8
9@merge
10Statement SingleStatement() throws ParseException:
11{
12 // merge area 1
13 before:
14 after:
15}
16{
17 (
18 // merge area 2
19 before:
20 after: | stmt = ChannelSubscriptionStatement())
21 {
22 // merge area 3
23 }
24}
25
26@merge
27Statement CreateStatement() throws ParseException:
28{
29 // merge area 1
30 before:
31 after:
32}
33{
34 (
35 // merge area 2
36 before:
37 after: | stmt = ChannelSpecification() | stmt = BrokerSpecification())
38 {
39 // merge area 3
40 }
41}
42
43@merge
44Statement DropStatement() throws ParseException:
45{
46 // merge area 1
47 before:
48 after:
49}
50{
51 (
52 // merge area 2
53 before:
54 after: | "channel" pairId = QualifiedName() ifExists = IfExists()
55 {
56 stmt = new ChannelDropStatement(pairId.first, pairId.second, ifExists);
57 }
58 | <BROKER> pairId = QualifiedName() ifExists = IfExists()
59 {
60 stmt = new BrokerDropStatement(pairId.first, pairId.second, ifExists);
61 }
62 )
63 {
64 // merge area 3
65 }
66}
67
68@new
69CreateChannelStatement ChannelSpecification() throws ParseException:
70{
71 Pair<Identifier,Identifier> nameComponents = null;
72 FunctionSignature appliedFunction = null;
73 CreateChannelStatement ccs = null;
74 String fqFunctionName = null;
75 Expression period = null;
76}
77{
78 (
79 "repetitive" "channel" nameComponents = QualifiedName()
80 <USING> appliedFunction = FunctionSignature()
81 "period" period = FunctionCallExpr()
82 {
83 ccs = new CreateChannelStatement(nameComponents.first,
84 nameComponents.second, appliedFunction, period);
85 }
86 )
87 {
88 return ccs;
89 }
90}
91
92@new
93CreateBrokerStatement BrokerSpecification() throws ParseException:
94{
95 CreateBrokerStatement cbs = null;
96 Pair<Identifier,Identifier> name = null;
97 String endPoint = null;
98}
99{
100 (
101 <BROKER> name = QualifiedName()
102 <AT> endPoint = StringLiteral()
103 {
104 cbs = new CreateBrokerStatement(name.first, name.second,endPoint);
105 }
106 )
107 {
108 return cbs;
109 }
110}
111
112@new
113Statement ChannelSubscriptionStatement() throws ParseException:
114{
115 Statement stmt = null;
116 Pair<Identifier,Identifier> nameComponents = null;
117 List<Expression> argList = new ArrayList<Expression>();
118 Expression tmp = null;
119 String id = null;
120 String subscriptionId = null;
121 Pair<Identifier,Identifier> brokerName = null;
122}
123{
124 (
125 "subscribe" <TO> nameComponents = QualifiedName()
126 <LEFTPAREN> (tmp = Expression()
127 {
128 argList.add(tmp);
129 }
130 (<COMMA> tmp = Expression()
131 {
132 argList.add(tmp);
133 }
134 )*)? <RIGHTPAREN> <ON> brokerName = QualifiedName()
135 {
136 stmt = new ChannelSubscribeStatement(nameComponents.first, nameComponents.second, argList, getVarCounter(), brokerName.first, brokerName.second, subscriptionId);
137 }
138 | "unsubscribe" id = StringLiteral() <FROM> nameComponents = QualifiedName()
139 {
140 setDataverses(new ArrayList<String>());
141 setDatasets(new ArrayList<String>());
142 VariableExpr varExp = new VariableExpr();
143 VarIdentifier var = new VarIdentifier();
144 varExp.setVar(var);
145 var.setValue("$subscriptionPlaceholder");
146 getCurrentScope().addNewVarSymbolToScope(varExp.getVar());
147 List<String> dataverses = getDataverses();
148 List<String> datasets = getDatasets();
149 // we remove the pointer to the dataverses and datasets
150 setDataverses(null);
151 setDatasets(null);
152 stmt = new ChannelUnsubscribeStatement(varExp, nameComponents.first, nameComponents.second, id, getVarCounter(), dataverses, datasets);
153 }
154 | "change" "subscription" subscriptionId = StringLiteral() <ON> nameComponents = QualifiedName()
155 <LEFTPAREN> (tmp = Expression()
156 {
157 argList.add(tmp);
158 }
159 (<COMMA> tmp = Expression()
160 {
161 argList.add(tmp);
162 }
163 )*)? <RIGHTPAREN>
164 <TO> brokerName = QualifiedName()
165 {
166 stmt = new ChannelSubscribeStatement(nameComponents.first, nameComponents.second, argList, getVarCounter(), brokerName.first, brokerName.second, subscriptionId);
167 }
168 )
169 {
170 return stmt;
171 }
172}
173
174<DEFAULT,IN_DBL_BRACE>
175TOKEN [IGNORE_CASE]:
176{
177 <BROKER : "broker">
178}