blob: a1497000f7fd1e1307f21712490c9f0e04c03f19 [file] [log] [blame]
Till Westmann5b431ca2015-10-01 19:16:11 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
vinayakb38b7ca42012-03-05 05:44:15 +000020options {
21
Taewoo Kima12d8cd2015-03-04 13:47:08 -080022
vinayakb38b7ca42012-03-05 05:44:15 +000023 STATIC = false;
Taewoo Kima12d8cd2015-03-04 13:47:08 -080024
vinayakb38b7ca42012-03-05 05:44:15 +000025}
26
27
28PARSER_BEGIN(AQLParser)
29
Ian Maxonf18bba22015-08-21 12:35:14 -070030package org.apache.asterix.aql.parser;
vinayakb38b7ca42012-03-05 05:44:15 +000031
Eldon Carmand2d78ad2015-05-07 16:23:41 -070032// For AQLParserTokenManager
Till Westmann96c1f172013-08-01 02:05:48 -070033import org.apache.xerces.util.IntStack;
34
Eldon Carmand2d78ad2015-05-07 16:23:41 -070035import java.io.BufferedReader;
36import java.io.File;
37import java.io.FileInputStream;
38import java.io.FileNotFoundException;
39import java.io.IOException;
40import java.io.InputStreamReader;
41import java.io.Reader;
42import java.io.StringReader;
43import java.util.ArrayList;
44import java.util.HashMap;
45import java.util.LinkedHashMap;
46import java.util.List;
47import java.util.Map;
48
Ian Maxonf18bba22015-08-21 12:35:14 -070049import org.apache.asterix.aql.base.Clause;
50import org.apache.asterix.aql.base.Expression;
51import org.apache.asterix.aql.base.Literal;
52import org.apache.asterix.aql.base.Statement;
53import org.apache.asterix.aql.context.RootScopeFactory;
54import org.apache.asterix.aql.context.Scope;
55import org.apache.asterix.aql.expression.AbstractAccessor;
56import org.apache.asterix.aql.expression.CallExpr;
57import org.apache.asterix.aql.expression.CompactStatement;
58import org.apache.asterix.aql.expression.ConnectFeedStatement;
59import org.apache.asterix.aql.expression.CreateFeedPolicyStatement;
60import org.apache.asterix.aql.expression.CreatePrimaryFeedStatement;
61import org.apache.asterix.aql.expression.CreateSecondaryFeedStatement;
62import org.apache.asterix.aql.expression.CreateDataverseStatement;
63import org.apache.asterix.aql.expression.CreateFeedStatement;
64import org.apache.asterix.aql.expression.CreateFunctionStatement;
65import org.apache.asterix.aql.expression.CreateIndexStatement;
66import org.apache.asterix.aql.expression.DatasetDecl;
67import org.apache.asterix.aql.expression.DataverseDecl;
68import org.apache.asterix.aql.expression.DataverseDropStatement;
69import org.apache.asterix.aql.expression.DeleteStatement;
70import org.apache.asterix.aql.expression.DisconnectFeedStatement;
71import org.apache.asterix.aql.expression.DistinctClause;
72import org.apache.asterix.aql.expression.DropStatement;
73import org.apache.asterix.aql.expression.ExternalDetailsDecl;
74import org.apache.asterix.aql.expression.FLWOGRExpression;
75import org.apache.asterix.aql.expression.FeedDropStatement;
76import org.apache.asterix.aql.expression.FieldAccessor;
77import org.apache.asterix.aql.expression.FieldBinding;
78import org.apache.asterix.aql.expression.ForClause;
79import org.apache.asterix.aql.expression.FunctionDecl;
80import org.apache.asterix.aql.expression.FunctionDropStatement;
81import org.apache.asterix.aql.expression.GbyVariableExpressionPair;
82import org.apache.asterix.aql.expression.GroupbyClause;
83import org.apache.asterix.aql.expression.Identifier;
84import org.apache.asterix.aql.expression.IfExpr;
85import org.apache.asterix.aql.expression.IndexAccessor;
86import org.apache.asterix.aql.expression.IndexDropStatement;
87import org.apache.asterix.aql.expression.InsertStatement;
88import org.apache.asterix.aql.expression.InternalDetailsDecl;
89import org.apache.asterix.aql.expression.LetClause;
90import org.apache.asterix.aql.expression.LimitClause;
91import org.apache.asterix.aql.expression.ListConstructor;
92import org.apache.asterix.aql.expression.LiteralExpr;
93import org.apache.asterix.aql.expression.LoadStatement;
94import org.apache.asterix.aql.expression.NodeGroupDropStatement;
95import org.apache.asterix.aql.expression.NodegroupDecl;
96import org.apache.asterix.aql.expression.OperatorExpr;
97import org.apache.asterix.aql.expression.OrderbyClause;
98import org.apache.asterix.aql.expression.OrderedListTypeDefinition;
99import org.apache.asterix.aql.expression.QuantifiedExpression;
100import org.apache.asterix.aql.expression.QuantifiedPair;
101import org.apache.asterix.aql.expression.Query;
102import org.apache.asterix.aql.expression.RecordConstructor;
103import org.apache.asterix.aql.expression.RecordTypeDefinition;
104import org.apache.asterix.aql.expression.RefreshExternalDatasetStatement;
105import org.apache.asterix.aql.expression.RunStatement;
106import org.apache.asterix.aql.expression.SetStatement;
107import org.apache.asterix.aql.expression.TypeDecl;
108import org.apache.asterix.aql.expression.TypeDropStatement;
109import org.apache.asterix.aql.expression.TypeExpression;
110import org.apache.asterix.aql.expression.TypeReferenceExpression;
111import org.apache.asterix.aql.expression.UnaryExpr;
112import org.apache.asterix.aql.expression.UnaryExpr.Sign;
113import org.apache.asterix.aql.expression.UnionExpr;
114import org.apache.asterix.aql.expression.UnorderedListTypeDefinition;
115import org.apache.asterix.aql.expression.UpdateClause;
116import org.apache.asterix.aql.expression.UpdateStatement;
117import org.apache.asterix.aql.expression.VarIdentifier;
118import org.apache.asterix.aql.expression.VariableExpr;
119import org.apache.asterix.aql.expression.WhereClause;
120import org.apache.asterix.aql.expression.WriteStatement;
121import org.apache.asterix.aql.literal.DoubleLiteral;
122import org.apache.asterix.aql.literal.FalseLiteral;
123import org.apache.asterix.aql.literal.FloatLiteral;
124import org.apache.asterix.aql.literal.LongIntegerLiteral;
125import org.apache.asterix.aql.literal.NullLiteral;
126import org.apache.asterix.aql.literal.StringLiteral;
127import org.apache.asterix.aql.literal.TrueLiteral;
128import org.apache.asterix.aql.util.RangeMapBuilder;
129import org.apache.asterix.common.annotations.AutoDataGen;
130import org.apache.asterix.common.annotations.DateBetweenYearsDataGen;
131import org.apache.asterix.common.annotations.DatetimeAddRandHoursDataGen;
132import org.apache.asterix.common.annotations.DatetimeBetweenYearsDataGen;
133import org.apache.asterix.common.annotations.FieldIntervalDataGen;
134import org.apache.asterix.common.annotations.FieldValFileDataGen;
135import org.apache.asterix.common.annotations.FieldValFileSameIndexDataGen;
136import org.apache.asterix.common.annotations.IRecordFieldDataGen;
137import org.apache.asterix.common.annotations.InsertRandIntDataGen;
138import org.apache.asterix.common.annotations.ListDataGen;
139import org.apache.asterix.common.annotations.ListValFileDataGen;
140import org.apache.asterix.common.annotations.SkipSecondaryIndexSearchExpressionAnnotation;
141import org.apache.asterix.common.annotations.TypeDataGen;
142import org.apache.asterix.common.annotations.UndeclaredFieldsDataGen;
143import org.apache.asterix.common.config.DatasetConfig.DatasetType;
144import org.apache.asterix.common.config.DatasetConfig.IndexType;
145import org.apache.asterix.common.exceptions.AsterixException;
146import org.apache.asterix.common.functions.FunctionSignature;
147import org.apache.asterix.metadata.bootstrap.MetadataConstants;
148import org.apache.hyracks.algebricks.common.utils.Pair;
149import org.apache.hyracks.algebricks.common.utils.Triple;
150import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation;
151import org.apache.hyracks.algebricks.core.algebra.expressions.IndexedNLJoinExpressionAnnotation;
152import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
153import org.apache.hyracks.dataflow.common.data.partition.range.IRangeMap;
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +0000154
155
vinayakb38b7ca42012-03-05 05:44:15 +0000156
157
158public class AQLParser extends ScopeChecker {
159
vinayakb38b7ca42012-03-05 05:44:15 +0000160 // optimizer hints
Eldon Carmand2d78ad2015-05-07 16:23:41 -0700161 private static final String AUTO_HINT = "auto";
vinayakb38b7ca42012-03-05 05:44:15 +0000162 private static final String BROADCAST_JOIN_HINT = "bcast";
vinayakb38b7ca42012-03-05 05:44:15 +0000163 private static final String COMPOSE_VAL_FILES_HINT = "compose-val-files";
vinayakb38b7ca42012-03-05 05:44:15 +0000164 private static final String DATE_BETWEEN_YEARS_HINT = "date-between-years";
165 private static final String DATETIME_ADD_RAND_HOURS_HINT = "datetime-add-rand-hours";
Eldon Carmand2d78ad2015-05-07 16:23:41 -0700166 private static final String DATETIME_BETWEEN_YEARS_HINT = "datetime-between-years";
167 private static final String HASH_GROUP_BY_HINT = "hash";
168 private static final String INDEXED_NESTED_LOOP_JOIN_HINT = "indexnl";
169 private static final String INMEMORY_HINT = "inmem";
170 private static final String INSERT_RAND_INT_HINT = "insert-rand-int";
171 private static final String INTERVAL_HINT = "interval";
172 private static final String LIST_HINT = "list";
173 private static final String LIST_VAL_FILE_HINT = "list-val-file";
174 private static final String RANGE_HINT = "range";
175 private static final String SKIP_SECONDARY_INDEX_SEARCH_HINT = "skip-index";
176 private static final String VAL_FILE_HINT = "val-files";
177 private static final String VAL_FILE_SAME_INDEX_HINT = "val-file-same-idx";
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800178
179 private static final String GEN_FIELDS_HINT = "gen-fields";
180
vinayakb38b7ca42012-03-05 05:44:15 +0000181 // data generator hints
182 private static final String DGEN_HINT = "dgen";
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800183
Till Westmann31c21f92013-05-08 09:21:53 -0700184 private static class IndexParams {
185 public IndexType type;
186 public int gramLength;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800187
Till Westmann31c21f92013-05-08 09:21:53 -0700188 public IndexParams(IndexType type, int gramLength) {
189 this.type = type;
190 this.gramLength = gramLength;
191 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800192 };
193
ramangrover299f76a5e2013-06-18 10:25:17 -0700194 private static class FunctionName {
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800195 public String dataverse = null;
196 public String library = null;
197 public String function = null;
198 }
ramangrover299f76a5e2013-06-18 10:25:17 -0700199
vinayakb38b7ca42012-03-05 05:44:15 +0000200 private static String getHint(Token t) {
Till Westmann31c21f92013-05-08 09:21:53 -0700201 if (t.specialToken == null) {
202 return null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800203 }
Till Westmann31c21f92013-05-08 09:21:53 -0700204 String s = t.specialToken.image;
205 int n = s.length();
206 if (n < 2) {
207 return null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800208 }
Till Westmann31c21f92013-05-08 09:21:53 -0700209 return s.substring(1).trim();
vinayakb38b7ca42012-03-05 05:44:15 +0000210 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800211
Till Westmann77cb2f42013-07-15 16:44:19 -0700212 private static IRecordFieldDataGen parseFieldDataGen(String hint) throws ParseException {
213 IRecordFieldDataGen rfdg = null;
214 String splits[] = hint.split(" +");
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800215 if (splits[0].equals(VAL_FILE_HINT)) {
Till Westmann77cb2f42013-07-15 16:44:19 -0700216 File[] valFiles = new File[splits.length - 1];
217 for (int k=1; k<splits.length; k++) {
218 valFiles[k-1] = new File(splits[k]);
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800219 }
Till Westmann77cb2f42013-07-15 16:44:19 -0700220 rfdg = new FieldValFileDataGen(valFiles);
221 } else if (splits[0].equals(VAL_FILE_SAME_INDEX_HINT)) {
222 rfdg = new FieldValFileSameIndexDataGen(new File(splits[1]), splits[2]);
223 } else if (splits[0].equals(LIST_VAL_FILE_HINT)) {
224 rfdg = new ListValFileDataGen(new File(splits[1]), Integer.parseInt(splits[2]), Integer.parseInt(splits[3]));
225 } else if (splits[0].equals(LIST_HINT)) {
226 rfdg = new ListDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
227 } else if (splits[0].equals(INTERVAL_HINT)) {
228 FieldIntervalDataGen.ValueType vt;
229 if (splits[1].equals("int")) {
230 vt = FieldIntervalDataGen.ValueType.INT;
231 } else if (splits[1].equals("long")) {
232 vt = FieldIntervalDataGen.ValueType.LONG;
233 } else if (splits[1].equals("float")) {
234 vt = FieldIntervalDataGen.ValueType.FLOAT;
235 } else if (splits[1].equals("double")) {
236 vt = FieldIntervalDataGen.ValueType.DOUBLE;
237 } else {
238 throw new ParseException("Unknown type for interval data gen: " + splits[1]);
239 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800240 rfdg = new FieldIntervalDataGen(vt, splits[2], splits[3]);
Till Westmann77cb2f42013-07-15 16:44:19 -0700241 } else if (splits[0].equals(INSERT_RAND_INT_HINT)) {
242 rfdg = new InsertRandIntDataGen(splits[1], splits[2]);
243 } else if (splits[0].equals(DATE_BETWEEN_YEARS_HINT)) {
244 rfdg = new DateBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
245 } else if (splits[0].equals(DATETIME_BETWEEN_YEARS_HINT)) {
246 rfdg = new DatetimeBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]));
247 } else if (splits[0].equals(DATETIME_ADD_RAND_HOURS_HINT)) {
248 rfdg = new DatetimeAddRandHoursDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]), splits[3]);
249 } else if (splits[0].equals(AUTO_HINT)) {
250 rfdg = new AutoDataGen(splits[1]);
251 }
252 return rfdg;
253 }
vinayakb38b7ca42012-03-05 05:44:15 +0000254
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +0000255 public AQLParser(String s){
Till Westmann31c21f92013-05-08 09:21:53 -0700256 this(new StringReader(s));
257 super.setInput(s);
258 }
vinayakb38b7ca42012-03-05 05:44:15 +0000259
Till Westmann31c21f92013-05-08 09:21:53 -0700260 public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException, AsterixException {
261 File file = new File(args[0]);
262 Reader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
263 AQLParser parser = new AQLParser(fis);
Till Westmanne3e8ffa2014-08-02 17:51:23 -0700264 List<Statement> st = parser.parse();
Till Westmann31c21f92013-05-08 09:21:53 -0700265 //st.accept(new AQLPrintVisitor(), 0);
266 }
Till Westmanne3e8ffa2014-08-02 17:51:23 -0700267
268 public List<Statement> parse() throws ParseException {
269 try {
270 return Statement();
271 } catch (Error e) {
272 // this is here as the JavaCharStream that's below the lexer somtimes throws Errors that are not handled
273 // by the ANTLR-generated lexer or parser (e.g it does this for invalid backslash u + 4 hex digits escapes)
274 throw new ParseException(e.getMessage());
275 }
276 }
vinayakb38b7ca42012-03-05 05:44:15 +0000277}
278
279PARSER_END(AQLParser)
280
281
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +0000282List<Statement> Statement() throws ParseException:
vinayakb38b7ca42012-03-05 05:44:15 +0000283{
vinayakb38b7ca42012-03-05 05:44:15 +0000284 scopeStack.push(RootScopeFactory.createRootScope(this));
285 List<Statement> decls = new ArrayList<Statement>();
Till Westmann31c21f92013-05-08 09:21:53 -0700286 Statement stmt = null;
vinayakb38b7ca42012-03-05 05:44:15 +0000287}
288{
Till Westmann31c21f92013-05-08 09:21:53 -0700289 ( stmt = SingleStatement() (";") ?
vinayakb38b7ca42012-03-05 05:44:15 +0000290 {
Till Westmann31c21f92013-05-08 09:21:53 -0700291 decls.add(stmt);
292 }
293 )*
294 <EOF>
295 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800296 return decls;
Till Westmann31c21f92013-05-08 09:21:53 -0700297 }
298}
299
300Statement SingleStatement() throws ParseException:
301{
302 Statement stmt = null;
303}
304{
305 (
306 stmt = DataverseDeclaration()
307 | stmt = FunctionDeclaration()
308 | stmt = CreateStatement()
309 | stmt = LoadStatement()
310 | stmt = DropStatement()
311 | stmt = WriteStatement()
312 | stmt = SetStatement()
313 | stmt = InsertStatement()
314 | stmt = DeleteStatement()
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800315 | stmt = UpdateStatement()
Till Westmann31c21f92013-05-08 09:21:53 -0700316 | stmt = FeedStatement()
salsubaiee0b423fa2013-09-19 19:16:48 -0700317 | stmt = CompactStatement()
Till Westmann31c21f92013-05-08 09:21:53 -0700318 | stmt = Query()
Abdullah Alamoudid9057732014-06-12 13:38:27 -0700319 | stmt = RefreshExternalDatasetStatement()
Markus Holzemer52c568e2014-12-18 10:51:49 -0800320 | stmt = RunStatement()
Till Westmann31c21f92013-05-08 09:21:53 -0700321 )
322 {
323 return stmt;
324 }
325}
326
327DataverseDecl DataverseDeclaration() throws ParseException:
328{
Till Westmann14a20a72013-05-09 00:06:24 -0700329 String dvName = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700330}
331{
Till Westmanna4242bc2013-05-08 17:49:55 -0700332 "use" "dataverse" dvName = Identifier()
Till Westmann31c21f92013-05-08 09:21:53 -0700333 {
Till Westmann14a20a72013-05-09 00:06:24 -0700334 defaultDataverse = dvName;
335 return new DataverseDecl(new Identifier(dvName));
Till Westmann31c21f92013-05-08 09:21:53 -0700336 }
337}
338
339Statement CreateStatement() throws ParseException:
340{
341 String hint = null;
342 boolean dgen = false;
343 Statement stmt = null;
344}
345{
346 "create"
347 (
348 {
349 hint = getHint(token);
350 if (hint != null && hint.startsWith(DGEN_HINT)) {
351 dgen = true;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800352 }
Till Westmann31c21f92013-05-08 09:21:53 -0700353 }
354 stmt = TypeSpecification(hint, dgen)
355 | stmt = NodegroupSpecification()
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800356 | stmt = DatasetSpecification()
Till Westmann31c21f92013-05-08 09:21:53 -0700357 | stmt = IndexSpecification()
358 | stmt = DataverseSpecification()
359 | stmt = FunctionSpecification()
ramangrover29a774ef22013-07-17 09:29:18 -0700360 | stmt = FeedSpecification()
ramangrover29ae85a1d2015-06-26 17:26:05 -0700361 | stmt = FeedPolicySpecification()
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800362 )
Till Westmann31c21f92013-05-08 09:21:53 -0700363 {
364 return stmt;
365 }
366}
367
368TypeDecl TypeSpecification(String hint, boolean dgen) throws ParseException:
369{
370 Pair<Identifier,Identifier> nameComponents = null;
371 boolean ifNotExists = false;
372 TypeExpression typeExpr = null;
373}
374{
ramangrover299f76a5e2013-06-18 10:25:17 -0700375 "type" nameComponents = TypeName() ifNotExists = IfNotExists()
Till Westmann31c21f92013-05-08 09:21:53 -0700376 "as" typeExpr = TypeExpr()
377 {
378 long numValues = -1;
379 String filename = null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800380 if (dgen) {
Till Westmann31c21f92013-05-08 09:21:53 -0700381 String splits[] = hint.split(" +");
382 if (splits.length != 3) {
383 throw new ParseException("Expecting /*+ dgen <filename> <numberOfItems> */");
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800384 }
Till Westmann31c21f92013-05-08 09:21:53 -0700385 filename = splits[1];
386 numValues = Long.parseLong(splits[2]);
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800387 }
Till Westmann31c21f92013-05-08 09:21:53 -0700388 TypeDataGen tddg = new TypeDataGen(dgen, filename, numValues);
389 return new TypeDecl(nameComponents.first, nameComponents.second, typeExpr, tddg, ifNotExists);
390 }
391}
392
393
394NodegroupDecl NodegroupSpecification() throws ParseException:
395{
Till Westmann14a20a72013-05-09 00:06:24 -0700396 String name = null;
397 String tmp = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700398 boolean ifNotExists = false;
399 List<Identifier>ncNames = null;
400}
401{
Till Westmanna4242bc2013-05-08 17:49:55 -0700402 "nodegroup" name = Identifier()
403 ifNotExists = IfNotExists() "on" tmp = Identifier()
Till Westmann31c21f92013-05-08 09:21:53 -0700404 {
405 ncNames = new ArrayList<Identifier>();
Till Westmann14a20a72013-05-09 00:06:24 -0700406 ncNames.add(new Identifier(tmp));
Till Westmann31c21f92013-05-08 09:21:53 -0700407 }
Till Westmann96c1f172013-08-01 02:05:48 -0700408 ( <COMMA> tmp = Identifier()
Till Westmann31c21f92013-05-08 09:21:53 -0700409 {
Till Westmann14a20a72013-05-09 00:06:24 -0700410 ncNames.add(new Identifier(tmp));
Till Westmann31c21f92013-05-08 09:21:53 -0700411 }
412 )*
413 {
Till Westmann14a20a72013-05-09 00:06:24 -0700414 return new NodegroupDecl(new Identifier(name), ncNames, ifNotExists);
Till Westmann31c21f92013-05-08 09:21:53 -0700415 }
416}
417
418DatasetDecl DatasetSpecification() throws ParseException:
419{
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800420 Pair<Identifier,Identifier> nameComponents = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700421 boolean ifNotExists = false;
Till Westmann14a20a72013-05-09 00:06:24 -0700422 String typeName = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700423 String adapterName = null;
424 Map<String,String> properties = null;
salsubaiee801bffe2013-09-22 23:42:35 -0700425 Map<String,String> compactionPolicyProperties = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700426 FunctionSignature appliedFunction = null;
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700427 List<List<String>> primaryKeyFields = null;
Till Westmann14a20a72013-05-09 00:06:24 -0700428 String nodeGroupName = null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800429 Map<String,String> hints = new HashMap<String,String>();
Till Westmann31c21f92013-05-08 09:21:53 -0700430 DatasetDecl dsetDecl = null;
zheilbron2467f2e2013-08-23 19:07:31 -0700431 boolean autogenerated = false;
salsubaiee0b423fa2013-09-19 19:16:48 -0700432 String compactionPolicy = null;
buyingyiccd67fe2015-05-19 11:53:39 -0700433 boolean temp = false;
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700434 List<String> filterField = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700435}
436{
437 (
Till Westmanna4242bc2013-05-08 17:49:55 -0700438 "external" <DATASET> nameComponents = QualifiedName()
439 <LEFTPAREN> typeName = Identifier() <RIGHTPAREN>
440 ifNotExists = IfNotExists()
Till Westmann31c21f92013-05-08 09:21:53 -0700441 "using" adapterName = AdapterName() properties = Configuration()
Abdullah Alamoudid9057732014-06-12 13:38:27 -0700442 ("on" nodeGroupName = Identifier() )?
Till Westmann31c21f92013-05-08 09:21:53 -0700443 ( "hints" hints = Properties() )?
salsubaiee661b9c72014-07-17 17:19:45 -0700444 ( "using" "compaction" "policy" compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )?
Till Westmann31c21f92013-05-08 09:21:53 -0700445 {
446 ExternalDetailsDecl edd = new ExternalDetailsDecl();
447 edd.setAdapter(adapterName);
448 edd.setProperties(properties);
Till Westmann14a20a72013-05-09 00:06:24 -0700449 dsetDecl = new DatasetDecl(nameComponents.first,
450 nameComponents.second,
451 new Identifier(typeName),
Ildar Absalyamova5895302015-08-17 23:15:41 -0700452 nodeGroupName != null? new Identifier(nodeGroupName): null,
453 compactionPolicy,
454 compactionPolicyProperties,
Till Westmann14a20a72013-05-09 00:06:24 -0700455 hints,
456 DatasetType.EXTERNAL,
457 edd,
458 ifNotExists);
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800459 }
Till Westmann31c21f92013-05-08 09:21:53 -0700460
buyingyiccd67fe2015-05-19 11:53:39 -0700461 | ("internal" | "temporary" {
462 temp = token.image.toLowerCase().equals("temporary");
463 }
464 )?
465 <DATASET> nameComponents = QualifiedName()
Till Westmanna4242bc2013-05-08 17:49:55 -0700466 <LEFTPAREN> typeName = Identifier() <RIGHTPAREN>
467 ifNotExists = IfNotExists()
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800468 primaryKeyFields = PrimaryKey()
469 ("autogenerated" { autogenerated = true; } )?
zheilbron2467f2e2013-08-23 19:07:31 -0700470 ("on" nodeGroupName = Identifier() )?
Till Westmann31c21f92013-05-08 09:21:53 -0700471 ( "hints" hints = Properties() )?
salsubaiee661b9c72014-07-17 17:19:45 -0700472 ( "using" "compaction" "policy" compactionPolicy = CompactionPolicy() (compactionPolicyProperties = Configuration())? )?
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700473 ( "with filter on" filterField = NestedField() )?
Till Westmann31c21f92013-05-08 09:21:53 -0700474 {
Ildar Absalyamova5895302015-08-17 23:15:41 -0700475 InternalDetailsDecl idd = new InternalDetailsDecl(primaryKeyFields,
zheilbron9082e6c2013-10-24 12:25:21 -0700476 autogenerated,
buyingyiccd67fe2015-05-19 11:53:39 -0700477 filterField,
478 temp);
Till Westmann14a20a72013-05-09 00:06:24 -0700479 dsetDecl = new DatasetDecl(nameComponents.first,
480 nameComponents.second,
481 new Identifier(typeName),
Ildar Absalyamova5895302015-08-17 23:15:41 -0700482 nodeGroupName != null ? new Identifier(nodeGroupName) : null,
483 compactionPolicy,
484 compactionPolicyProperties,
Till Westmann14a20a72013-05-09 00:06:24 -0700485 hints,
486 DatasetType.INTERNAL,
487 idd,
488 ifNotExists);
Till Westmann31c21f92013-05-08 09:21:53 -0700489 }
490 )
491 {
492 return dsetDecl;
493 }
494}
495
Abdullah Alamoudid9057732014-06-12 13:38:27 -0700496RefreshExternalDatasetStatement RefreshExternalDatasetStatement() throws ParseException:
497{
498 RefreshExternalDatasetStatement redss = new RefreshExternalDatasetStatement();
499 Pair<Identifier,Identifier> nameComponents = null;
500 String datasetName = null;
501}
502{
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800503 "refresh external" <DATASET> nameComponents = QualifiedName()
504 {
505 redss.setDataverseName(nameComponents.first);
506 redss.setDatasetName(nameComponents.second);
507 return redss;
508 }
Abdullah Alamoudid9057732014-06-12 13:38:27 -0700509}
510
Markus Holzemer52c568e2014-12-18 10:51:49 -0800511RunStatement RunStatement() throws ParseException:
512{
513 String system = null;
514 String tmp;
515 ArrayList<String> parameters = new ArrayList<String>();
516 Pair<Identifier,Identifier> nameComponentsFrom = null;
517 Pair<Identifier,Identifier> nameComponentsTo = null;
518}
519{
520 "run" system = Identifier()<LEFTPAREN> ( tmp = Identifier() [<COMMA>]
521 {
522 parameters.add(tmp);
523 }
524 )*<RIGHTPAREN>
525 <FROM> <DATASET> nameComponentsFrom = QualifiedName()
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800526 "to" <DATASET> nameComponentsTo = QualifiedName()
Markus Holzemer52c568e2014-12-18 10:51:49 -0800527 {
528 return new RunStatement(system, parameters, nameComponentsFrom.first, nameComponentsFrom.second, nameComponentsTo.first, nameComponentsTo.second);
529 }
530}
531
Till Westmann31c21f92013-05-08 09:21:53 -0700532CreateIndexStatement IndexSpecification() throws ParseException:
533{
534 CreateIndexStatement cis = new CreateIndexStatement();
Till Westmann14a20a72013-05-09 00:06:24 -0700535 String indexName = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700536 boolean ifNotExists = false;
537 Pair<Identifier,Identifier> nameComponents = null;
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700538 Pair<List<String>, TypeExpression> fieldPair = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700539 IndexParams indexType = null;
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700540 boolean enforced = false;
Till Westmann31c21f92013-05-08 09:21:53 -0700541}
542{
Till Westmanna4242bc2013-05-08 17:49:55 -0700543 "index" indexName = Identifier()
Till Westmann31c21f92013-05-08 09:21:53 -0700544 ifNotExists = IfNotExists()
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800545 "on" nameComponents = QualifiedName()
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700546 <LEFTPAREN> ( fieldPair = OpenField()
Till Westmann31c21f92013-05-08 09:21:53 -0700547 {
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700548 cis.addFieldExprPair(fieldPair);
Till Westmann31c21f92013-05-08 09:21:53 -0700549 }
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700550 ) (<COMMA> fieldPair = OpenField()
Till Westmann31c21f92013-05-08 09:21:53 -0700551 {
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700552 cis.addFieldExprPair(fieldPair);
Till Westmann31c21f92013-05-08 09:21:53 -0700553 }
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700554 )* <RIGHTPAREN> ( "type" indexType = IndexType() )? ( "enforced" { enforced = true; } )?
Till Westmann31c21f92013-05-08 09:21:53 -0700555 {
Till Westmann14a20a72013-05-09 00:06:24 -0700556 cis.setIndexName(new Identifier(indexName));
Till Westmann31c21f92013-05-08 09:21:53 -0700557 cis.setIfNotExists(ifNotExists);
558 cis.setDataverseName(nameComponents.first);
559 cis.setDatasetName(nameComponents.second);
560 if (indexType != null) {
561 cis.setIndexType(indexType.type);
562 cis.setGramLength(indexType.gramLength);
563 }
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700564 cis.setEnforced(enforced);
Till Westmann31c21f92013-05-08 09:21:53 -0700565 return cis;
566 }
567}
568
salsubaiee0b423fa2013-09-19 19:16:48 -0700569String CompactionPolicy() throws ParseException :
570{
571 String compactionPolicy = null;
572}
573{
574 compactionPolicy = Identifier()
575 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800576 return compactionPolicy;
salsubaiee0b423fa2013-09-19 19:16:48 -0700577 }
578}
579
salsubaieea5af4e02014-07-08 15:20:02 -0700580String FilterField() throws ParseException :
581{
582 String filterField = null;
583}
584{
585 filterField = Identifier()
586 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800587 return filterField;
salsubaieea5af4e02014-07-08 15:20:02 -0700588 }
589}
590
Till Westmann31c21f92013-05-08 09:21:53 -0700591IndexParams IndexType() throws ParseException:
592{
593 IndexType type = null;
594 int gramLength = 0;
595}
596{
597 ("btree"
598 {
599 type = IndexType.BTREE;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800600 }
Till Westmann31c21f92013-05-08 09:21:53 -0700601 | "rtree"
602 {
603 type = IndexType.RTREE;
604 }
605 | "keyword"
606 {
JIMAHNb75446d2013-06-03 08:35:27 -0700607 type = IndexType.LENGTH_PARTITIONED_WORD_INVIX;
Till Westmann31c21f92013-05-08 09:21:53 -0700608 }
609 | "ngram" <LEFTPAREN> <INTEGER_LITERAL>
610 {
JIMAHNb75446d2013-06-03 08:35:27 -0700611 type = IndexType.LENGTH_PARTITIONED_NGRAM_INVIX;
Till Westmann31c21f92013-05-08 09:21:53 -0700612 gramLength = Integer.valueOf(token.image);
613 }
614 <RIGHTPAREN>)
615 {
616 return new IndexParams(type, gramLength);
617 }
618}
619
620CreateDataverseStatement DataverseSpecification() throws ParseException :
621{
Till Westmann14a20a72013-05-09 00:06:24 -0700622 String dvName = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700623 boolean ifNotExists = false;
624 String format = null;
625}
626{
Till Westmanna4242bc2013-05-08 17:49:55 -0700627 "dataverse" dvName = Identifier()
Till Westmann31c21f92013-05-08 09:21:53 -0700628 ifNotExists = IfNotExists()
Till Westmann7d535322013-05-09 00:40:02 -0700629 ( "with format" format = StringLiteral() )?
Till Westmann31c21f92013-05-08 09:21:53 -0700630 {
Till Westmann14a20a72013-05-09 00:06:24 -0700631 return new CreateDataverseStatement(new Identifier(dvName), format, ifNotExists);
Till Westmann31c21f92013-05-08 09:21:53 -0700632 }
633}
634
635CreateFunctionStatement FunctionSpecification() throws ParseException:
636{
637 FunctionSignature signature;
638 boolean ifNotExists = false;
639 List<VarIdentifier> paramList = new ArrayList<VarIdentifier>();
640 String functionBody;
ramangrover29bdba1a82013-06-21 17:17:52 -0700641 VarIdentifier var = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700642 Expression functionBodyExpr;
643 Token beginPos;
644 Token endPos;
ramangrover299f76a5e2013-06-18 10:25:17 -0700645 FunctionName fctName = null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800646
Till Westmann31c21f92013-05-08 09:21:53 -0700647 createNewScope();
648}
649{
ramangrover299f76a5e2013-06-18 10:25:17 -0700650 "function" fctName = FunctionName()
Till Westmann31c21f92013-05-08 09:21:53 -0700651 ifNotExists = IfNotExists()
Till Westmannd7dcb122013-05-16 13:19:09 -0700652 paramList = ParameterList()
Till Westmann96c1f172013-08-01 02:05:48 -0700653 <LEFTBRACE>
Raman Groverf6b4b292013-09-24 11:11:20 +0530654 {
655 beginPos = token;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800656 }
Till Westmann96c1f172013-08-01 02:05:48 -0700657 functionBodyExpr = Expression() <RIGHTBRACE>
Till Westmannd7dcb122013-05-16 13:19:09 -0700658 {
659 endPos = token;
660 functionBody = extractFragment(beginPos.beginLine, beginPos.beginColumn, endPos.beginLine, endPos.beginColumn);
ramangrover299f76a5e2013-06-18 10:25:17 -0700661 // TODO use fctName.library
662 signature = new FunctionSignature(fctName.dataverse, fctName.function, paramList.size());
Till Westmannd7dcb122013-05-16 13:19:09 -0700663 getCurrentScope().addFunctionDescriptor(signature, false);
Steven Jacobsa84eee42014-12-16 13:55:08 -0800664 removeCurrentScope();
Till Westmannd7dcb122013-05-16 13:19:09 -0700665 return new CreateFunctionStatement(signature, paramList, functionBody, ifNotExists);
666 }
667}
668
ramangrover29a774ef22013-07-17 09:29:18 -0700669CreateFeedStatement FeedSpecification() throws ParseException:
670{
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800671 Pair<Identifier,Identifier> nameComponents = null;
ramangrover29a774ef22013-07-17 09:29:18 -0700672 boolean ifNotExists = false;
Chris Hillerye64055d2014-10-11 00:14:39 -0700673 String adapterName = null;
ramangrover29a774ef22013-07-17 09:29:18 -0700674 Map<String,String> properties = null;
675 FunctionSignature appliedFunction = null;
676 CreateFeedStatement cfs = null;
ramangrover29ae85a1d2015-06-26 17:26:05 -0700677 Pair<Identifier,Identifier> sourceNameComponents = null;
678
ramangrover29a774ef22013-07-17 09:29:18 -0700679}
680{
681 (
ramangrover29ae85a1d2015-06-26 17:26:05 -0700682 "secondary" "feed" nameComponents = QualifiedName() ifNotExists = IfNotExists()
683 <FROM> "feed" sourceNameComponents = QualifiedName() (appliedFunction = ApplyFunction())?
ramangrover29a774ef22013-07-17 09:29:18 -0700684 {
ramangrover29ae85a1d2015-06-26 17:26:05 -0700685 cfs = new CreateSecondaryFeedStatement(nameComponents,
686 sourceNameComponents, appliedFunction, ifNotExists);
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800687 }
ramangrover29ae85a1d2015-06-26 17:26:05 -0700688 |
689 ("primary")? "feed" nameComponents = QualifiedName() ifNotExists = IfNotExists()
690 "using" adapterName = AdapterName() properties = Configuration() (appliedFunction = ApplyFunction())?
691 {
692 cfs = new CreatePrimaryFeedStatement(nameComponents,
693 adapterName, properties, appliedFunction, ifNotExists);
694 }
ramangrover29a774ef22013-07-17 09:29:18 -0700695 )
696 {
697 return cfs;
698 }
699}
700
ramangrover29ae85a1d2015-06-26 17:26:05 -0700701CreateFeedPolicyStatement FeedPolicySpecification() throws ParseException:
702{
703 String policyName = null;
704 String basePolicyName = null;
705 String sourcePolicyFile = null;
706 String definition = null;
707 boolean ifNotExists = false;
708 Map<String,String> properties = null;
709 CreateFeedPolicyStatement cfps = null;
710}
711{
712 (
713 "ingestion" "policy" policyName = Identifier() ifNotExists = IfNotExists()
714 <FROM>
715 ("policy" basePolicyName = Identifier() properties = Configuration() ("definition" definition = StringLiteral())?
716 {
717 cfps = new CreateFeedPolicyStatement(policyName,
718 basePolicyName, properties, definition, ifNotExists);
719 }
720 | "path" sourcePolicyFile = Identifier() ("definition" definition = StringLiteral())?
721 {
722 cfps = new CreateFeedPolicyStatement(policyName, sourcePolicyFile, definition, ifNotExists);
723 }
724 )
725
726 )
727 {
728 return cfps;
729 }
730}
731
ramangrover29a774ef22013-07-17 09:29:18 -0700732
733
Till Westmannd7dcb122013-05-16 13:19:09 -0700734List<VarIdentifier> ParameterList() throws ParseException:
735{
736 List<VarIdentifier> paramList = new ArrayList<VarIdentifier>();
737 VarIdentifier var = null;
738}
739{
Till Westmann31c21f92013-05-08 09:21:53 -0700740 <LEFTPAREN> (<VARIABLE>
741 {
742 var = new VarIdentifier();
Till Westmanna4242bc2013-05-08 17:49:55 -0700743 var.setValue(token.image);
Till Westmann31c21f92013-05-08 09:21:53 -0700744 paramList.add(var);
745 getCurrentScope().addNewVarSymbolToScope(var);
746 }
Till Westmann96c1f172013-08-01 02:05:48 -0700747 (<COMMA> <VARIABLE>
Till Westmann31c21f92013-05-08 09:21:53 -0700748 {
749 var = new VarIdentifier();
Till Westmanna4242bc2013-05-08 17:49:55 -0700750 var.setValue(token.image);
Till Westmann31c21f92013-05-08 09:21:53 -0700751 paramList.add(var);
752 getCurrentScope().addNewVarSymbolToScope(var);
753 }
Till Westmannd7dcb122013-05-16 13:19:09 -0700754 )*)? <RIGHTPAREN>
Till Westmann31c21f92013-05-08 09:21:53 -0700755 {
Till Westmannd7dcb122013-05-16 13:19:09 -0700756 return paramList;
Till Westmann31c21f92013-05-08 09:21:53 -0700757 }
758}
759
760boolean IfNotExists() throws ParseException:
761{
762}
763{
764 ( "if not exists"
765 {
766 return true;
767 }
768 )?
769 {
770 return false;
771 }
772}
773
774FunctionSignature ApplyFunction() throws ParseException:
775{
Raman Grover25a2b2e2013-09-27 18:22:23 +0530776 FunctionName functioName = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700777 FunctionSignature funcSig = null;
778}
779{
Raman Grover25a2b2e2013-09-27 18:22:23 +0530780 "apply" "function" functioName = FunctionName()
Till Westmann31c21f92013-05-08 09:21:53 -0700781 {
Raman Grover25a2b2e2013-09-27 18:22:23 +0530782 String fqFunctionName = functioName.library == null ? functioName.function : functioName.library + "#" + functioName.function;
783 return new FunctionSignature(functioName.dataverse, fqFunctionName, 1);
Till Westmann31c21f92013-05-08 09:21:53 -0700784 }
785}
786
ramangrover29566b3a92013-05-28 09:07:10 -0700787String GetPolicy() throws ParseException:
788{
789 String policy = null;
790}
791{
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800792 "using" "policy" policy = Identifier()
ramangrover29566b3a92013-05-28 09:07:10 -0700793 {
794 return policy;
795 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800796
797}
ramangrover29566b3a92013-05-28 09:07:10 -0700798
Till Westmann31c21f92013-05-08 09:21:53 -0700799FunctionSignature FunctionSignature() throws ParseException:
800{
ramangrover299f76a5e2013-06-18 10:25:17 -0700801 FunctionName fctName = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700802 int arity = 0;
803}
804{
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800805 fctName = FunctionName() "@" <INTEGER_LITERAL>
806 {
Till Westmanna4242bc2013-05-08 17:49:55 -0700807 arity = new Integer(token.image);
Till Westmann31c21f92013-05-08 09:21:53 -0700808 if (arity < 0 && arity != FunctionIdentifier.VARARGS) {
809 throw new ParseException(" invalid arity:" + arity);
810 }
811
ramangrover299f76a5e2013-06-18 10:25:17 -0700812 // TODO use fctName.library
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800813 String fqFunctionName = fctName.library == null ? fctName.function : fctName.library + "#" + fctName.function;
ramangrover2993dd8232013-07-03 22:51:25 -0700814 return new FunctionSignature(fctName.dataverse, fqFunctionName, arity);
Till Westmann31c21f92013-05-08 09:21:53 -0700815 }
816}
817
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700818List<List<String>> PrimaryKey() throws ParseException:
Till Westmann31c21f92013-05-08 09:21:53 -0700819{
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700820 List<String> tmp = null;
821 List<List<String>> primaryKeyFields = new ArrayList<List<String>>();
Till Westmann31c21f92013-05-08 09:21:53 -0700822}
823{
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700824 "primary" "key" tmp = NestedField()
Till Westmann31c21f92013-05-08 09:21:53 -0700825 {
Till Westmann14a20a72013-05-09 00:06:24 -0700826 primaryKeyFields.add(tmp);
Till Westmann31c21f92013-05-08 09:21:53 -0700827 }
Ildar Absalyamov04b2b772015-03-19 15:09:51 -0700828 ( <COMMA> tmp = NestedField()
Till Westmann31c21f92013-05-08 09:21:53 -0700829 {
Till Westmann14a20a72013-05-09 00:06:24 -0700830 primaryKeyFields.add(tmp);
Till Westmann31c21f92013-05-08 09:21:53 -0700831 }
832 )*
833 {
834 return primaryKeyFields;
835 }
836}
837
838Statement DropStatement() throws ParseException:
839{
Till Westmann14a20a72013-05-09 00:06:24 -0700840 String id = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700841 Pair<Identifier,Identifier> pairId = null;
842 Triple<Identifier,Identifier,Identifier> tripleId = null;
843 FunctionSignature funcSig = null;
844 boolean ifExists = false;
845 Statement stmt = null;
846}
847{
848 "drop"
849 (
850 <DATASET> pairId = QualifiedName() ifExists = IfExists()
851 {
852 stmt = new DropStatement(pairId.first, pairId.second, ifExists);
853 }
854 | "index" tripleId = DoubleQualifiedName() ifExists = IfExists()
855 {
856 stmt = new IndexDropStatement(tripleId.first, tripleId.second, tripleId.third, ifExists);
857 }
Till Westmanna4242bc2013-05-08 17:49:55 -0700858 | "nodegroup" id = Identifier() ifExists = IfExists()
Till Westmann31c21f92013-05-08 09:21:53 -0700859 {
Till Westmann14a20a72013-05-09 00:06:24 -0700860 stmt = new NodeGroupDropStatement(new Identifier(id), ifExists);
Till Westmann31c21f92013-05-08 09:21:53 -0700861 }
ramangrover299f76a5e2013-06-18 10:25:17 -0700862 | "type" pairId = TypeName() ifExists = IfExists()
Till Westmann31c21f92013-05-08 09:21:53 -0700863 {
864 stmt = new TypeDropStatement(pairId.first, pairId.second, ifExists);
865 }
Till Westmanna4242bc2013-05-08 17:49:55 -0700866 | "dataverse" id = Identifier() ifExists = IfExists()
Till Westmann31c21f92013-05-08 09:21:53 -0700867 {
Till Westmann14a20a72013-05-09 00:06:24 -0700868 stmt = new DataverseDropStatement(new Identifier(id), ifExists);
Till Westmann31c21f92013-05-08 09:21:53 -0700869 }
870 | "function" funcSig = FunctionSignature() ifExists = IfExists()
871 {
872 stmt = new FunctionDropStatement(funcSig, ifExists);
873 }
ramangrover29a774ef22013-07-17 09:29:18 -0700874 | "feed" pairId = QualifiedName() ifExists = IfExists()
875 {
876 stmt = new FeedDropStatement(pairId.first, pairId.second, ifExists);
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800877 }
Till Westmann31c21f92013-05-08 09:21:53 -0700878 )
879 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800880 return stmt;
Till Westmann31c21f92013-05-08 09:21:53 -0700881 }
882}
883
884boolean IfExists() throws ParseException :
885{
886}
887{
Till Westmann96c1f172013-08-01 02:05:48 -0700888 ( <IF> "exists"
Till Westmann31c21f92013-05-08 09:21:53 -0700889 {
890 return true;
891 }
892 )?
893 {
894 return false;
vinayakb38b7ca42012-03-05 05:44:15 +0000895 }
896}
897
898InsertStatement InsertStatement() throws ParseException:
899{
Till Westmann31c21f92013-05-08 09:21:53 -0700900 Pair<Identifier,Identifier> nameComponents = null;
901 Query query;
vinayakb38b7ca42012-03-05 05:44:15 +0000902}
903{
Till Westmann31c21f92013-05-08 09:21:53 -0700904 "insert" "into" <DATASET> nameComponents = QualifiedName() query = Query()
905 {
906 return new InsertStatement(nameComponents.first, nameComponents.second, query, getVarCounter());
907 }
vinayakb38b7ca42012-03-05 05:44:15 +0000908}
909
910DeleteStatement DeleteStatement() throws ParseException:
911{
Till Westmann31c21f92013-05-08 09:21:53 -0700912 VariableExpr var = null;
913 Expression condition = null;
914 Pair<Identifier, Identifier> nameComponents;
Abdullah Alamoudidb37f662014-07-14 21:51:37 +0300915 // This is related to the new metadata lock management
916 setDataverses(new ArrayList<String>());
917 setDatasets(new ArrayList<String>());
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800918
vinayakb38b7ca42012-03-05 05:44:15 +0000919}
920{
Till Westmann31c21f92013-05-08 09:21:53 -0700921 "delete" var = Variable()
922 {
923 getCurrentScope().addNewVarSymbolToScope(var.getVar());
924 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800925 <FROM> <DATASET> nameComponents = QualifiedName()
salsubaieedf89fbc2013-12-21 19:51:42 -0800926 (<WHERE> condition = Expression())?
927 {
Abdullah Alamoudidb37f662014-07-14 21:51:37 +0300928 // First we get the dataverses and datasets that we want to lock
929 List<String> dataverses = getDataverses();
930 List<String> datasets = getDatasets();
931 // we remove the pointer to the dataverses and datasets
932 setDataverses(null);
933 setDatasets(null);
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800934 return new DeleteStatement(var, nameComponents.first, nameComponents.second,
935 condition, getVarCounter(), dataverses, datasets);
Till Westmann31c21f92013-05-08 09:21:53 -0700936 }
vinayakb38b7ca42012-03-05 05:44:15 +0000937}
938
939UpdateStatement UpdateStatement() throws ParseException:
940{
Till Westmann31c21f92013-05-08 09:21:53 -0700941 VariableExpr vars;
942 Expression target;
943 Expression condition;
944 UpdateClause uc;
945 List<UpdateClause> ucs = new ArrayList<UpdateClause>();
vinayakb38b7ca42012-03-05 05:44:15 +0000946}
947{
Till Westmann96c1f172013-08-01 02:05:48 -0700948 "update" vars = Variable() <IN> target = Expression()
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800949 <WHERE> condition = Expression()
Till Westmann31c21f92013-05-08 09:21:53 -0700950 <LEFTPAREN> (uc = UpdateClause()
951 {
952 ucs.add(uc);
953 }
Till Westmann96c1f172013-08-01 02:05:48 -0700954 (<COMMA> uc = UpdateClause()
Till Westmann31c21f92013-05-08 09:21:53 -0700955 {
956 ucs.add(uc);
957 }
958 )*) <RIGHTPAREN>
959 {
960 return new UpdateStatement(vars, target, condition, ucs);
961 }
vinayakb38b7ca42012-03-05 05:44:15 +0000962}
963
vinayakb38b7ca42012-03-05 05:44:15 +0000964UpdateClause UpdateClause() throws ParseException:
965{
Till Westmann31c21f92013-05-08 09:21:53 -0700966 Expression target = null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800967 Expression value = null ;
Till Westmann31c21f92013-05-08 09:21:53 -0700968 InsertStatement is = null;
969 DeleteStatement ds = null;
970 UpdateStatement us = null;
971 Expression condition = null;
972 UpdateClause ifbranch = null;
973 UpdateClause elsebranch = null;
vinayakb38b7ca42012-03-05 05:44:15 +0000974}
975{
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800976 "set" target = Expression() <ASSIGN> value = Expression()
Till Westmann31c21f92013-05-08 09:21:53 -0700977 | is = InsertStatement()
978 | ds = DeleteStatement()
979 | us = UpdateStatement()
Till Westmann96c1f172013-08-01 02:05:48 -0700980 | <IF> <LEFTPAREN> condition = Expression() <RIGHTPAREN>
981 <THEN> ifbranch = UpdateClause()
Taewoo Kima12d8cd2015-03-04 13:47:08 -0800982 [LOOKAHEAD(1) <ELSE> elsebranch = UpdateClause()]
Till Westmann31c21f92013-05-08 09:21:53 -0700983 {
984 return new UpdateClause(target, value, is, ds, us, condition, ifbranch, elsebranch);
985 }
vinayakb38b7ca42012-03-05 05:44:15 +0000986}
987
vinayakb38b7ca42012-03-05 05:44:15 +0000988Statement SetStatement() throws ParseException:
989{
990 String pn = null;
Till Westmann31c21f92013-05-08 09:21:53 -0700991 String pv = null;
vinayakb38b7ca42012-03-05 05:44:15 +0000992}
993{
Till Westmann7d535322013-05-09 00:40:02 -0700994 "set" pn = Identifier() pv = StringLiteral()
Till Westmann31c21f92013-05-08 09:21:53 -0700995 {
Till Westmann31c21f92013-05-08 09:21:53 -0700996 return new SetStatement(pn, pv);
997 }
vinayakb38b7ca42012-03-05 05:44:15 +0000998}
999
1000Statement WriteStatement() throws ParseException:
1001{
Till Westmann14a20a72013-05-09 00:06:24 -07001002 String nodeName = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001003 String fileName = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001004 Query query;
1005 String writerClass = null;
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001006 Pair<Identifier,Identifier> nameComponents = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001007}
1008{
Till Westmann96c1f172013-08-01 02:05:48 -07001009 "write" "output" "to" nodeName = Identifier() <COLON> fileName = StringLiteral()
Till Westmann7d535322013-05-09 00:40:02 -07001010 ( "using" writerClass = StringLiteral() )?
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001011 {
1012 return new WriteStatement(new Identifier(nodeName), fileName, writerClass);
vinayakb38b7ca42012-03-05 05:44:15 +00001013 }
1014}
1015
zheilbron28e026f2013-11-20 10:15:15 -08001016LoadStatement LoadStatement() throws ParseException:
vinayakb38b7ca42012-03-05 05:44:15 +00001017{
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001018 Identifier dataverseName = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001019 Identifier datasetName = null;
1020 boolean alreadySorted = false;
ramangrover29669d8f62013-02-11 06:03:32 +00001021 String adapterName;
vinayakb38b7ca42012-03-05 05:44:15 +00001022 Map<String,String> properties;
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001023 Pair<Identifier,Identifier> nameComponents = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001024}
1025{
Till Westmann31c21f92013-05-08 09:21:53 -07001026 "load" <DATASET> nameComponents = QualifiedName()
vinayakb38b7ca42012-03-05 05:44:15 +00001027 {
Till Westmann31c21f92013-05-08 09:21:53 -07001028 dataverseName = nameComponents.first;
1029 datasetName = nameComponents.second;
vinayakb38b7ca42012-03-05 05:44:15 +00001030 }
Till Westmann31c21f92013-05-08 09:21:53 -07001031 "using" adapterName = AdapterName() properties = Configuration()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001032 ("pre-sorted"
vinayakb38b7ca42012-03-05 05:44:15 +00001033 {
Till Westmann31c21f92013-05-08 09:21:53 -07001034 alreadySorted = true;
vinayakb38b7ca42012-03-05 05:44:15 +00001035 }
1036 )?
Till Westmann31c21f92013-05-08 09:21:53 -07001037 {
zheilbron28e026f2013-11-20 10:15:15 -08001038 return new LoadStatement(dataverseName, datasetName, adapterName, properties, alreadySorted);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001039 }
vinayakb38b7ca42012-03-05 05:44:15 +00001040}
1041
vinayakb38b7ca42012-03-05 05:44:15 +00001042
Till Westmann31c21f92013-05-08 09:21:53 -07001043String AdapterName() throws ParseException :
vinayakb38b7ca42012-03-05 05:44:15 +00001044{
ramangrover29669d8f62013-02-11 06:03:32 +00001045 String adapterName = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001046}
1047{
Till Westmann68d99652013-05-09 11:15:21 -07001048 adapterName = Identifier()
vinayakb38b7ca42012-03-05 05:44:15 +00001049 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001050 return adapterName;
vinayakb38b7ca42012-03-05 05:44:15 +00001051 }
vinayakb38b7ca42012-03-05 05:44:15 +00001052}
1053
salsubaiee0b423fa2013-09-19 19:16:48 -07001054Statement CompactStatement() throws ParseException:
1055{
1056 Pair<Identifier,Identifier> nameComponents = null;
1057 Statement stmt = null;
1058}
1059{
1060 "compact" <DATASET> nameComponents = QualifiedName()
1061 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001062 stmt = new CompactStatement(nameComponents.first, nameComponents.second);
salsubaiee0b423fa2013-09-19 19:16:48 -07001063 }
1064 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001065 return stmt;
salsubaiee0b423fa2013-09-19 19:16:48 -07001066 }
1067}
1068
Till Westmann31c21f92013-05-08 09:21:53 -07001069Statement FeedStatement() throws ParseException:
vinayakb38b7ca42012-03-05 05:44:15 +00001070{
ramangrover29a774ef22013-07-17 09:29:18 -07001071 Pair<Identifier,Identifier> feedNameComponents = null;
1072 Pair<Identifier,Identifier> datasetNameComponents = null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001073
Till Westmann31c21f92013-05-08 09:21:53 -07001074 Map<String,String> configuration = null;
1075 Statement stmt = null;
ramangrover29566b3a92013-05-28 09:07:10 -07001076 String policy = null;
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001077}
1078{
Till Westmann31c21f92013-05-08 09:21:53 -07001079 (
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001080 "connect" "feed" feedNameComponents = QualifiedName() "to" <DATASET> datasetNameComponents = QualifiedName() (policy = GetPolicy())?
Till Westmann31c21f92013-05-08 09:21:53 -07001081 {
ramangrover29a774ef22013-07-17 09:29:18 -07001082 stmt = new ConnectFeedStatement(feedNameComponents, datasetNameComponents, policy, getVarCounter());
Till Westmann31c21f92013-05-08 09:21:53 -07001083 }
buyingyi2fd7fa62014-11-24 19:31:55 -08001084 | "disconnect" "feed" feedNameComponents = QualifiedName() <FROM> <DATASET> datasetNameComponents = QualifiedName()
Till Westmann31c21f92013-05-08 09:21:53 -07001085 {
ramangrover29a774ef22013-07-17 09:29:18 -07001086 stmt = new DisconnectFeedStatement(feedNameComponents, datasetNameComponents);
Till Westmann31c21f92013-05-08 09:21:53 -07001087 }
1088 )
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001089 {
Till Westmann31c21f92013-05-08 09:21:53 -07001090 return stmt;
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001091 }
1092}
1093
Till Westmann31c21f92013-05-08 09:21:53 -07001094Map<String,String> Configuration() throws ParseException :
vinayakb38b7ca42012-03-05 05:44:15 +00001095{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001096 Map<String,String> configuration = new LinkedHashMap<String,String>();
1097 Pair<String, String> keyValuePair = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001098}
1099{
Till Westmann31c21f92013-05-08 09:21:53 -07001100 <LEFTPAREN> ( keyValuePair = KeyValuePair()
vinayakb38b7ca42012-03-05 05:44:15 +00001101 {
Till Westmann31c21f92013-05-08 09:21:53 -07001102 configuration.put(keyValuePair.first, keyValuePair.second);
vinayakb38b7ca42012-03-05 05:44:15 +00001103 }
Till Westmann96c1f172013-08-01 02:05:48 -07001104 ( <COMMA> keyValuePair = KeyValuePair()
vinayakb38b7ca42012-03-05 05:44:15 +00001105 {
Till Westmann31c21f92013-05-08 09:21:53 -07001106 configuration.put(keyValuePair.first, keyValuePair.second);
vinayakb38b7ca42012-03-05 05:44:15 +00001107 }
Till Westmann31c21f92013-05-08 09:21:53 -07001108 )* )? <RIGHTPAREN>
1109 {
1110 return configuration;
1111 }
1112}
1113
1114Pair<String, String> KeyValuePair() throws ParseException:
1115{
1116 String key;
1117 String value;
1118}
1119{
Till Westmann96c1f172013-08-01 02:05:48 -07001120 <LEFTPAREN> key = StringLiteral() <EQ> value = StringLiteral() <RIGHTPAREN>
Till Westmann31c21f92013-05-08 09:21:53 -07001121 {
1122 return new Pair<String, String>(key, value);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001123 }
Till Westmann31c21f92013-05-08 09:21:53 -07001124}
1125
1126Map<String,String> Properties() throws ParseException:
1127{
1128 Map<String,String> properties = new HashMap<String,String>();
1129 Pair<String, String> property;
1130}
1131{
1132 ( <LEFTPAREN> property = Property()
1133 {
1134 properties.put(property.first, property.second);
1135 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001136 ( <COMMA> property = Property()
Till Westmann31c21f92013-05-08 09:21:53 -07001137 {
1138 properties.put(property.first, property.second);
1139 }
1140 )* <RIGHTPAREN> )?
1141 {
1142 return properties;
1143 }
1144}
1145
1146Pair<String, String> Property() throws ParseException:
1147{
1148 String key;
1149 String value;
1150}
1151{
Till Westmann96c1f172013-08-01 02:05:48 -07001152 key = Identifier() <EQ> ( value = StringLiteral() | <INTEGER_LITERAL>
Till Westmann31c21f92013-05-08 09:21:53 -07001153 {
1154 try {
1155 value = "" + Long.valueOf(token.image);
1156 } catch (NumberFormatException nfe) {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001157 throw new ParseException("inapproriate value: " + token.image);
Till Westmann31c21f92013-05-08 09:21:53 -07001158 }
1159 }
1160 )
1161 {
1162 return new Pair<String, String>(key.toUpperCase(), value);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001163 }
vinayakb38b7ca42012-03-05 05:44:15 +00001164}
1165
Ildar Absalyamov04b2b772015-03-19 15:09:51 -07001166TypeExpression IndexedTypeExpr() throws ParseException:
1167{
1168 TypeExpression typeExpr = null;
1169}
1170{
1171 (
1172 typeExpr = TypeReference()
1173 | typeExpr = OrderedListTypeDef()
1174 | typeExpr = UnorderedListTypeDef()
1175 )
1176 {
1177 return typeExpr;
1178 }
1179}
1180
vinayakb38b7ca42012-03-05 05:44:15 +00001181TypeExpression TypeExpr() throws ParseException:
1182{
1183 TypeExpression typeExpr = null;
1184}
1185{
1186 (
1187 typeExpr = RecordTypeDef()
1188 | typeExpr = TypeReference()
1189 | typeExpr = OrderedListTypeDef()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001190 | typeExpr = UnorderedListTypeDef()
1191 )
vinayakb38b7ca42012-03-05 05:44:15 +00001192 {
1193 return typeExpr;
1194 }
1195}
1196
1197RecordTypeDefinition RecordTypeDef() throws ParseException:
1198{
1199 RecordTypeDefinition recType = new RecordTypeDefinition();
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001200 RecordTypeDefinition.RecordKind recordKind = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001201}
1202{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001203 ( "closed" { recordKind = RecordTypeDefinition.RecordKind.CLOSED; }
vinayakb38b7ca42012-03-05 05:44:15 +00001204 | "open" { recordKind = RecordTypeDefinition.RecordKind.OPEN; } )?
Till Westmann96c1f172013-08-01 02:05:48 -07001205 <LEFTBRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00001206 {
1207 String hint = getHint(token);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001208 if (hint != null) {
vinayakb38b7ca42012-03-05 05:44:15 +00001209 String splits[] = hint.split(" +");
1210 if (splits[0].equals(GEN_FIELDS_HINT)) {
1211 if (splits.length != 5) {
1212 throw new ParseException("Expecting: /*+ gen-fields <type> <min> <max> <prefix>*/");
1213 }
1214 if (!splits[1].equals("int")) {
1215 throw new ParseException("The only supported type for gen-fields is int.");
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001216 }
1217 UndeclaredFieldsDataGen ufdg = new UndeclaredFieldsDataGen(UndeclaredFieldsDataGen.Type.INT,
vinayakb38b7ca42012-03-05 05:44:15 +00001218 Integer.parseInt(splits[2]), Integer.parseInt(splits[3]), splits[4]);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001219 recType.setUndeclaredFieldsDataGen(ufdg);
vinayakb38b7ca42012-03-05 05:44:15 +00001220 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001221 }
1222
vinayakb38b7ca42012-03-05 05:44:15 +00001223 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001224 (
1225 RecordField(recType)
1226 ( <COMMA> RecordField(recType) )*
1227 )?
Till Westmann96c1f172013-08-01 02:05:48 -07001228 <RIGHTBRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00001229 {
1230 if (recordKind == null) {
1231 recordKind = RecordTypeDefinition.RecordKind.OPEN;
1232 }
1233 recType.setRecordKind(recordKind);
1234 return recType;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001235 }
vinayakb38b7ca42012-03-05 05:44:15 +00001236}
1237
1238void RecordField(RecordTypeDefinition recType) throws ParseException:
1239{
Till Westmann77cb2f42013-07-15 16:44:19 -07001240 String fieldName;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001241 TypeExpression type = null;
Till Westmann77cb2f42013-07-15 16:44:19 -07001242 boolean nullable = false;
vinayakb38b7ca42012-03-05 05:44:15 +00001243}
1244{
Till Westmann77cb2f42013-07-15 16:44:19 -07001245 fieldName = Identifier()
1246 {
1247 String hint = getHint(token);
1248 IRecordFieldDataGen rfdg = hint != null ? parseFieldDataGen(hint) : null;
1249 }
Till Westmann96c1f172013-08-01 02:05:48 -07001250 <COLON> type = TypeExpr() (<QUES> { nullable = true; } )?
Till Westmann77cb2f42013-07-15 16:44:19 -07001251 {
1252 recType.addField(fieldName, type, nullable, rfdg);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001253 }
vinayakb38b7ca42012-03-05 05:44:15 +00001254}
1255
1256TypeReferenceExpression TypeReference() throws ParseException:
vinayakb38b7ca42012-03-05 05:44:15 +00001257{
Till Westmann14a20a72013-05-09 00:06:24 -07001258 String id = null;
Till Westmanna4242bc2013-05-08 17:49:55 -07001259}
1260{
1261 id = Identifier()
1262 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001263 if (id.equalsIgnoreCase("int")) {
1264 id = "int64";
1265 }
1266
Till Westmann14a20a72013-05-09 00:06:24 -07001267 return new TypeReferenceExpression(new Identifier(id));
Till Westmanna4242bc2013-05-08 17:49:55 -07001268 }
vinayakb38b7ca42012-03-05 05:44:15 +00001269}
1270
1271OrderedListTypeDefinition OrderedListTypeDef() throws ParseException:
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001272{
vinayakb38b7ca42012-03-05 05:44:15 +00001273 TypeExpression type = null;
1274}
1275{
Till Westmann96c1f172013-08-01 02:05:48 -07001276 <LEFTBRACKET>
vinayakb38b7ca42012-03-05 05:44:15 +00001277 ( type = TypeExpr() )
Till Westmann96c1f172013-08-01 02:05:48 -07001278 <RIGHTBRACKET>
vinayakb38b7ca42012-03-05 05:44:15 +00001279 {
1280 return new OrderedListTypeDefinition(type);
1281 }
1282}
1283
1284
1285UnorderedListTypeDefinition UnorderedListTypeDef() throws ParseException:
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001286{
vinayakb38b7ca42012-03-05 05:44:15 +00001287 TypeExpression type = null;
1288}
1289{
Till Westmann96c1f172013-08-01 02:05:48 -07001290 <LEFTDBLBRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00001291 ( type = TypeExpr() )
Till Westmann96c1f172013-08-01 02:05:48 -07001292 <RIGHTDBLBRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00001293 {
1294 return new UnorderedListTypeDefinition(type);
1295 }
1296}
1297
ramangrover299f76a5e2013-06-18 10:25:17 -07001298FunctionName FunctionName() throws ParseException:
1299{
1300 String first = null;
1301 String second = null;
1302 String third = null;
1303 boolean secondAfterDot = false;
1304}
1305{
zheilbron555dc9d2013-08-14 19:58:00 -07001306 first = Identifier() ( <DOT> second = Identifier()
ramangrover299f76a5e2013-06-18 10:25:17 -07001307 {
1308 secondAfterDot = true;
1309 }
1310 ("#" third = Identifier())? | "#" second = Identifier() )?
1311 {
1312 FunctionName result = new FunctionName();
1313 if (second == null) {
1314 result.dataverse = defaultDataverse;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001315 result.library = null;
1316 result.function = first;
ramangrover299f76a5e2013-06-18 10:25:17 -07001317 } else if (third == null) {
1318 if (secondAfterDot) {
1319 result.dataverse = first;
1320 result.library = null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001321 result.function = second;
ramangrover299f76a5e2013-06-18 10:25:17 -07001322 } else {
1323 result.dataverse = defaultDataverse;
1324 result.library = first;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001325 result.function = second;
ramangrover299f76a5e2013-06-18 10:25:17 -07001326 }
1327 } else {
1328 result.dataverse = first;
1329 result.library = second;
1330 result.function = third;
1331 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001332
1333 if (result.function.equalsIgnoreCase("int")) {
1334 result.function = "int64";
1335 }
ramangrover299f76a5e2013-06-18 10:25:17 -07001336 return result;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001337 }
ramangrover299f76a5e2013-06-18 10:25:17 -07001338}
Till Westmann31c21f92013-05-08 09:21:53 -07001339
ramangrover299f76a5e2013-06-18 10:25:17 -07001340
1341Pair<Identifier,Identifier> TypeName() throws ParseException:
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001342{
Till Westmann31c21f92013-05-08 09:21:53 -07001343 Pair<Identifier,Identifier> name = null;
1344}
1345{
1346 name = QualifiedName()
1347 {
1348 if (name.first == null) {
1349 name.first = new Identifier(defaultDataverse);
1350 }
1351 return name;
1352 }
1353}
1354
Till Westmann14a20a72013-05-09 00:06:24 -07001355String Identifier() throws ParseException:
Till Westmanna4242bc2013-05-08 17:49:55 -07001356{
Till Westmann68d99652013-05-09 11:15:21 -07001357 String lit = null;
Till Westmanna4242bc2013-05-08 17:49:55 -07001358}
1359{
1360 <IDENTIFIER>
1361 {
Till Westmann14a20a72013-05-09 00:06:24 -07001362 return token.image;
Till Westmanna4242bc2013-05-08 17:49:55 -07001363 }
Till Westmann68d99652013-05-09 11:15:21 -07001364 | lit = StringLiteral()
1365 {
1366 return lit;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001367 }
Till Westmanna4242bc2013-05-08 17:49:55 -07001368}
1369
Ildar Absalyamov04b2b772015-03-19 15:09:51 -07001370Pair<List<String>, TypeExpression> OpenField() throws ParseException:
1371{
1372 TypeExpression fieldType = null;
1373 List<String> fieldList = null;
1374}
1375{
1376 fieldList = NestedField()
1377 ( <COLON> fieldType = IndexedTypeExpr() )?
1378 {
1379 return new Pair<List<String>, TypeExpression>(fieldList, fieldType);
1380 }
1381}
1382
1383List<String> NestedField() throws ParseException:
1384{
1385 List<String> exprList = new ArrayList<String>();
1386 String lit = null;
1387}
1388{
1389 lit = Identifier()
1390 {
1391 exprList.add(lit);
1392 }
1393 (<DOT>
1394 lit = Identifier()
1395 {
1396 exprList.add(lit);
1397 }
1398 )*
1399 {
1400 return exprList;
1401 }
1402}
1403
1404
1405
Till Westmann7d535322013-05-09 00:40:02 -07001406String StringLiteral() throws ParseException:
1407{
1408}
1409{
1410 <STRING_LITERAL>
1411 {
1412 return removeQuotesAndEscapes(token.image);
1413 }
1414}
1415
Till Westmann31c21f92013-05-08 09:21:53 -07001416Pair<Identifier,Identifier> QualifiedName() throws ParseException:
1417{
Till Westmann14a20a72013-05-09 00:06:24 -07001418 String first = null;
1419 String second = null;
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001420}
1421{
Till Westmann96c1f172013-08-01 02:05:48 -07001422 first = Identifier() (<DOT> second = Identifier())?
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001423 {
Till Westmann14a20a72013-05-09 00:06:24 -07001424 Identifier id1 = null;
1425 Identifier id2 = null;
Till Westmann31c21f92013-05-08 09:21:53 -07001426 if (second == null) {
Till Westmann14a20a72013-05-09 00:06:24 -07001427 id2 = new Identifier(first);
1428 } else
1429 {
1430 id1 = new Identifier(first);
1431 id2 = new Identifier(second);
1432 }
1433 return new Pair<Identifier,Identifier>(id1, id2);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001434 }
1435}
1436
Till Westmann31c21f92013-05-08 09:21:53 -07001437Triple<Identifier,Identifier,Identifier> DoubleQualifiedName() throws ParseException:
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001438{
Till Westmann14a20a72013-05-09 00:06:24 -07001439 String first = null;
1440 String second = null;
1441 String third = null;
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001442}
1443{
Till Westmann96c1f172013-08-01 02:05:48 -07001444 first = Identifier() <DOT> second = Identifier() (<DOT> third = Identifier())?
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001445 {
Till Westmann14a20a72013-05-09 00:06:24 -07001446 Identifier id1 = null;
1447 Identifier id2 = null;
1448 Identifier id3 = null;
Till Westmann31c21f92013-05-08 09:21:53 -07001449 if (third == null) {
Till Westmann14a20a72013-05-09 00:06:24 -07001450 id2 = new Identifier(first);
1451 id3 = new Identifier(second);
1452 } else {
1453 id1 = new Identifier(first);
1454 id2 = new Identifier(second);
1455 id3 = new Identifier(third);
1456 }
1457 return new Triple<Identifier,Identifier,Identifier>(id1, id2, id3);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001458 }
1459}
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001460
vinayakb38b7ca42012-03-05 05:44:15 +00001461FunctionDecl FunctionDeclaration() throws ParseException:
1462{
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001463 FunctionDecl funcDecl;
1464 FunctionSignature signature;
ramangrover29a13f2422012-03-15 23:01:27 +00001465 String functionName;
vinayakb38b7ca42012-03-05 05:44:15 +00001466 List<VarIdentifier> paramList = new ArrayList<VarIdentifier>();
1467 Expression funcBody;
vinayakb38b7ca42012-03-05 05:44:15 +00001468 createNewScope();
1469}
1470{
Till Westmannd7dcb122013-05-16 13:19:09 -07001471 "declare" "function" functionName = Identifier()
1472 paramList = ParameterList()
Till Westmann96c1f172013-08-01 02:05:48 -07001473 <LEFTBRACE> funcBody = Expression() <RIGHTBRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00001474 {
Till Westmannd7dcb122013-05-16 13:19:09 -07001475 signature = new FunctionSignature(defaultDataverse, functionName, paramList.size());
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001476 getCurrentScope().addFunctionDescriptor(signature, false);
1477 funcDecl = new FunctionDecl(signature, paramList, funcBody);
Till Westmannc6c4a742013-05-20 17:59:21 -07001478 removeCurrentScope();
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001479 return funcDecl;
vinayakb38b7ca42012-03-05 05:44:15 +00001480 }
1481}
1482
vinayakb38b7ca42012-03-05 05:44:15 +00001483
Till Westmann31c21f92013-05-08 09:21:53 -07001484Query Query() throws ParseException:
vinayakb38b7ca42012-03-05 05:44:15 +00001485{
1486 Query query = new Query();
Abdullah Alamoudidb37f662014-07-14 21:51:37 +03001487 // we set the pointers to the dataverses and datasets lists to fill them with entities to be locked
1488 setDataverses(query.getDataverses());
1489 setDatasets(query.getDatasets());
vinayakb38b7ca42012-03-05 05:44:15 +00001490 Expression expr;
1491}
1492{
Till Westmann31c21f92013-05-08 09:21:53 -07001493 expr = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00001494 {
1495 query.setBody(expr);
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00001496 query.setVarCounter(getVarCounter());
Abdullah Alamoudidb37f662014-07-14 21:51:37 +03001497 // we remove the pointers to the locked entities before we return the query object
1498 setDataverses(null);
1499 setDatasets(null);
vinayakb38b7ca42012-03-05 05:44:15 +00001500 return query;
1501 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001502
vinayakb38b7ca42012-03-05 05:44:15 +00001503}
1504
1505
1506
1507Expression Expression():
1508{
1509 Expression expr = null;
1510 Expression exprP = null;
1511}
1512{
1513(
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001514
vinayakb38b7ca42012-03-05 05:44:15 +00001515//OperatorExpr | IfThenElse | FLWOGRExpression | QuantifiedExpression
1516 expr = OperatorExpr()
1517 | expr = IfThenElse()
1518 | expr = FLWOGR()
1519 | expr = QuantifiedExpression()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001520
vinayakb38b7ca42012-03-05 05:44:15 +00001521
1522)
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001523 {
1524 return (exprP==null) ? expr : exprP;
1525 }
vinayakb38b7ca42012-03-05 05:44:15 +00001526}
1527
1528
1529
1530Expression OperatorExpr()throws ParseException:
1531{
1532 OperatorExpr op = null;
1533 Expression operand = null;
1534}
1535{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001536 operand = AndExpr()
1537 (
1538
1539 <OR>
1540 {
1541 if (op == null) {
1542 op = new OperatorExpr();
1543 op.addOperand(operand);
1544 op.setCurrentop(true);
1545 }
Till Westmanna4242bc2013-05-08 17:49:55 -07001546 op.addOperator(token.image);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001547 }
vinayakb38b7ca42012-03-05 05:44:15 +00001548
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001549 operand = AndExpr()
1550 {
1551 op.addOperand(operand);
1552 }
vinayakb38b7ca42012-03-05 05:44:15 +00001553
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001554 )*
1555
1556 {
1557 return op==null? operand: op;
1558 }
vinayakb38b7ca42012-03-05 05:44:15 +00001559}
1560
1561Expression AndExpr()throws ParseException:
1562{
1563 OperatorExpr op = null;
1564 Expression operand = null;
1565}
1566{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001567 operand = RelExpr()
1568 (
1569
1570 <AND>
1571 {
1572 if (op == null) {
1573 op = new OperatorExpr();
1574 op.addOperand(operand);
1575 op.setCurrentop(true);
1576 }
Till Westmanna4242bc2013-05-08 17:49:55 -07001577 op.addOperator(token.image);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001578 }
vinayakb38b7ca42012-03-05 05:44:15 +00001579
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001580 operand = RelExpr()
1581 {
1582 op.addOperand(operand);
1583 }
vinayakb38b7ca42012-03-05 05:44:15 +00001584
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001585 )*
1586
1587 {
1588 return op==null? operand: op;
1589 }
vinayakb38b7ca42012-03-05 05:44:15 +00001590}
1591
1592
1593
1594Expression RelExpr()throws ParseException:
1595{
1596 OperatorExpr op = null;
1597 Expression operand = null;
1598 boolean broadcast = false;
alexander.behm07617fd2012-07-25 10:13:50 +00001599 IExpressionAnnotation annotation = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001600}
1601{
1602 operand = AddExpr()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001603 {
1604 if (operand instanceof VariableExpr) {
1605 String hint = getHint(token);
vinayakb38b7ca42012-03-05 05:44:15 +00001606 if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) {
alexander.behm07617fd2012-07-25 10:13:50 +00001607 broadcast = true;
vinayakb38b7ca42012-03-05 05:44:15 +00001608 }
1609 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001610 }
vinayakb38b7ca42012-03-05 05:44:15 +00001611
1612 (
Till Westmann96c1f172013-08-01 02:05:48 -07001613 LOOKAHEAD(2)( <LT> | <GT> | <LE> | <GE> | <EQ> | <NE> |<SIMILAR>)
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001614 {
1615 String mhint = getHint(token);
1616 if (mhint != null) {
1617 if (mhint.equals(INDEXED_NESTED_LOOP_JOIN_HINT)) {
salsubaieedf89fbc2013-12-21 19:51:42 -08001618 annotation = IndexedNLJoinExpressionAnnotation.INSTANCE;
1619 } else if (mhint.equals(SKIP_SECONDARY_INDEX_SEARCH_HINT)) {
1620 annotation = SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE;
1621 }
alexander.behm07617fd2012-07-25 10:13:50 +00001622 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001623 if (op == null) {
1624 op = new OperatorExpr();
1625 op.addOperand(operand, broadcast);
vinayakb38b7ca42012-03-05 05:44:15 +00001626 op.setCurrentop(true);
1627 broadcast = false;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001628 }
Till Westmanna4242bc2013-05-08 17:49:55 -07001629 op.addOperator(token.image);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001630 }
1631
1632 operand = AddExpr()
1633 {
1634 broadcast = false;
alexander.behm07617fd2012-07-25 10:13:50 +00001635 if (operand instanceof VariableExpr) {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001636 String hint = getHint(token);
vinayakb38b7ca42012-03-05 05:44:15 +00001637 if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) {
1638 broadcast = true;
1639 }
alexander.behm07617fd2012-07-25 10:13:50 +00001640 }
vinayakb38b7ca42012-03-05 05:44:15 +00001641 op.addOperand(operand, broadcast);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001642 }
vinayakb38b7ca42012-03-05 05:44:15 +00001643 )?
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001644
1645 {
1646 if (annotation != null) {
1647 op.addHint(annotation);
1648 }
1649 return op==null? operand: op;
1650 }
vinayakb38b7ca42012-03-05 05:44:15 +00001651}
1652
1653Expression AddExpr()throws ParseException:
1654{
1655 OperatorExpr op = null;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001656 Expression operand = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001657}
1658{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001659 operand = MultExpr()
vinayakb38b7ca42012-03-05 05:44:15 +00001660
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001661 ( (<PLUS> | <MINUS>)
1662 {
1663 if (op == null) {
1664 op = new OperatorExpr();
1665 op.addOperand(operand);
1666 op.setCurrentop(true);
1667 }
1668 ((OperatorExpr)op).addOperator(token.image);
1669 }
vinayakb38b7ca42012-03-05 05:44:15 +00001670
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001671 operand = MultExpr()
1672 {
1673 op.addOperand(operand);
1674 }
1675 )*
1676
1677 {
1678 return op==null? operand: op;
1679 }
vinayakb38b7ca42012-03-05 05:44:15 +00001680}
1681
1682Expression MultExpr()throws ParseException:
1683{
1684 OperatorExpr op = null;
1685 Expression operand = null;
1686}
1687{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001688 operand = UnionExpr()
vinayakb38b7ca42012-03-05 05:44:15 +00001689
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001690 (( <MUL> | <DIV> | <MOD> | <CARET> | <IDIV>)
1691 {
1692 if (op == null) {
1693 op = new OperatorExpr();
vinayakb38b7ca42012-03-05 05:44:15 +00001694 op.addOperand(operand);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001695 op.setCurrentop(true);
1696 }
1697 op.addOperator(token.image);
1698 }
1699 operand = UnionExpr()
1700 {
1701 op.addOperand(operand);
1702 }
1703 )*
1704
1705 {
1706 return op==null?operand:op;
1707 }
vinayakb38b7ca42012-03-05 05:44:15 +00001708}
1709
1710Expression UnionExpr() throws ParseException:
1711{
1712 UnionExpr union = null;
1713 Expression operand1 = null;
1714 Expression operand2 = null;
1715}
1716{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001717 operand1 = UnaryExpr()
1718 (<UNION>
vinayakb38b7ca42012-03-05 05:44:15 +00001719 (operand2 = UnaryExpr()) {
1720 if (union == null) {
1721 union = new UnionExpr();
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001722 union.addExpr(operand1);
vinayakb38b7ca42012-03-05 05:44:15 +00001723 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001724 union.addExpr(operand2);
vinayakb38b7ca42012-03-05 05:44:15 +00001725 } )*
1726 {
1727 return (union == null)? operand1: union;
1728 }
1729}
1730
1731Expression UnaryExpr() throws ParseException:
1732{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001733 Expression uexpr = null;
1734 Expression expr = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001735}
1736{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001737 ( (<PLUS> | <MINUS>)
1738 {
1739 uexpr = new UnaryExpr();
1740 if("+".equals(token.image))
1741 ((UnaryExpr)uexpr).setSign(Sign.POSITIVE);
1742 else if("-".equals(token.image))
1743 ((UnaryExpr)uexpr).setSign(Sign.NEGATIVE);
1744 else
1745 throw new ParseException();
1746 }
1747 )?
1748
1749 expr = ValueExpr()
1750 {
1751 if(uexpr!=null){
1752 ((UnaryExpr)uexpr).setExpr(expr);
1753 return uexpr;
1754 }
1755 else{
1756 return expr;
1757 }
1758 }
vinayakb38b7ca42012-03-05 05:44:15 +00001759}
1760
Till Westmann04478e72013-05-13 23:01:34 -07001761Expression ValueExpr()throws ParseException:
vinayakb38b7ca42012-03-05 05:44:15 +00001762{
1763 Expression expr = null;
1764 Identifier ident = null;
1765 AbstractAccessor fa = null;
icetindila611ac72014-05-16 10:10:11 -07001766 Expression indexExpr = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001767}
1768{
Till Westmann04478e72013-05-13 23:01:34 -07001769 expr = PrimaryExpr() ( ident = Field()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001770 {
1771 fa = (fa == null ? new FieldAccessor(expr, ident)
Till Westmann04478e72013-05-13 23:01:34 -07001772 : new FieldAccessor(fa, ident));
1773 }
icetindila611ac72014-05-16 10:10:11 -07001774 | indexExpr = Index()
Till Westmann04478e72013-05-13 23:01:34 -07001775 {
icetindila611ac72014-05-16 10:10:11 -07001776 fa = (fa == null ? new IndexAccessor(expr, indexExpr)
1777 : new IndexAccessor(fa, indexExpr));
Till Westmann04478e72013-05-13 23:01:34 -07001778 }
1779 )*
1780 {
1781 return fa == null ? expr : fa;
1782 }
vinayakb38b7ca42012-03-05 05:44:15 +00001783}
1784
1785Identifier Field() throws ParseException:
1786{
Till Westmann14a20a72013-05-09 00:06:24 -07001787 String ident = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001788}
1789{
Till Westmann96c1f172013-08-01 02:05:48 -07001790 <DOT> ident = Identifier()
Till Westmanna4242bc2013-05-08 17:49:55 -07001791 {
Till Westmann14a20a72013-05-09 00:06:24 -07001792 return new Identifier(ident);
Till Westmanna4242bc2013-05-08 17:49:55 -07001793 }
vinayakb38b7ca42012-03-05 05:44:15 +00001794}
1795
icetindila611ac72014-05-16 10:10:11 -07001796Expression Index() throws ParseException:
vinayakb38b7ca42012-03-05 05:44:15 +00001797{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001798 Expression expr = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001799}
1800{
Till Westmann96c1f172013-08-01 02:05:48 -07001801 <LEFTBRACKET> ( expr = Expression()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001802 {
1803 if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION)
1804 {
1805 Literal lit = ((LiteralExpr)expr).getValue();
1806 if(lit.getLiteralType() != Literal.Type.INTEGER &&
1807 lit.getLiteralType() != Literal.Type.LONG) {
1808 throw new ParseException("Index should be an INTEGER");
vinayakb38b7ca42012-03-05 05:44:15 +00001809 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001810 }
1811 }
vinayakb38b7ca42012-03-05 05:44:15 +00001812
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001813 | <QUES> // ANY
1814
1815 )
vinayakb38b7ca42012-03-05 05:44:15 +00001816
Till Westmann96c1f172013-08-01 02:05:48 -07001817 <RIGHTBRACKET>
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001818 {
1819 return expr;
1820 }
vinayakb38b7ca42012-03-05 05:44:15 +00001821}
1822
1823
1824Expression PrimaryExpr()throws ParseException:
1825{
1826 Expression expr = null;
1827}
1828{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001829 ( LOOKAHEAD(2)
Till Westmann68d99652013-05-09 11:15:21 -07001830 expr = FunctionCallExpr()
1831 | expr = Literal()
1832 | expr = DatasetAccessExpression()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001833 | expr = VariableRef()
vinayakb38b7ca42012-03-05 05:44:15 +00001834 {
1835 if(((VariableExpr)expr).getIsNewVar() == true)
Till Westmann68d99652013-05-09 11:15:21 -07001836 throw new ParseException("can't find variable " + ((VariableExpr)expr).getVar());
vinayakb38b7ca42012-03-05 05:44:15 +00001837 }
Till Westmann68d99652013-05-09 11:15:21 -07001838 | expr = ListConstructor()
1839 | expr = RecordConstructor()
1840 | expr = ParenthesizedExpression()
1841 )
1842 {
1843 return expr;
1844 }
vinayakb38b7ca42012-03-05 05:44:15 +00001845}
1846
1847Expression Literal() throws ParseException:
1848{
vinayakb38b7ca42012-03-05 05:44:15 +00001849 LiteralExpr lit = new LiteralExpr();
Till Westmann7d535322013-05-09 00:40:02 -07001850 String str = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001851}
1852{
Till Westmann7d535322013-05-09 00:40:02 -07001853 ( str = StringLiteral()
vinayakb38b7ca42012-03-05 05:44:15 +00001854 {
Till Westmann7d535322013-05-09 00:40:02 -07001855 lit.setValue(new StringLiteral(str));
Till Westmanna4242bc2013-05-08 17:49:55 -07001856 }
1857 | <INTEGER_LITERAL>
vinayakb38b7ca42012-03-05 05:44:15 +00001858 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001859 lit.setValue(new LongIntegerLiteral(new Long(token.image)));
Till Westmanna4242bc2013-05-08 17:49:55 -07001860 }
1861 | <FLOAT_LITERAL>
vinayakb38b7ca42012-03-05 05:44:15 +00001862 {
Till Westmanna4242bc2013-05-08 17:49:55 -07001863 lit.setValue(new FloatLiteral(new Float(token.image)));
1864 }
1865 | <DOUBLE_LITERAL>
1866 {
1867 lit.setValue(new DoubleLiteral(new Double(token.image)));
1868 }
1869 | <NULL>
1870 {
1871 lit.setValue(NullLiteral.INSTANCE);
1872 }
1873 | <TRUE>
1874 {
1875 lit.setValue(TrueLiteral.INSTANCE);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001876 }
Till Westmanna4242bc2013-05-08 17:49:55 -07001877 | <FALSE>
1878 {
1879 lit.setValue(FalseLiteral.INSTANCE);
1880 }
1881 )
vinayakb38b7ca42012-03-05 05:44:15 +00001882 {
1883 return lit;
1884 }
1885}
1886
1887
1888VariableExpr VariableRef() throws ParseException:
1889{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001890 VariableExpr varExp = new VariableExpr();
1891 VarIdentifier var = new VarIdentifier();
vinayakb38b7ca42012-03-05 05:44:15 +00001892}
1893{
Till Westmann4f58e1a2013-05-20 18:29:54 -07001894 <VARIABLE>
vinayakb38b7ca42012-03-05 05:44:15 +00001895 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001896 String varName = token.image;
vinayakb38b7ca42012-03-05 05:44:15 +00001897 Identifier ident = lookupSymbol(varName);
1898 if (isInForbiddenScopes(varName)) {
1899 throw new ParseException("Inside limit clauses, it is disallowed to reference a variable having the same name as any variable bound in the same scope as the limit clause.");
1900 }
1901 if(ident != null) { // exist such ident
1902 varExp.setIsNewVar(false);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001903 varExp.setVar((VarIdentifier)ident);
vinayakb38b7ca42012-03-05 05:44:15 +00001904 } else {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001905 varExp.setVar(var);
vinayakb38b7ca42012-03-05 05:44:15 +00001906 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001907 var.setValue(varName);
vinayakb38b7ca42012-03-05 05:44:15 +00001908 return varExp;
1909 }
1910}
1911
1912
1913VariableExpr Variable() throws ParseException:
1914{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001915 VariableExpr varExp = new VariableExpr();
1916 VarIdentifier var = new VarIdentifier();
vinayakb38b7ca42012-03-05 05:44:15 +00001917}
1918{
Till Westmann4f58e1a2013-05-20 18:29:54 -07001919 <VARIABLE>
vinayakb38b7ca42012-03-05 05:44:15 +00001920 {
Till Westmanna4242bc2013-05-08 17:49:55 -07001921 Identifier ident = lookupSymbol(token.image);
vinayakb38b7ca42012-03-05 05:44:15 +00001922 if(ident != null) { // exist such ident
1923 varExp.setIsNewVar(false);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001924 }
1925 varExp.setVar(var);
1926 var.setValue(token.image);
vinayakb38b7ca42012-03-05 05:44:15 +00001927 return varExp;
1928 }
1929}
1930
1931Expression ListConstructor() throws ParseException:
1932{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001933 Expression expr = null;
vinayakb38b7ca42012-03-05 05:44:15 +00001934}
1935{
1936 (
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001937 expr = OrderedListConstructor() | expr = UnorderedListConstructor()
vinayakb38b7ca42012-03-05 05:44:15 +00001938 )
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001939
vinayakb38b7ca42012-03-05 05:44:15 +00001940 {
1941 return expr;
1942 }
1943}
1944
1945
1946ListConstructor OrderedListConstructor() throws ParseException:
1947{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001948 ListConstructor expr = new ListConstructor();
1949 Expression tmp = null;
1950 List<Expression> exprList = new ArrayList<Expression>();
1951 expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR);
vinayakb38b7ca42012-03-05 05:44:15 +00001952}
1953{
1954
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001955 <LEFTBRACKET>
1956 ( tmp = Expression()
1957 {
1958 exprList.add(tmp);
1959 }
1960
1961 (<COMMA> tmp = Expression() { exprList.add(tmp); })*
1962 )?
1963
Till Westmann96c1f172013-08-01 02:05:48 -07001964 <RIGHTBRACKET>
vinayakb38b7ca42012-03-05 05:44:15 +00001965
1966 {
1967 expr.setExprList(exprList);
1968 return expr;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001969 }
vinayakb38b7ca42012-03-05 05:44:15 +00001970}
1971
1972ListConstructor UnorderedListConstructor() throws ParseException:
1973{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001974 ListConstructor expr = new ListConstructor();
1975 Expression tmp = null;
1976 List<Expression> exprList = new ArrayList<Expression>();
1977 expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR);
vinayakb38b7ca42012-03-05 05:44:15 +00001978}
1979{
1980
Till Westmann96c1f172013-08-01 02:05:48 -07001981 <LEFTDBLBRACE> ( tmp = Expression()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001982 {
1983 exprList.add(tmp);
1984 }
Till Westmann96c1f172013-08-01 02:05:48 -07001985 (<COMMA> tmp = Expression() { exprList.add(tmp); })*)? <RIGHTDBLBRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00001986 {
1987 expr.setExprList(exprList);
1988 return expr;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001989 }
vinayakb38b7ca42012-03-05 05:44:15 +00001990}
1991
1992RecordConstructor RecordConstructor() throws ParseException:
1993{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08001994 RecordConstructor expr = new RecordConstructor();
1995 FieldBinding tmp = null;
1996 List<FieldBinding> fbList = new ArrayList<FieldBinding>();
vinayakb38b7ca42012-03-05 05:44:15 +00001997}
1998{
Till Westmann96c1f172013-08-01 02:05:48 -07001999 <LEFTBRACE> (tmp = FieldBinding()
vinayakb38b7ca42012-03-05 05:44:15 +00002000 {
2001 fbList.add(tmp);
2002 }
Till Westmann96c1f172013-08-01 02:05:48 -07002003 (<COMMA> tmp = FieldBinding() { fbList.add(tmp); })*)? <RIGHTBRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002004 {
2005 expr.setFbList(fbList);
2006 return expr;
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002007 }
vinayakb38b7ca42012-03-05 05:44:15 +00002008}
2009
2010FieldBinding FieldBinding() throws ParseException:
2011{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002012 FieldBinding fb = new FieldBinding();
2013 Expression left, right;
vinayakb38b7ca42012-03-05 05:44:15 +00002014}
2015{
Till Westmann96c1f172013-08-01 02:05:48 -07002016 left = Expression() <COLON> right = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002017 {
2018 fb.setLeftExpr(left);
2019 fb.setRightExpr(right);
2020 return fb;
2021 }
2022}
2023
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00002024
vinayakb38b7ca42012-03-05 05:44:15 +00002025Expression FunctionCallExpr() throws ParseException:
2026{
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00002027 CallExpr callExpr;
alexander.behm07617fd2012-07-25 10:13:50 +00002028 List<Expression> argList = new ArrayList<Expression>();
vinayakb38b7ca42012-03-05 05:44:15 +00002029 Expression tmp;
2030 int arity = 0;
ramangrover299f76a5e2013-06-18 10:25:17 -07002031 FunctionName funcName = null;
Till Westmann31c21f92013-05-08 09:21:53 -07002032 String hint = null;
vinayakb38b7ca42012-03-05 05:44:15 +00002033}
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002034{
ramangrover299f76a5e2013-06-18 10:25:17 -07002035 funcName = FunctionName()
vinayakb38b7ca42012-03-05 05:44:15 +00002036 {
Till Westmann31c21f92013-05-08 09:21:53 -07002037 hint = getHint(token);
vinayakb38b7ca42012-03-05 05:44:15 +00002038 }
Till Westmann31c21f92013-05-08 09:21:53 -07002039 <LEFTPAREN> (tmp = Expression()
2040 {
2041 argList.add(tmp);
2042 arity ++;
2043 }
Till Westmann96c1f172013-08-01 02:05:48 -07002044 (<COMMA> tmp = Expression()
Till Westmann31c21f92013-05-08 09:21:53 -07002045 {
2046 argList.add(tmp);
2047 arity++;
2048 }
2049 )*)? <RIGHTPAREN>
2050 {
ramangrover299f76a5e2013-06-18 10:25:17 -07002051 // TODO use funcName.library
ramangrover29bdba1a82013-06-21 17:17:52 -07002052 String fqFunctionName = funcName.library == null ? funcName.function : funcName.library + "#" + funcName.function;
ramangrover299f76a5e2013-06-18 10:25:17 -07002053 FunctionSignature signature
ramangrover29bdba1a82013-06-21 17:17:52 -07002054 = lookupFunctionSignature(funcName.dataverse, fqFunctionName, arity);
Till Westmann31c21f92013-05-08 09:21:53 -07002055 if (signature == null) {
ramangrover29bdba1a82013-06-21 17:17:52 -07002056 signature = new FunctionSignature(funcName.dataverse, fqFunctionName, arity);
Till Westmann31c21f92013-05-08 09:21:53 -07002057 }
2058 callExpr = new CallExpr(signature,argList);
salsubaieedf89fbc2013-12-21 19:51:42 -08002059 if (hint != null) {
2060 if (hint.startsWith(INDEXED_NESTED_LOOP_JOIN_HINT)) {
2061 callExpr.addHint(IndexedNLJoinExpressionAnnotation.INSTANCE);
2062 } else if (hint.startsWith(SKIP_SECONDARY_INDEX_SEARCH_HINT)) {
2063 callExpr.addHint(SkipSecondaryIndexSearchExpressionAnnotation.INSTANCE);
2064 }
Till Westmann31c21f92013-05-08 09:21:53 -07002065 }
2066 return callExpr;
2067 }
vinayakb38b7ca42012-03-05 05:44:15 +00002068}
2069
ramangrover29@gmail.com5f248e12013-04-11 01:03:09 +00002070
pouria.pirzadeh@gmail.comfa890742013-03-07 23:59:21 +00002071Expression DatasetAccessExpression() throws ParseException:
2072{
pouria.pirzadeh@gmail.comfa890742013-03-07 23:59:21 +00002073 String funcName;
Till Westmann14a20a72013-05-09 00:06:24 -07002074 String arg1 = null;
2075 String arg2 = null;
pouria.pirzadeh@gmail.comfa890742013-03-07 23:59:21 +00002076 Expression nameArg;
pouria.pirzadeh@gmail.comfa890742013-03-07 23:59:21 +00002077}
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002078{
Till Westmann14a20a72013-05-09 00:06:24 -07002079 <DATASET>
2080 {
Till Westmann14a20a72013-05-09 00:06:24 -07002081 funcName = token.image;
2082 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002083 ( ( arg1 = Identifier() ( <DOT> arg2 = Identifier() )? )
Till Westmann14a20a72013-05-09 00:06:24 -07002084 {
2085 String name = arg2 == null ? arg1 : arg1 + "." + arg2;
Till Westmann1f7a2362013-05-24 08:43:40 -07002086 LiteralExpr ds = new LiteralExpr();
Till Westmann14a20a72013-05-09 00:06:24 -07002087 ds.setValue( new StringLiteral(name) );
Till Westmann1f7a2362013-05-24 08:43:40 -07002088 nameArg = ds;
Abdullah Alamoudidb37f662014-07-14 21:51:37 +03002089 if(arg2 != null){
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002090 addDataverse(arg1.toString());
2091 addDataset(name);
Abdullah Alamoudidb37f662014-07-14 21:51:37 +03002092 } else {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002093 addDataset(defaultDataverse + "." + name);
Abdullah Alamoudidb37f662014-07-14 21:51:37 +03002094 }
Till Westmann14a20a72013-05-09 00:06:24 -07002095 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002096 | ( <LEFTPAREN> nameArg = Expression() <RIGHTPAREN> ) )
Till Westmann14a20a72013-05-09 00:06:24 -07002097 {
Till Westmann1f7a2362013-05-24 08:43:40 -07002098 String dataverse = MetadataConstants.METADATA_DATAVERSE_NAME;
2099 FunctionSignature signature = lookupFunctionSignature(dataverse, funcName, 1);
2100 if (signature == null) {
2101 signature = new FunctionSignature(dataverse, funcName, 1);
2102 }
2103 List<Expression> argList = new ArrayList<Expression>();
Till Westmann14a20a72013-05-09 00:06:24 -07002104 argList.add(nameArg);
Till Westmann1f7a2362013-05-24 08:43:40 -07002105 return new CallExpr(signature, argList);
Till Westmann14a20a72013-05-09 00:06:24 -07002106 }
pouria.pirzadeh@gmail.comfa890742013-03-07 23:59:21 +00002107}
RamanGrover29@gmail.com58cf3302012-11-09 00:27:45 +00002108
vinayakb38b7ca42012-03-05 05:44:15 +00002109Expression ParenthesizedExpression() throws ParseException:
2110{
2111 Expression expr;
2112}
2113{
2114 <LEFTPAREN> expr = Expression() <RIGHTPAREN>
2115 {
2116 return expr;
2117 }
2118}
2119
2120Expression IfThenElse() throws ParseException:
2121{
2122 Expression condExpr;
2123 Expression thenExpr;
2124 Expression elseExpr;
2125 IfExpr ifExpr = new IfExpr();
2126}
2127{
Till Westmann96c1f172013-08-01 02:05:48 -07002128 <IF> <LEFTPAREN> condExpr = Expression() <RIGHTPAREN> <THEN> thenExpr = Expression() <ELSE> elseExpr = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002129
2130 {
2131 ifExpr.setCondExpr(condExpr);
2132 ifExpr.setThenExpr(thenExpr);
2133 ifExpr.setElseExpr(elseExpr);
2134 return ifExpr;
2135 }
2136}
2137
2138Expression FLWOGR() throws ParseException:
2139{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002140 FLWOGRExpression flworg = new FLWOGRExpression();
2141 List<Clause> clauseList = new ArrayList<Clause>();
2142 Expression returnExpr;
2143 Clause tmp;
2144 createNewScope();
vinayakb38b7ca42012-03-05 05:44:15 +00002145}
2146{
2147 (tmp = ForClause() {clauseList.add(tmp);} | tmp = LetClause() {clauseList.add(tmp);})
buyingyi2fd7fa62014-11-24 19:31:55 -08002148 (tmp = Clause() {clauseList.add(tmp);})* (<RETURN>|<SELECT>) returnExpr = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002149
2150 {
2151 flworg.setClauseList(clauseList);
2152 flworg.setReturnExpr(returnExpr);
2153 removeCurrentScope();
2154 return flworg;
2155 }
2156}
2157
2158Clause Clause()throws ParseException :
2159{
2160 Clause clause;
2161}
2162{
2163 (
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002164 clause = ForClause()
2165 | clause = LetClause()
2166 | clause = WhereClause()
2167 | clause = OrderbyClause()
2168 | clause = GroupClause()
vinayakb38b7ca42012-03-05 05:44:15 +00002169 | clause = LimitClause()
2170 | clause = DistinctClause()
vinayakb38b7ca42012-03-05 05:44:15 +00002171 )
2172 {
2173 return clause;
2174 }
2175}
2176
2177Clause ForClause()throws ParseException :
2178{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002179 ForClause fc = new ForClause();
2180 VariableExpr varExp;
2181 VariableExpr varPos = null;
2182 Expression inExp;
2183 extendCurrentScope();
vinayakb38b7ca42012-03-05 05:44:15 +00002184}
2185{
buyingyi2fd7fa62014-11-24 19:31:55 -08002186 (<FOR>|<FROM>) varExp = Variable() (<AT> varPos = Variable())? <IN> ( inExp = Expression() )
vinayakb38b7ca42012-03-05 05:44:15 +00002187 {
2188 fc.setVarExpr(varExp);
Vinayak Borkar62e66c02013-05-28 13:56:11 -07002189 getCurrentScope().addNewVarSymbolToScope(varExp.getVar());
vinayakb38b7ca42012-03-05 05:44:15 +00002190 fc.setInExpr(inExp);
2191 if (varPos != null) {
2192 fc.setPosExpr(varPos);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002193 getCurrentScope().addNewVarSymbolToScope(varPos.getVar());
vinayakb38b7ca42012-03-05 05:44:15 +00002194 }
2195 return fc;
2196 }
2197}
2198
2199Clause LetClause() throws ParseException:
2200{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002201 LetClause lc = new LetClause();
2202 VariableExpr varExp;
2203 Expression beExp;
2204 extendCurrentScope();
vinayakb38b7ca42012-03-05 05:44:15 +00002205}
2206{
buyingyi2fd7fa62014-11-24 19:31:55 -08002207 (<LET>|<WITH>) varExp = Variable() <ASSIGN> beExp = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002208 {
2209 getCurrentScope().addNewVarSymbolToScope(varExp.getVar());
vinayakb38b7ca42012-03-05 05:44:15 +00002210 lc.setVarExpr(varExp);
2211 lc.setBeExpr(beExp);
2212 return lc;
2213 }
2214}
2215
2216Clause WhereClause()throws ParseException :
2217{
2218 WhereClause wc = new WhereClause();
2219 Expression whereExpr;
2220}
2221{
salsubaieedf89fbc2013-12-21 19:51:42 -08002222 <WHERE> whereExpr = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002223 {
2224 wc.setWhereExpr(whereExpr);
2225 return wc;
2226 }
2227}
2228
2229Clause OrderbyClause()throws ParseException :
2230{
Eldon Carmand2d78ad2015-05-07 16:23:41 -07002231 OrderbyClause oc = new OrderbyClause();
2232 Expression orderbyExpr;
2233 List<Expression> orderbyList = new ArrayList<Expression>();
2234 List<OrderbyClause.OrderModifier> modifierList = new ArrayList<OrderbyClause.OrderModifier >();
2235 int numOfOrderby = 0;
vinayakb38b7ca42012-03-05 05:44:15 +00002236}
2237{
2238 (
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002239 <ORDER>
vinayakb38b7ca42012-03-05 05:44:15 +00002240 {
Eldon Carmand2d78ad2015-05-07 16:23:41 -07002241 String hint = getHint(token);
2242 if (hint != null) {
2243 if (hint.startsWith(INMEMORY_HINT)) {
2244 String splits[] = hint.split(" +");
2245 int numFrames = Integer.parseInt(splits[1]);
2246 int numTuples = Integer.parseInt(splits[2]);
2247 oc.setNumFrames(numFrames);
2248 oc.setNumTuples(numTuples);
2249 }
2250 if (hint.startsWith(RANGE_HINT)) {
2251 oc.setRangeMap(RangeMapBuilder.parseHint(hint.substring(RANGE_HINT.length())));
2252 }
2253 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002254 }
Till Westmann96c1f172013-08-01 02:05:48 -07002255 <BY> orderbyExpr = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002256 {
2257 orderbyList.add(orderbyExpr);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002258 OrderbyClause.OrderModifier modif = OrderbyClause.OrderModifier.ASC;
vinayakb38b7ca42012-03-05 05:44:15 +00002259 }
Till Westmann96c1f172013-08-01 02:05:48 -07002260 ( (<ASC> { modif = OrderbyClause.OrderModifier.ASC; })
2261 | (<DESC> { modif = OrderbyClause.OrderModifier.DESC; }))?
vinayakb38b7ca42012-03-05 05:44:15 +00002262 {
2263 modifierList.add(modif);
2264 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002265
Till Westmann96c1f172013-08-01 02:05:48 -07002266 (<COMMA> orderbyExpr = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002267 {
2268 orderbyList.add(orderbyExpr);
2269 modif = OrderbyClause.OrderModifier.ASC;
2270 }
Till Westmann96c1f172013-08-01 02:05:48 -07002271 ( (<ASC> { modif = OrderbyClause.OrderModifier.ASC; })
2272 | (<DESC> { modif = OrderbyClause.OrderModifier.DESC; }))?
vinayakb38b7ca42012-03-05 05:44:15 +00002273 {
2274 modifierList.add(modif);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002275 }
vinayakb38b7ca42012-03-05 05:44:15 +00002276 )*
2277)
2278 {
2279 oc.setModifierList(modifierList);
2280 oc.setOrderbyList(orderbyList);
2281 return oc;
2282 }
2283}
2284Clause GroupClause()throws ParseException :
2285{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002286 GroupbyClause gbc = new GroupbyClause();
2287 // GbyVariableExpressionPair pair = new GbyVariableExpressionPair();
2288 List<GbyVariableExpressionPair> vePairList = new ArrayList<GbyVariableExpressionPair>();
vinayakb38b7ca42012-03-05 05:44:15 +00002289 List<GbyVariableExpressionPair> decorPairList = new ArrayList<GbyVariableExpressionPair>();
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002290 List<VariableExpr> withVarList= new ArrayList<VariableExpr>();
2291 VariableExpr var = null;
2292 VariableExpr withVar = null;
2293 Expression expr = null;
2294 VariableExpr decorVar = null;
2295 Expression decorExpr = null;
vinayakb38b7ca42012-03-05 05:44:15 +00002296}
2297{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002298 {
2299 Scope newScope = extendCurrentScopeNoPush(true);
2300 // extendCurrentScope(true);
2301 }
Till Westmann96c1f172013-08-01 02:05:48 -07002302 <GROUP>
vinayakb38b7ca42012-03-05 05:44:15 +00002303 {
2304 String hint = getHint(token);
2305 if (hint != null && hint.equals(HASH_GROUP_BY_HINT)) {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002306 gbc.setHashGroupByHint(true);
2307 }
2308 }
Till Westmann96c1f172013-08-01 02:05:48 -07002309 <BY> (LOOKAHEAD(2) var = Variable()
vinayakb38b7ca42012-03-05 05:44:15 +00002310 {
2311 newScope.addNewVarSymbolToScope(var.getVar());
Till Westmann96c1f172013-08-01 02:05:48 -07002312 } <ASSIGN>)?
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002313 expr = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002314 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002315 GbyVariableExpressionPair pair1 = new GbyVariableExpressionPair(var, expr);
vinayakb38b7ca42012-03-05 05:44:15 +00002316 vePairList.add(pair1);
2317 }
Till Westmann96c1f172013-08-01 02:05:48 -07002318 (<COMMA> ( LOOKAHEAD(2) var = Variable()
vinayakb38b7ca42012-03-05 05:44:15 +00002319 {
2320 newScope.addNewVarSymbolToScope(var.getVar());
Till Westmann96c1f172013-08-01 02:05:48 -07002321 } <ASSIGN>)?
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002322 expr = Expression()
2323 {
2324 GbyVariableExpressionPair pair2 = new GbyVariableExpressionPair(var, expr);
vinayakb38b7ca42012-03-05 05:44:15 +00002325 vePairList.add(pair2);
2326 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002327 )*
Till Westmann96c1f172013-08-01 02:05:48 -07002328 (<DECOR> decorVar = Variable() <ASSIGN> decorExpr = Expression()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002329 {
2330 newScope.addNewVarSymbolToScope(decorVar.getVar());
vinayakb38b7ca42012-03-05 05:44:15 +00002331 GbyVariableExpressionPair pair3 = new GbyVariableExpressionPair(decorVar, decorExpr);
2332 decorPairList.add(pair3);
2333 }
Till Westmann96c1f172013-08-01 02:05:48 -07002334 (<COMMA> <DECOR> decorVar = Variable() <ASSIGN> decorExpr = Expression()
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002335 {
2336 newScope.addNewVarSymbolToScope(decorVar.getVar());
vinayakb38b7ca42012-03-05 05:44:15 +00002337 GbyVariableExpressionPair pair4 = new GbyVariableExpressionPair(decorVar, decorExpr);
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002338 decorPairList.add(pair4);
vinayakb38b7ca42012-03-05 05:44:15 +00002339 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002340 )*
2341 )?
buyingyi3ca46d02015-01-27 23:22:09 -08002342 (<WITH>|<KEEPING>) withVar = VariableRef()
vinayakb38b7ca42012-03-05 05:44:15 +00002343 {
2344 if(withVar.getIsNewVar()==true)
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002345 throw new ParseException("can't find variable " + withVar.getVar());
vinayakb38b7ca42012-03-05 05:44:15 +00002346 withVarList.add(withVar);
2347 newScope.addNewVarSymbolToScope(withVar.getVar());
2348 }
Till Westmann96c1f172013-08-01 02:05:48 -07002349 (<COMMA> withVar = VariableRef()
vinayakb38b7ca42012-03-05 05:44:15 +00002350 {
2351 if(withVar.getIsNewVar()==true)
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002352 throw new ParseException("can't find variable " + withVar.getVar());
vinayakb38b7ca42012-03-05 05:44:15 +00002353 withVarList.add(withVar);
2354 newScope.addNewVarSymbolToScope(withVar.getVar());
2355 })*
2356 {
2357 gbc.setGbyPairList(vePairList);
2358 gbc.setDecorPairList(decorPairList);
2359 gbc.setWithVarList(withVarList);
2360 replaceCurrentScope(newScope);
2361 return gbc;
2362 }
2363}
2364
2365
2366LimitClause LimitClause() throws ParseException:
2367{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002368 LimitClause lc = new LimitClause();
2369 Expression expr;
2370 pushForbiddenScope(getCurrentScope());
vinayakb38b7ca42012-03-05 05:44:15 +00002371}
2372{
Till Westmann96c1f172013-08-01 02:05:48 -07002373 <LIMIT> expr = Expression() { lc.setLimitExpr(expr); }
2374 (<OFFSET> expr = Expression() { lc.setOffset(expr); })?
vinayakb38b7ca42012-03-05 05:44:15 +00002375
2376 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002377 popForbiddenScope();
vinayakb38b7ca42012-03-05 05:44:15 +00002378 return lc;
2379 }
2380}
2381
2382DistinctClause DistinctClause() throws ParseException:
2383{
2384 List<Expression> exprs = new ArrayList<Expression>();
2385 Expression expr;
2386}
2387{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002388 <DISTINCT> <BY> expr = Expression()
vinayakb38b7ca42012-03-05 05:44:15 +00002389 {
2390 exprs.add(expr);
2391 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002392 (<COMMA> expr = Expression()
2393 {
2394 exprs.add(expr);
2395 }
vinayakb38b7ca42012-03-05 05:44:15 +00002396 )*
2397 {
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002398 return new DistinctClause(exprs);
vinayakb38b7ca42012-03-05 05:44:15 +00002399 }
2400}
2401
vinayakb38b7ca42012-03-05 05:44:15 +00002402QuantifiedExpression QuantifiedExpression()throws ParseException:
2403{
2404 QuantifiedExpression qc = new QuantifiedExpression();
2405 List<QuantifiedPair> quantifiedList = new ArrayList<QuantifiedPair>();
2406 Expression satisfiesExpr;
2407 VariableExpr var;
2408 Expression inExpr;
2409 QuantifiedPair pair;
2410}
2411{
2412 {
2413 createNewScope();
2414 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002415
Till Westmann96c1f172013-08-01 02:05:48 -07002416 ( (<SOME> { qc.setQuantifier(QuantifiedExpression.Quantifier.SOME); })
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002417 | (<EVERY> { qc.setQuantifier(QuantifiedExpression.Quantifier.EVERY); }))
2418 var = Variable() <IN> inExpr = Expression()
2419 {
vinayakb38b7ca42012-03-05 05:44:15 +00002420 pair = new QuantifiedPair(var, inExpr);
2421 getCurrentScope().addNewVarSymbolToScope(var.getVar());
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002422 quantifiedList.add(pair);
2423 }
2424 (
2425 <COMMA> var = Variable() <IN> inExpr = Expression()
2426 {
2427 pair = new QuantifiedPair(var, inExpr);
2428 getCurrentScope().addNewVarSymbolToScope(var.getVar());
2429 quantifiedList.add(pair);
2430 }
2431 )*
2432 <SATISFIES> satisfiesExpr = Expression()
2433 {
2434 qc.setSatisfiesExpr(satisfiesExpr);
2435 qc.setQuantifiedList(quantifiedList);
2436 removeCurrentScope();
2437 return qc;
2438 }
vinayakb38b7ca42012-03-05 05:44:15 +00002439}
2440
2441TOKEN_MGR_DECLS:
2442{
Till Westmann96c1f172013-08-01 02:05:48 -07002443 public int commentDepth = 0;
2444 public IntStack lexerStateStack = new IntStack();
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002445
Till Westmann96c1f172013-08-01 02:05:48 -07002446 public void pushState() {
2447 lexerStateStack.push( curLexState );
2448 }
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002449
Till Westmannfd733ee2014-07-10 00:57:37 -07002450 public void popState(String token) {
Till Westmann96c1f172013-08-01 02:05:48 -07002451 if (lexerStateStack.size() > 0) {
2452 SwitchTo( lexerStateStack.pop() );
2453 } else {
Till Westmannfd733ee2014-07-10 00:57:37 -07002454 int errorLine = input_stream.getEndLine();
2455 int errorColumn = input_stream.getEndColumn();
2456 String msg = "Lexical error at line " + errorLine + ", column " + errorColumn + ". Encountered \"" + token
2457 + "\" but state stack is empty.";
2458 throw new TokenMgrError(msg, -1);
Till Westmann96c1f172013-08-01 02:05:48 -07002459 }
2460 }
vinayakb38b7ca42012-03-05 05:44:15 +00002461}
2462
Till Westmann96c1f172013-08-01 02:05:48 -07002463<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002464TOKEN :
2465{
Till Westmann5df7b452013-08-02 13:07:16 -07002466 <ASC : "asc">
2467 | <AT : "at">
2468 | <BY : "by">
2469 | <DATASET : "dataset">
2470 | <DECOR : "decor">
2471 | <DESC : "desc">
2472 | <DISTINCT : "distinct">
2473 | <ELSE : "else">
2474 | <EVERY : "every">
2475 | <FOR : "for">
buyingyi2fd7fa62014-11-24 19:31:55 -08002476 | <FROM : "from">
Till Westmann5df7b452013-08-02 13:07:16 -07002477 | <GROUP : "group">
2478 | <IF : "if">
2479 | <IN : "in">
2480 | <LET : "let">
2481 | <LIMIT : "limit">
2482 | <OFFSET : "offset">
2483 | <ORDER : "order">
2484 | <RETURN : "return">
2485 | <SATISFIES : "satisfies">
buyingyi2fd7fa62014-11-24 19:31:55 -08002486 | <SELECT : "select">
Till Westmann5df7b452013-08-02 13:07:16 -07002487 | <SOME : "some">
2488 | <THEN : "then">
2489 | <UNION : "union">
2490 | <WHERE : "where">
2491 | <WITH : "with">
buyingyi3ca46d02015-01-27 23:22:09 -08002492 | <KEEPING : "keeping">
vinayakb38b7ca42012-03-05 05:44:15 +00002493}
2494
Till Westmann96c1f172013-08-01 02:05:48 -07002495<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002496TOKEN :
2497{
Till Westmann5df7b452013-08-02 13:07:16 -07002498 <CARET : "^">
2499 | <DIV : "/">
2500 | <IDIV : "idiv">
2501 | <MINUS : "-">
2502 | <MOD : "%">
2503 | <MUL : "*">
2504 | <PLUS : "+">
2505
2506 | <LEFTPAREN : "(">
2507 | <RIGHTPAREN : ")">
2508 | <LEFTBRACKET : "[">
2509 | <RIGHTBRACKET : "]">
2510
2511 | <COLON : ":">
2512 | <COMMA : ",">
2513 | <DOT : ".">
2514 | <QUES : "?">
2515
2516 | <LT : "<">
2517 | <GT : ">">
2518 | <LE : "<=">
2519 | <GE : ">=">
2520 | <EQ : "=">
2521 | <NE : "!=">
2522 | <SIMILAR : "~=">
2523 | <ASSIGN : ":=">
2524
2525 | <AND : "and">
2526 | <OR : "or">
vinayakb38b7ca42012-03-05 05:44:15 +00002527}
2528
Till Westmann96c1f172013-08-01 02:05:48 -07002529<DEFAULT,IN_DBL_BRACE>
2530TOKEN :
2531{
Till Westmann5df7b452013-08-02 13:07:16 -07002532 <LEFTBRACE : "{"> { pushState(); } : DEFAULT
vinayakb38b7ca42012-03-05 05:44:15 +00002533}
2534
2535<DEFAULT>
2536TOKEN :
2537{
Till Westmannfd733ee2014-07-10 00:57:37 -07002538 <RIGHTBRACE : "}"> { popState("}"); }
vinayakb38b7ca42012-03-05 05:44:15 +00002539}
2540
Till Westmann96c1f172013-08-01 02:05:48 -07002541<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002542TOKEN :
2543{
Till Westmann5df7b452013-08-02 13:07:16 -07002544 <LEFTDBLBRACE : "{{"> { pushState(); } : IN_DBL_BRACE
vinayakb38b7ca42012-03-05 05:44:15 +00002545}
2546
Till Westmann96c1f172013-08-01 02:05:48 -07002547<IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002548TOKEN :
2549{
Till Westmannfd733ee2014-07-10 00:57:37 -07002550 <RIGHTDBLBRACE : "}}"> { popState("}}"); }
vinayakb38b7ca42012-03-05 05:44:15 +00002551}
2552
Till Westmann96c1f172013-08-01 02:05:48 -07002553<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002554TOKEN :
2555{
Till Westmann5df7b452013-08-02 13:07:16 -07002556 <INTEGER_LITERAL : (<DIGIT>)+ >
vinayakb38b7ca42012-03-05 05:44:15 +00002557}
2558
Till Westmann96c1f172013-08-01 02:05:48 -07002559<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002560TOKEN :
2561{
Till Westmann5df7b452013-08-02 13:07:16 -07002562 <NULL : "null">
2563 | <TRUE : "true">
2564 | <FALSE : "false">
vinayakb38b7ca42012-03-05 05:44:15 +00002565}
2566
Till Westmann96c1f172013-08-01 02:05:48 -07002567<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002568TOKEN :
2569{
Till Westmann5df7b452013-08-02 13:07:16 -07002570 <#DIGIT : ["0" - "9"]>
vinayakb38b7ca42012-03-05 05:44:15 +00002571}
2572
Till Westmann96c1f172013-08-01 02:05:48 -07002573<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002574TOKEN:
2575{
Till Westmann5df7b452013-08-02 13:07:16 -07002576 < DOUBLE_LITERAL: <DIGITS>
Till Westmannaf0551c2013-07-23 14:53:31 -07002577 | <DIGITS> ( "." <DIGITS> )?
2578 | "." <DIGITS>
Till Westmann5df7b452013-08-02 13:07:16 -07002579 >
2580 | < FLOAT_LITERAL: <DIGITS> ( "f" | "F" )
Till Westmannaf0551c2013-07-23 14:53:31 -07002581 | <DIGITS> ( "." <DIGITS> ( "f" | "F" ) )?
2582 | "." <DIGITS> ( "f" | "F" )
Till Westmann5df7b452013-08-02 13:07:16 -07002583 >
2584 | <DIGITS : (<DIGIT>)+ >
vinayakb38b7ca42012-03-05 05:44:15 +00002585}
2586
Till Westmann96c1f172013-08-01 02:05:48 -07002587<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002588TOKEN :
2589{
Till Westmann5df7b452013-08-02 13:07:16 -07002590 <#LETTER : ["A" - "Z", "a" - "z"]>
2591 | <SPECIALCHARS : ["$", "_", "-"]>
vinayakb38b7ca42012-03-05 05:44:15 +00002592}
2593
Till Westmann96c1f172013-08-01 02:05:48 -07002594<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002595TOKEN :
2596{
Till Westmanne3e8ffa2014-08-02 17:51:23 -07002597 // backslash u + 4 hex digits escapes are handled in the underlying JavaCharStream
2598 <STRING_LITERAL : ("\"" (
2599 <EscapeQuot>
2600 | <EscapeBslash>
2601 | <EscapeSlash>
2602 | <EscapeBspace>
2603 | <EscapeFormf>
2604 | <EscapeNl>
2605 | <EscapeCr>
2606 | <EscapeTab>
2607 | ~["\"","\\"])* "\"")
2608 | ("\'"(
2609 <EscapeApos>
2610 | <EscapeBslash>
2611 | <EscapeSlash>
2612 | <EscapeBspace>
2613 | <EscapeFormf>
2614 | <EscapeNl>
2615 | <EscapeCr>
2616 | <EscapeTab>
2617 | ~["\'","\\"])* "\'")>
Till Westmann5df7b452013-08-02 13:07:16 -07002618 | < #EscapeQuot: "\\\"" >
2619 | < #EscapeApos: "\\\'" >
Till Westmanne0cc01c2014-03-31 10:26:10 -07002620 | < #EscapeBslash: "\\\\" >
Till Westmanne3e8ffa2014-08-02 17:51:23 -07002621 | < #EscapeSlash: "\\/" >
2622 | < #EscapeBspace: "\\b" >
2623 | < #EscapeFormf: "\\f" >
2624 | < #EscapeNl: "\\n" >
2625 | < #EscapeCr: "\\r" >
2626 | < #EscapeTab: "\\t" >
vinayakb38b7ca42012-03-05 05:44:15 +00002627}
2628
Till Westmann96c1f172013-08-01 02:05:48 -07002629<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002630TOKEN :
2631{
Till Westmann5df7b452013-08-02 13:07:16 -07002632 <IDENTIFIER : <LETTER> (<LETTER> | <DIGIT> | <SPECIALCHARS>)*>
vinayakb38b7ca42012-03-05 05:44:15 +00002633}
2634
Till Westmann96c1f172013-08-01 02:05:48 -07002635<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002636TOKEN :
2637{
Till Westmann5df7b452013-08-02 13:07:16 -07002638 <VARIABLE : "$" <LETTER> (<LETTER> | <DIGIT> | "_")*>
vinayakb38b7ca42012-03-05 05:44:15 +00002639}
2640
Till Westmann96c1f172013-08-01 02:05:48 -07002641<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002642SKIP:
2643{
2644 " "
Till Westmann5df7b452013-08-02 13:07:16 -07002645 | "\t"
2646 | "\r"
2647 | "\n"
vinayakb38b7ca42012-03-05 05:44:15 +00002648}
2649
Till Westmann96c1f172013-08-01 02:05:48 -07002650<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002651SKIP:
2652{
Till Westmann5df7b452013-08-02 13:07:16 -07002653 <"//" (~["\n"])* "\n">
vinayakb38b7ca42012-03-05 05:44:15 +00002654}
2655
Till Westmann96c1f172013-08-01 02:05:48 -07002656<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002657SKIP:
2658{
Taewoo Kima12d8cd2015-03-04 13:47:08 -08002659 <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")?>
vinayakb38b7ca42012-03-05 05:44:15 +00002660}
2661
Till Westmann96c1f172013-08-01 02:05:48 -07002662<DEFAULT,IN_DBL_BRACE>
vinayakb38b7ca42012-03-05 05:44:15 +00002663SKIP:
2664{
Till Westmann96c1f172013-08-01 02:05:48 -07002665 <"/*"> { pushState(); } : INSIDE_COMMENT
vinayakb38b7ca42012-03-05 05:44:15 +00002666}
2667
2668<INSIDE_COMMENT>
2669SPECIAL_TOKEN:
2670{
Till Westmann5df7b452013-08-02 13:07:16 -07002671 <"+"(" ")*(~["*"])*>
vinayakb38b7ca42012-03-05 05:44:15 +00002672}
2673
2674<INSIDE_COMMENT>
2675SKIP:
2676{
Till Westmann96c1f172013-08-01 02:05:48 -07002677 <"/*"> { pushState(); }
vinayakb38b7ca42012-03-05 05:44:15 +00002678}
2679
2680<INSIDE_COMMENT>
2681SKIP:
2682{
Till Westmannfd733ee2014-07-10 00:57:37 -07002683 <"*/"> { popState("*/"); }
Till Westmann5df7b452013-08-02 13:07:16 -07002684 | <~[]>
vinayakb38b7ca42012-03-05 05:44:15 +00002685}