blob: 94b4c78d09cb7bcb9d0e0083199f73d7f2060dd6 [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;
Steven Glenn Jacobsd0ec8372016-12-07 11:00:08 -08007import org.apache.asterix.bad.lang.statement.CreateProcedureStatement;
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -07008
9
10@merge
11Statement SingleStatement() throws ParseException:
12{
13 // merge area 1
14 before:
15 after:
16}
17{
18 (
19 // merge area 2
20 before:
21 after: | stmt = ChannelSubscriptionStatement())
22 {
23 // merge area 3
24 }
25}
26
27@merge
28Statement CreateStatement() throws ParseException:
29{
30 // merge area 1
31 before:
32 after:
33}
34{
35 (
36 // merge area 2
37 before:
Steven Glenn Jacobsd0ec8372016-12-07 11:00:08 -080038 after: | stmt = ChannelSpecification() | stmt = BrokerSpecification() | stmt = ProcedureSpecification())
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -070039 {
40 // merge area 3
41 }
42}
43
44@merge
45Statement DropStatement() throws ParseException:
46{
47 // merge area 1
48 before:
49 after:
50}
51{
52 (
53 // merge area 2
54 before:
55 after: | "channel" pairId = QualifiedName() ifExists = IfExists()
56 {
57 stmt = new ChannelDropStatement(pairId.first, pairId.second, ifExists);
58 }
Steven Glenn Jacobsd0ec8372016-12-07 11:00:08 -080059 | "broker" pairId = QualifiedName() ifExists = IfExists()
60 {
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -070061 stmt = new BrokerDropStatement(pairId.first, pairId.second, ifExists);
62 }
63 )
64 {
65 // merge area 3
66 }
67}
68
69@new
70CreateChannelStatement ChannelSpecification() throws ParseException:
71{
72 Pair<Identifier,Identifier> nameComponents = null;
73 FunctionSignature appliedFunction = null;
74 CreateChannelStatement ccs = null;
75 String fqFunctionName = null;
76 Expression period = null;
Steven Glenn Jacobsd0ec8372016-12-07 11:00:08 -080077 boolean distributed = false;
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -070078}
79{
80 (
81 "repetitive" "channel" nameComponents = QualifiedName()
82 <USING> appliedFunction = FunctionSignature()
Steven Glenn Jacobsd0ec8372016-12-07 11:00:08 -080083 "period" period = FunctionCallExpr() ("distributed" { distributed = true; })?
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -070084 {
85 ccs = new CreateChannelStatement(nameComponents.first,
Steven Glenn Jacobsd0ec8372016-12-07 11:00:08 -080086 nameComponents.second, appliedFunction, period, distributed);
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -070087 }
88 )
89 {
90 return ccs;
91 }
92}
93
Steven Glenn Jacobsd0ec8372016-12-07 11:00:08 -080094
95@new
96CreateProcedureStatement ProcedureSpecification() throws ParseException:
97{
98 Pair<Identifier,Identifier> nameComponents = null;
99 FunctionSignature signature;
100 List<VarIdentifier> paramList = new ArrayList<VarIdentifier>();
101 String functionBody;
102 Token beginPos;
103 Token endPos;
104 Expression functionBodyExpr;
105}
106{
107 "procedure" nameComponents = QualifiedName()
108 paramList = ParameterList()
109 <LEFTBRACE>
110 {
111 beginPos = token;
112 }
113 functionBodyExpr = Expression() <RIGHTBRACE>
114 {
115 endPos = token;
116 functionBody = extractFragment(beginPos.beginLine, beginPos.beginColumn, endPos.beginLine, endPos.beginColumn);
117 signature = new FunctionSignature(nameComponents.first.toString(), nameComponents.second.toString(), paramList.size());
118 removeCurrentScope();
119 return new CreateProcedureStatement(signature, paramList, functionBody);
120 }
121}
122
123
124
125
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -0700126@new
127CreateBrokerStatement BrokerSpecification() throws ParseException:
128{
129 CreateBrokerStatement cbs = null;
130 Pair<Identifier,Identifier> name = null;
131 String endPoint = null;
132}
133{
134 (
Steven Glenn Jacobsd0ec8372016-12-07 11:00:08 -0800135 "broker" name = QualifiedName()
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -0700136 <AT> endPoint = StringLiteral()
137 {
138 cbs = new CreateBrokerStatement(name.first, name.second,endPoint);
139 }
140 )
141 {
142 return cbs;
143 }
144}
145
146@new
147Statement ChannelSubscriptionStatement() throws ParseException:
148{
149 Statement stmt = null;
150 Pair<Identifier,Identifier> nameComponents = null;
151 List<Expression> argList = new ArrayList<Expression>();
152 Expression tmp = null;
153 String id = null;
154 String subscriptionId = null;
155 Pair<Identifier,Identifier> brokerName = null;
156}
157{
158 (
159 "subscribe" <TO> nameComponents = QualifiedName()
160 <LEFTPAREN> (tmp = Expression()
161 {
162 argList.add(tmp);
163 }
164 (<COMMA> tmp = Expression()
165 {
166 argList.add(tmp);
167 }
168 )*)? <RIGHTPAREN> <ON> brokerName = QualifiedName()
169 {
170 stmt = new ChannelSubscribeStatement(nameComponents.first, nameComponents.second, argList, getVarCounter(), brokerName.first, brokerName.second, subscriptionId);
171 }
172 | "unsubscribe" id = StringLiteral() <FROM> nameComponents = QualifiedName()
173 {
174 setDataverses(new ArrayList<String>());
175 setDatasets(new ArrayList<String>());
176 VariableExpr varExp = new VariableExpr();
177 VarIdentifier var = new VarIdentifier();
178 varExp.setVar(var);
179 var.setValue("$subscriptionPlaceholder");
180 getCurrentScope().addNewVarSymbolToScope(varExp.getVar());
181 List<String> dataverses = getDataverses();
182 List<String> datasets = getDatasets();
183 // we remove the pointer to the dataverses and datasets
184 setDataverses(null);
185 setDatasets(null);
186 stmt = new ChannelUnsubscribeStatement(varExp, nameComponents.first, nameComponents.second, id, getVarCounter(), dataverses, datasets);
187 }
188 | "change" "subscription" subscriptionId = StringLiteral() <ON> nameComponents = QualifiedName()
189 <LEFTPAREN> (tmp = Expression()
190 {
191 argList.add(tmp);
192 }
193 (<COMMA> tmp = Expression()
194 {
195 argList.add(tmp);
196 }
197 )*)? <RIGHTPAREN>
198 <TO> brokerName = QualifiedName()
199 {
200 stmt = new ChannelSubscribeStatement(nameComponents.first, nameComponents.second, argList, getVarCounter(), brokerName.first, brokerName.second, subscriptionId);
201 }
202 )
203 {
204 return stmt;
205 }
Steven Glenn Jacobs409c3e72016-09-14 11:32:13 -0700206}