Till Westmann | 5b431ca | 2015-10-01 19:16:11 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 20 | options { |
| 21 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 22 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 23 | STATIC = false; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 24 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | |
| 28 | PARSER_BEGIN(AQLPlusParser) |
| 29 | |
Ian Maxon | f18bba2 | 2015-08-21 12:35:14 -0700 | [diff] [blame] | 30 | package org.apache.asterix.aqlplus.parser; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 31 | |
| 32 | import java.io.*; |
| 33 | import java.util.List; |
| 34 | import java.util.ArrayList; |
| 35 | import java.util.Stack; |
| 36 | import java.util.Map; |
| 37 | import java.util.HashMap; |
| 38 | |
Ian Maxon | f18bba2 | 2015-08-21 12:35:14 -0700 | [diff] [blame] | 39 | import org.apache.asterix.aql.literal.FloatLiteral; |
| 40 | import org.apache.asterix.aql.literal.DoubleLiteral; |
| 41 | import org.apache.asterix.aql.literal.FalseLiteral; |
| 42 | import org.apache.asterix.aql.base.Literal; |
| 43 | import org.apache.asterix.aql.literal.IntegerLiteral; |
| 44 | import org.apache.asterix.aql.literal.LongIntegerLiteral; |
| 45 | import org.apache.asterix.aql.literal.NullLiteral; |
| 46 | import org.apache.asterix.aql.literal.StringLiteral; |
| 47 | import org.apache.asterix.aql.literal.TrueLiteral; |
| 48 | import org.apache.asterix.aql.parser.ScopeChecker; |
| 49 | import org.apache.asterix.aql.base.*; |
| 50 | import org.apache.asterix.aql.expression.*; |
| 51 | import org.apache.asterix.aql.expression.visitor.AQLPrintVisitor; |
| 52 | import org.apache.asterix.aql.expression.UnaryExpr.Sign; |
| 53 | import org.apache.asterix.aql.expression.TypeExpression.TypeExprKind; |
| 54 | import org.apache.asterix.aql.base.Statement.Kind; |
| 55 | import org.apache.asterix.aql.context.Scope; |
| 56 | import org.apache.asterix.aql.context.RootScopeFactory; |
| 57 | import org.apache.asterix.common.exceptions.AsterixException; |
| 58 | import org.apache.asterix.om.functions.AsterixFunction; |
| 59 | import org.apache.asterix.common.functions.FunctionSignature; |
| 60 | import org.apache.asterix.metadata.bootstrap.MetadataConstants; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 61 | |
Ian Maxon | f18bba2 | 2015-08-21 12:35:14 -0700 | [diff] [blame] | 62 | import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation; |
| 63 | import org.apache.hyracks.algebricks.core.algebra.expressions.IndexedNLJoinExpressionAnnotation; |
| 64 | import org.apache.hyracks.algebricks.common.utils.Pair; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 65 | |
| 66 | |
ramangrover29 | a13f242 | 2012-03-15 23:01:27 +0000 | [diff] [blame] | 67 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 68 | public class AQLPlusParser extends ScopeChecker { |
| 69 | |
| 70 | /* |
| 71 | private void printHints(Token t) { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 72 | //System.err.println("token="+t.image+"\t special="+t.specialToken); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 73 | if (t.specialToken == null) return; |
| 74 | Token tmp_t = t.specialToken; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 75 | while (tmp_t.specialToken != null) tmp_t = tmp_t.specialToken; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 76 | while (tmp_t != null) { |
| 77 | System.out.println(tmp_t.image); |
| 78 | tmp_t = tmp_t.next; |
| 79 | } |
| 80 | } |
| 81 | */ |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 82 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 83 | private static final String HASH_GROUP_BY_HINT = "hash"; |
| 84 | private static final String BROADCAST_JOIN_HINT = "bcast"; |
| 85 | private static final String INMEMORY_HINT = "inmem"; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 86 | private static final String INDEXED_NESTED_LOOP_JOIN_HINT = "indexnl"; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 87 | |
| 88 | |
| 89 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 90 | private static String getHint(Token t) { |
| 91 | if (t.specialToken == null) { |
| 92 | return null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 93 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 94 | String s = t.specialToken.image; |
| 95 | int n = s.length(); |
| 96 | if (n < 2) { |
| 97 | return null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 98 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 99 | return s.substring(1).trim(); |
| 100 | } |
| 101 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 102 | public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException, AsterixException { |
| 103 | File file = new File(args[0]); |
| 104 | Reader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); |
| 105 | AQLPlusParser parser = new AQLPlusParser(fis); |
| 106 | List<Statement> st = parser.Statement(); |
| 107 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 108 | |
| 109 | public void initScope() { |
| 110 | scopeStack.push(RootScopeFactory.createRootScope(this)); |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | PARSER_END(AQLPlusParser) |
| 115 | |
| 116 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 117 | List<Statement> Statement() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 118 | { |
| 119 | Query query = null; |
| 120 | // scopeStack.push(RootScopeFactory.createRootScope(this)); |
| 121 | initScope(); |
| 122 | List<Statement> decls = new ArrayList<Statement>(); |
| 123 | } |
| 124 | { |
| 125 | ( |
| 126 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 127 | ( |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 128 | "use" |
| 129 | { |
| 130 | decls.add(DataverseDeclaration()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 131 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 132 | | "declare" |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 133 | ( "function" { |
| 134 | decls.add(FunctionDeclaration()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 135 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 136 | | "type" { |
| 137 | decls.add(TypeDeclaration()); |
| 138 | } |
| 139 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 140 | | "load" { |
| 141 | decls.add(LoadStatement()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 142 | } |
| 143 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 144 | | "write" { |
| 145 | decls.add(WriteStatement()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 146 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 147 | | "set" { |
| 148 | decls.add(SetStatement()); |
| 149 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 150 | | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 151 | { |
| 152 | decls.add(Query()) ; |
| 153 | } ";" |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 154 | |
| 155 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 156 | )* |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 157 | ) |
| 158 | |
| 159 | <EOF> |
| 160 | ) |
| 161 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 162 | |
| 163 | return decls; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
| 167 | Statement SetStatement() throws ParseException: |
| 168 | { |
| 169 | String pn = null; |
| 170 | Statement stmt = null; |
| 171 | } |
| 172 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 173 | <IDENTIFIER> { pn = token.image; } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 174 | <STRING_LITERAL> |
| 175 | { String pv = removeQuotesAndEscapes(token.image); } |
| 176 | ";" |
| 177 | { |
| 178 | return new SetStatement(pn, pv); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | Statement WriteStatement() throws ParseException: |
| 183 | { |
| 184 | Identifier nodeName = null; |
| 185 | String fileName = null; |
| 186 | Identifier datasetName = null; |
| 187 | Statement stmt = null; |
| 188 | Query query; |
| 189 | } |
| 190 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 191 | ( "output" "to" |
| 192 | <IDENTIFIER> { nodeName = new Identifier(token.image); } |
| 193 | ":" <STRING_LITERAL> { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 194 | fileName = removeQuotesAndEscapes(token.image); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 195 | stmt = new WriteStatement(nodeName, fileName, null); |
Till Westmann | 35a0f70 | 2013-07-01 14:06:34 -0700 | [diff] [blame] | 196 | } |
| 197 | ) ";" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 198 | { |
| 199 | return stmt; |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | DataverseDecl DataverseDeclaration() throws ParseException: |
| 204 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 205 | Identifier dvName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 206 | } |
| 207 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 208 | "dataverse" <IDENTIFIER> { defaultDataverse = token.image;} |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 209 | ";" |
| 210 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 211 | return new DataverseDecl(new Identifier(defaultDataverse)); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | |
zheilbron | 28e026f | 2013-11-20 10:15:15 -0800 | [diff] [blame] | 215 | LoadStatement LoadStatement() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 216 | { |
| 217 | Identifier datasetName = null; |
| 218 | boolean alreadySorted = false; |
| 219 | String adapter; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 220 | Map<String,String> properties = new HashMap<String,String>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 221 | String name; |
| 222 | String value; |
| 223 | } |
| 224 | { |
| 225 | <DATASET> <IDENTIFIER> { datasetName = new Identifier(token.image); } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 226 | |
| 227 | "using" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 228 | ( |
| 229 | <STRING_LITERAL> |
| 230 | { |
| 231 | adapter = removeQuotesAndEscapes(token.image); |
| 232 | } |
| 233 | <LEFTPAREN> |
| 234 | ( |
| 235 | ( |
| 236 | <LEFTPAREN> |
| 237 | ( |
| 238 | <STRING_LITERAL> |
| 239 | { |
| 240 | name = removeQuotesAndEscapes(token.image); |
| 241 | } |
| 242 | "=" <STRING_LITERAL> |
| 243 | { |
| 244 | value = removeQuotesAndEscapes(token.image); |
| 245 | } |
| 246 | ) |
| 247 | <RIGHTPAREN> |
| 248 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 249 | properties.put(name, value); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 250 | } |
| 251 | ) |
| 252 | ( |
| 253 | "," <LEFTPAREN> |
| 254 | ( |
| 255 | <STRING_LITERAL> |
| 256 | { |
| 257 | name = removeQuotesAndEscapes(token.image); |
| 258 | } |
| 259 | "=" <STRING_LITERAL> |
| 260 | { |
| 261 | value = removeQuotesAndEscapes(token.image); |
| 262 | } |
| 263 | ) |
| 264 | <RIGHTPAREN> |
| 265 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 266 | properties.put(name, value); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 267 | } |
| 268 | )* |
| 269 | )? |
| 270 | <RIGHTPAREN> |
| 271 | ) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 272 | |
| 273 | ("pre-sorted" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 274 | { alreadySorted = true; } |
| 275 | )? |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 276 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 277 | ";" |
| 278 | { |
zheilbron | 28e026f | 2013-11-20 10:15:15 -0800 | [diff] [blame] | 279 | return new LoadStatement(null, datasetName, adapter, properties, alreadySorted); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 280 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | TypeDecl TypeDeclaration() throws ParseException: |
| 284 | { |
| 285 | Identifier ident; |
| 286 | TypeExpression typeExpr; |
| 287 | } |
| 288 | { |
| 289 | <IDENTIFIER> |
| 290 | { |
| 291 | ident = new Identifier(token.image.toString()); |
| 292 | } |
| 293 | "as" |
| 294 | ( typeExpr = TypeExpr() ) |
| 295 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 296 | return new TypeDecl(null, ident, typeExpr); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 297 | } |
| 298 | } |
| 299 | |
| 300 | TypeExpression TypeExpr() throws ParseException: |
| 301 | { |
| 302 | TypeExpression typeExpr = null; |
| 303 | } |
| 304 | { |
| 305 | ( |
| 306 | typeExpr = RecordTypeDef() |
| 307 | | typeExpr = TypeReference() |
| 308 | | typeExpr = OrderedListTypeDef() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 309 | | typeExpr = UnorderedListTypeDef() |
| 310 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 311 | { |
| 312 | return typeExpr; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | RecordTypeDefinition RecordTypeDef() throws ParseException: |
| 317 | { |
| 318 | RecordTypeDefinition recType = new RecordTypeDefinition(); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 319 | RecordTypeDefinition.RecordKind recordKind = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 320 | } |
| 321 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 322 | ( "closed" { recordKind = RecordTypeDefinition.RecordKind.CLOSED; } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 323 | | "open" { recordKind = RecordTypeDefinition.RecordKind.OPEN; } )? |
| 324 | "{" |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 325 | ( |
| 326 | RecordField(recType) |
| 327 | ( "," RecordField(recType) )* |
| 328 | )? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 329 | "}" |
| 330 | { |
| 331 | if (recordKind == null) { |
| 332 | recordKind = RecordTypeDefinition.RecordKind.OPEN; |
| 333 | } |
| 334 | recType.setRecordKind(recordKind); |
| 335 | return recType; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 336 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | void RecordField(RecordTypeDefinition recType) throws ParseException: |
| 340 | { |
| 341 | String fieldName; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 342 | TypeExpression type = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 343 | boolean nullable = false; |
| 344 | } |
| 345 | { |
| 346 | <IDENTIFIER> |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 347 | { |
| 348 | Token t = getToken(0); |
| 349 | fieldName = t.toString(); |
| 350 | } |
| 351 | ":" |
| 352 | ( type = TypeExpr() ) |
| 353 | ("?" { nullable = true; } )? |
| 354 | { |
| 355 | |
| 356 | recType.addField(fieldName, type, nullable); |
| 357 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | TypeReferenceExpression TypeReference() throws ParseException: |
| 361 | {} |
| 362 | { |
| 363 | <IDENTIFIER> |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 364 | { |
| 365 | Token t = getToken(0); |
| 366 | Identifier id; |
| 367 | if (t.toString().equalsIgnoreCase("int")) { |
| 368 | id = new Identifier("int64"); |
| 369 | } else { |
| 370 | id = new Identifier(t.toString()); |
| 371 | } |
| 372 | return new TypeReferenceExpression(id); |
| 373 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | OrderedListTypeDefinition OrderedListTypeDef() throws ParseException: |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 377 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 378 | TypeExpression type = null; |
| 379 | } |
| 380 | { |
| 381 | "[" |
| 382 | ( type = TypeExpr() ) |
| 383 | "]" |
| 384 | { |
| 385 | return new OrderedListTypeDefinition(type); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | |
| 390 | UnorderedListTypeDefinition UnorderedListTypeDef() throws ParseException: |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 391 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 392 | TypeExpression type = null; |
| 393 | } |
| 394 | { |
| 395 | "<" |
| 396 | ( type = TypeExpr() ) |
| 397 | ">" |
| 398 | { |
| 399 | return new UnorderedListTypeDefinition(type); |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | |
| 404 | FunctionDecl FunctionDeclaration() throws ParseException: |
| 405 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 406 | FunctionDecl funcDecl; |
| 407 | FunctionSignature signature; |
ramangrover29 | a13f242 | 2012-03-15 23:01:27 +0000 | [diff] [blame] | 408 | String functionName; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 409 | int arity = 0; |
| 410 | List<VarIdentifier> paramList = new ArrayList<VarIdentifier>(); |
| 411 | Expression funcBody; |
| 412 | VarIdentifier var = null; |
| 413 | createNewScope(); |
| 414 | } |
| 415 | { |
| 416 | |
| 417 | <IDENTIFIER> |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 418 | { |
| 419 | Token t = getToken(0); |
| 420 | functionName = t.toString(); |
| 421 | if (functionName.equalsIgnoreCase("int")) { |
| 422 | functionName = "int64"; |
| 423 | } |
| 424 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 425 | <LEFTPAREN> (<VARIABLE> |
| 426 | { |
| 427 | var = new VarIdentifier(); |
| 428 | var.setValue(getToken(0).toString()); |
| 429 | paramList.add(var); |
| 430 | getCurrentScope().addNewVarSymbolToScope(var); |
| 431 | arity++; |
| 432 | } |
| 433 | ("," <VARIABLE> |
| 434 | { |
| 435 | var = new VarIdentifier(); |
| 436 | var.setValue(getToken(0).toString()); |
| 437 | paramList.add(var); |
| 438 | getCurrentScope().addNewVarSymbolToScope(var); |
| 439 | arity++; |
| 440 | })*)? <RIGHTPAREN> "{" funcBody = Expression() "}" |
| 441 | |
| 442 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 443 | signature = new FunctionSignature(defaultDataverse, functionName, arity); |
| 444 | getCurrentScope().addFunctionDescriptor(signature, false); |
| 445 | funcDecl = new FunctionDecl(signature, paramList, funcBody); |
| 446 | return funcDecl; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 447 | } |
| 448 | } |
| 449 | |
| 450 | Query Query()throws ParseException: |
| 451 | { |
| 452 | Query query = new Query(); |
| 453 | Expression expr; |
| 454 | } |
| 455 | { |
| 456 | expr = Expression() |
| 457 | |
| 458 | { |
| 459 | query.setBody(expr); |
| 460 | return query; |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | |
| 465 | |
| 466 | Expression Expression(): |
| 467 | { |
| 468 | Expression expr = null; |
| 469 | Expression exprP = null; |
| 470 | } |
| 471 | { |
| 472 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 473 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 474 | //OperatorExpr | IfThenElse | FLWOGRExpression | QuantifiedExpression |
| 475 | expr = OperatorExpr() |
| 476 | | expr = IfThenElse() |
| 477 | | expr = FLWOGR() |
| 478 | | expr = QuantifiedExpression() |
| 479 | |
| 480 | |
| 481 | ) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 482 | { |
| 483 | return (exprP==null) ? expr : exprP; |
| 484 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | |
| 488 | |
| 489 | Expression OperatorExpr()throws ParseException: |
| 490 | { |
| 491 | OperatorExpr op = null; |
| 492 | Expression operand = null; |
| 493 | } |
| 494 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 495 | operand = AndExpr() |
| 496 | ( |
| 497 | |
| 498 | "or" |
| 499 | { |
| 500 | if (op == null) { |
| 501 | op = new OperatorExpr(); |
| 502 | op.addOperand(operand); |
| 503 | op.setCurrentop(true); |
| 504 | } |
| 505 | Token t = getToken(0); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 506 | op.addOperator(t.toString()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 507 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 508 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 509 | operand = AndExpr() |
| 510 | { |
| 511 | op.addOperand(operand); |
| 512 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 513 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 514 | )* |
| 515 | |
| 516 | { |
| 517 | return op==null? operand: op; |
| 518 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 519 | } |
| 520 | |
| 521 | Expression AndExpr()throws ParseException: |
| 522 | { |
| 523 | OperatorExpr op = null; |
| 524 | Expression operand = null; |
| 525 | } |
| 526 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 527 | operand = RelExpr() |
| 528 | ( |
| 529 | |
| 530 | "and" |
| 531 | { |
| 532 | if (op == null) { |
| 533 | op = new OperatorExpr(); |
| 534 | op.addOperand(operand); |
| 535 | op.setCurrentop(true); |
| 536 | } |
| 537 | Token t = getToken(0); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 538 | op.addOperator(t.toString()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 539 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 540 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 541 | operand = RelExpr() |
| 542 | { |
| 543 | op.addOperand(operand); |
| 544 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 545 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 546 | )* |
| 547 | |
| 548 | { |
| 549 | return op==null? operand: op; |
| 550 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | |
| 554 | |
| 555 | Expression RelExpr()throws ParseException: |
| 556 | { |
| 557 | OperatorExpr op = null; |
| 558 | Expression operand = null; |
| 559 | boolean broadcast = false; |
| 560 | } |
| 561 | { |
| 562 | operand = AddExpr() |
| 563 | { |
| 564 | if (operand instanceof VariableExpr) { |
| 565 | String hint = getHint(token); |
| 566 | if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 567 | broadcast = true; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 568 | } |
| 569 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 570 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 571 | |
| 572 | ( |
| 573 | LOOKAHEAD(2)( "<" | ">" | "<=" | ">=" | "=" | "!=" |"~=") |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 574 | { |
| 575 | if (op == null) { |
| 576 | op = new OperatorExpr(); |
| 577 | op.addOperand(operand, broadcast); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 578 | op.setCurrentop(true); |
| 579 | broadcast = false; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 580 | } |
| 581 | Token t = getToken(0); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 582 | op.addOperator(t.toString()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | operand = AddExpr() |
| 586 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 587 | broadcast = false; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 588 | if (operand instanceof VariableExpr) { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 589 | String hint = getHint(token); |
| 590 | if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) { |
| 591 | broadcast = true; |
| 592 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 593 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 594 | op.addOperand(operand, broadcast); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 595 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 596 | )? |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 597 | |
| 598 | { |
| 599 | return op==null? operand: op; |
| 600 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | Expression AddExpr()throws ParseException: |
| 604 | { |
| 605 | OperatorExpr op = null; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 606 | Expression operand = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 607 | } |
| 608 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 609 | operand = MultExpr() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 610 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 611 | ( ("+" | "-") |
| 612 | { |
| 613 | if (op == null) { |
| 614 | op = new OperatorExpr(); |
| 615 | op.addOperand(operand); |
| 616 | op.setCurrentop(true); |
| 617 | } |
| 618 | Token t = getToken(0); |
| 619 | ((OperatorExpr)op).addOperator(t.toString()); |
| 620 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 621 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 622 | operand = MultExpr() |
| 623 | { |
| 624 | op.addOperand(operand); |
| 625 | } |
| 626 | )* |
| 627 | |
| 628 | { |
| 629 | return op==null? operand: op; |
| 630 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 631 | } |
| 632 | |
| 633 | Expression MultExpr()throws ParseException: |
| 634 | { |
| 635 | OperatorExpr op = null; |
| 636 | Expression operand = null; |
| 637 | } |
| 638 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 639 | operand = UnionExpr() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 640 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 641 | (( "*" | "/" | "%" | <CARET> | "idiv") |
| 642 | { |
| 643 | if (op == null) { |
| 644 | op = new OperatorExpr(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 645 | op.addOperand(operand); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 646 | op.setCurrentop(true); |
| 647 | } |
| 648 | Token t = getToken(0); |
| 649 | op.addOperator(t.toString()); |
| 650 | } |
| 651 | operand = UnionExpr() |
| 652 | { |
| 653 | op.addOperand(operand); |
| 654 | } |
| 655 | )* |
| 656 | |
| 657 | { |
| 658 | return op==null?operand:op; |
| 659 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | Expression UnionExpr() throws ParseException: |
| 663 | { |
| 664 | UnionExpr union = null; |
| 665 | Expression operand1 = null; |
| 666 | Expression operand2 = null; |
| 667 | } |
| 668 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 669 | operand1 = UnaryExpr() |
| 670 | ("union" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 671 | (operand2 = UnaryExpr()) { |
| 672 | if (union == null) { |
| 673 | union = new UnionExpr(); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 674 | union.addExpr(operand1); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 675 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 676 | union.addExpr(operand2); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 677 | } )* |
| 678 | { |
| 679 | return (union == null)? operand1: union; |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | Expression UnaryExpr() throws ParseException: |
| 684 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 685 | Expression uexpr = null; |
| 686 | Expression expr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 687 | } |
| 688 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 689 | (( "+"|"-") |
| 690 | { |
| 691 | uexpr = new UnaryExpr(); |
| 692 | Token t = getToken(0); |
| 693 | if("+".equals(t.toString())) |
| 694 | ((UnaryExpr)uexpr).setSign(Sign.POSITIVE); |
| 695 | else if("-".equals(t.toString())) |
| 696 | ((UnaryExpr)uexpr).setSign(Sign.NEGATIVE); |
| 697 | else |
| 698 | throw new ParseException(); |
| 699 | } |
| 700 | )? |
| 701 | |
| 702 | expr = ValueExpr() |
| 703 | { |
| 704 | if(uexpr!=null){ |
| 705 | ((UnaryExpr)uexpr).setExpr(expr); |
| 706 | return uexpr; |
| 707 | } |
| 708 | else{ |
| 709 | return expr; |
| 710 | } |
| 711 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 712 | } |
| 713 | |
| 714 | Expression ValueExpr() throws ParseException: |
| 715 | { |
| 716 | Expression expr; |
| 717 | } |
| 718 | { |
| 719 | expr = FieldOrIndexAccessor() |
| 720 | { |
| 721 | return expr; |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | |
| 726 | Expression FieldOrIndexAccessor()throws ParseException: |
| 727 | { |
| 728 | Expression expr = null; |
| 729 | Identifier ident = null; |
| 730 | AbstractAccessor fa = null; |
icetindil | a611ac7 | 2014-05-16 10:10:11 -0700 | [diff] [blame] | 731 | Expression indexExpr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 732 | |
| 733 | } |
| 734 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 735 | ( expr = PrimaryExpr() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 736 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 737 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 738 | |
| 739 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 740 | ( |
| 741 | ( |
| 742 | ident = Field() |
| 743 | { |
| 744 | if(fa == null) |
| 745 | fa = new FieldAccessor(expr, ident); |
| 746 | else |
| 747 | fa = new FieldAccessor(fa, ident); |
| 748 | } |
| 749 | ) |
| 750 | | ( |
| 751 | indexExpr = Index() |
| 752 | { |
| 753 | if(fa == null) |
| 754 | fa = new IndexAccessor(expr, indexExpr); |
| 755 | else |
| 756 | fa = new IndexAccessor(fa, indexExpr); |
| 757 | } |
| 758 | ) |
| 759 | )* |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 760 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 761 | |
| 762 | { |
| 763 | return fa==null?expr:fa; |
| 764 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 765 | } |
| 766 | |
| 767 | Identifier Field() throws ParseException: |
| 768 | { |
| 769 | Identifier ident = null; |
| 770 | |
| 771 | } |
| 772 | { |
| 773 | "." < IDENTIFIER > |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 774 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 775 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 776 | ident = new Identifier(); |
| 777 | ident.setValue(getToken(0).toString()); |
| 778 | |
| 779 | return ident; |
| 780 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 781 | } |
| 782 | |
icetindil | a611ac7 | 2014-05-16 10:10:11 -0700 | [diff] [blame] | 783 | Expression Index() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 784 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 785 | Expression expr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 786 | } |
| 787 | { |
| 788 | "[" ( expr = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 789 | { |
| 790 | if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION) |
| 791 | { |
| 792 | Literal lit = ((LiteralExpr)expr).getValue(); |
| 793 | if(lit.getLiteralType() != Literal.Type.INTEGER && |
| 794 | lit.getLiteralType() != Literal.Type.LONG) { |
| 795 | throw new ParseException("Index should be an INTEGER"); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 796 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 797 | } |
| 798 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 799 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 800 | | "?" // ANY |
| 801 | |
| 802 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 803 | |
| 804 | "]" |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 805 | { |
| 806 | return expr; |
| 807 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | |
| 811 | Expression PrimaryExpr()throws ParseException: |
| 812 | { |
| 813 | Expression expr = null; |
| 814 | } |
| 815 | { |
ilovesoup | c9fef1d | 2012-07-08 19:30:42 +0000 | [diff] [blame] | 816 | //Literal | VariableRef | ListConstructor | RecordConstructor | FunctionCallExpr | ParenthesizedExpression |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 817 | ( |
| 818 | expr =Literal() |
| 819 | | expr = FunctionCallExpr() |
| 820 | | expr =VariableRef() |
| 821 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 822 | { |
| 823 | if(((VariableExpr)expr).getIsNewVar() == true) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 824 | throw new ParseException("can't find variable " + ((VariableExpr)expr).getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 825 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 826 | | expr = ListConstructor() |
| 827 | | expr = RecordConstructor() |
| 828 | | expr = ParenthesizedExpression() |
| 829 | | expr = MetaVariableRef() |
| 830 | ) |
| 831 | { |
| 832 | return expr; |
| 833 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 834 | } |
| 835 | |
| 836 | Expression Literal() throws ParseException: |
| 837 | { |
| 838 | |
| 839 | LiteralExpr lit = new LiteralExpr(); |
| 840 | Token t; |
| 841 | } |
| 842 | { |
| 843 | ( |
| 844 | <STRING_LITERAL> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 845 | { |
| 846 | t= getToken(0); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 847 | lit.setValue( new StringLiteral(removeQuotesAndEscapes(t.image))); |
| 848 | } |
| 849 | |
| 850 | | <INTEGER_LITERAL> |
| 851 | { |
| 852 | t= getToken(0); |
| 853 | try { |
| 854 | lit.setValue(new IntegerLiteral(new Integer(t.image))); |
| 855 | } catch(NumberFormatException ex) { |
| 856 | lit.setValue(new LongIntegerLiteral(new Long(t.image))); |
| 857 | } |
| 858 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 859 | | < FLOAT_LITERAL > |
| 860 | { |
| 861 | t= getToken(0); |
| 862 | lit.setValue(new FloatLiteral(new Float(t.image))); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 863 | } |
| 864 | | < DOUBLE_LITERAL > |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 865 | { |
| 866 | t= getToken(0); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 867 | lit.setValue(new DoubleLiteral(new Double(t.image))); |
| 868 | } |
| 869 | | <NULL> |
| 870 | { |
| 871 | t= getToken(0); |
| 872 | lit.setValue(NullLiteral.INSTANCE); |
| 873 | } |
| 874 | | <TRUE> |
| 875 | { |
| 876 | t= getToken(0); |
| 877 | lit.setValue(TrueLiteral.INSTANCE); |
| 878 | } |
| 879 | | <FALSE> |
| 880 | { |
| 881 | t= getToken(0); |
| 882 | lit.setValue(FalseLiteral.INSTANCE); |
| 883 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 884 | ) |
| 885 | { |
| 886 | return lit; |
| 887 | } |
| 888 | } |
| 889 | |
| 890 | |
| 891 | VariableExpr VariableRef() throws ParseException: |
| 892 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 893 | VariableExpr varExp = new VariableExpr(); |
| 894 | VarIdentifier var = new VarIdentifier(); |
| 895 | Token t; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 896 | } |
| 897 | { |
| 898 | <VARIABLE> |
| 899 | { |
| 900 | t = getToken(0);//get current token |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 901 | String varName = t.toString(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 902 | Identifier ident = lookupSymbol(varName); |
| 903 | if (isInForbiddenScopes(varName)) { |
| 904 | 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."); |
| 905 | } |
| 906 | if(ident != null) { // exist such ident |
| 907 | varExp.setIsNewVar(false); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 908 | varExp.setVar((VarIdentifier)ident); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 909 | } else { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 910 | varExp.setVar(var); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 911 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 912 | var.setValue(t.toString()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 913 | return varExp; |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | |
| 918 | VariableExpr Variable() throws ParseException: |
| 919 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 920 | VariableExpr varExp = new VariableExpr(); |
| 921 | VarIdentifier var = new VarIdentifier(); |
| 922 | Token t; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 923 | } |
| 924 | { |
| 925 | <VARIABLE> |
| 926 | { |
| 927 | t = getToken(0);//get current token |
| 928 | Identifier ident = lookupSymbol(t.toString()); |
| 929 | if(ident != null) { // exist such ident |
| 930 | varExp.setIsNewVar(false); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 931 | } |
| 932 | varExp.setVar(var); |
| 933 | var.setValue(t.toString()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 934 | return varExp; |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | MetaVariableExpr MetaVariableRef() throws ParseException: |
| 939 | { |
| 940 | MetaVariableExpr metaVarExp = new MetaVariableExpr(); |
| 941 | VarIdentifier var = new VarIdentifier(); |
| 942 | Token t; |
| 943 | } |
| 944 | { |
| 945 | <METAVARIABLE> |
| 946 | { |
| 947 | t = getToken(0);//get current token |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 948 | metaVarExp.setVar(var); |
| 949 | var.setValue(t.toString()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 950 | return metaVarExp; |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | Expression ListConstructor() throws ParseException: |
| 955 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 956 | Expression expr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 957 | } |
| 958 | { |
| 959 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 960 | expr = OrderedListConstructor() | expr = UnorderedListConstructor() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 961 | ) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 962 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 963 | { |
| 964 | return expr; |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | |
| 969 | ListConstructor OrderedListConstructor() throws ParseException: |
| 970 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 971 | ListConstructor expr = new ListConstructor(); |
| 972 | Expression tmp = null; |
| 973 | List<Expression> exprList = new ArrayList<Expression>(); |
| 974 | expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 975 | } |
| 976 | { |
| 977 | |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 978 | "[" |
| 979 | ( tmp = Expression() |
| 980 | { |
| 981 | exprList.add(tmp); |
| 982 | } |
| 983 | |
| 984 | ("," tmp = Expression() { exprList.add(tmp); })* |
| 985 | )? |
| 986 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 987 | "]" |
| 988 | |
| 989 | { |
| 990 | expr.setExprList(exprList); |
| 991 | return expr; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 992 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 993 | } |
| 994 | |
| 995 | ListConstructor UnorderedListConstructor() throws ParseException: |
| 996 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 997 | ListConstructor expr = new ListConstructor(); |
| 998 | Expression tmp = null; |
| 999 | List<Expression> exprList = new ArrayList<Expression>(); |
| 1000 | expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1001 | } |
| 1002 | { |
| 1003 | |
| 1004 | "{{" ( tmp = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1005 | { |
| 1006 | exprList.add(tmp); |
| 1007 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1008 | ("," tmp = Expression() { exprList.add(tmp); })*)? "}}" |
| 1009 | { |
| 1010 | expr.setExprList(exprList); |
| 1011 | return expr; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1012 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1013 | } |
| 1014 | |
| 1015 | RecordConstructor RecordConstructor() throws ParseException: |
| 1016 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1017 | RecordConstructor expr = new RecordConstructor(); |
| 1018 | FieldBinding tmp = null; |
| 1019 | List<FieldBinding> fbList = new ArrayList<FieldBinding>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1020 | } |
| 1021 | { |
| 1022 | "{" (tmp = FieldBinding() |
| 1023 | { |
| 1024 | fbList.add(tmp); |
| 1025 | } |
| 1026 | ("," tmp = FieldBinding() { fbList.add(tmp); })*)? "}" |
| 1027 | { |
| 1028 | expr.setFbList(fbList); |
| 1029 | return expr; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1030 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1031 | } |
| 1032 | |
| 1033 | FieldBinding FieldBinding() throws ParseException: |
| 1034 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1035 | FieldBinding fb = new FieldBinding(); |
| 1036 | Expression left, right; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1037 | } |
| 1038 | { |
| 1039 | left = Expression() ":" right = Expression() |
| 1040 | { |
| 1041 | fb.setLeftExpr(left); |
| 1042 | fb.setRightExpr(right); |
| 1043 | return fb; |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | Expression FunctionCallExpr() throws ParseException: |
| 1048 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1049 | CallExpr callExpr; |
| 1050 | List<Expression> argList = new ArrayList<Expression>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1051 | Expression tmp; |
| 1052 | int arity = 0; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1053 | String funcName; |
| 1054 | String dataverse; |
| 1055 | String hint=null; |
| 1056 | String id1=null; |
| 1057 | String id2=null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1058 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1059 | { |
| 1060 | ( <IDENTIFIER> { dataverse = defaultDataverse; funcName = token.image;} |
| 1061 | ("." <IDENTIFIER> { dataverse = funcName; funcName = token.image;})? |
| 1062 | | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1063 | <DATASET> {dataverse = MetadataConstants.METADATA_DATAVERSE_NAME; funcName = getToken(0).toString();} |
| 1064 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1065 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1066 | hint=getHint(token); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1067 | } |
| 1068 | <LEFTPAREN> (tmp = Expression() |
| 1069 | { |
| 1070 | argList.add(tmp); |
| 1071 | arity ++; |
| 1072 | } ("," tmp = Expression() { argList.add(tmp); arity++; })*)? <RIGHTPAREN> |
| 1073 | |
| 1074 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1075 | FunctionSignature signature = lookupFunctionSignature(dataverse, funcName.toString(), arity); |
| 1076 | if(signature == null) |
| 1077 | { |
| 1078 | signature = new FunctionSignature(dataverse, funcName.toString(), arity); |
| 1079 | } |
| 1080 | callExpr = new CallExpr(signature,argList); |
| 1081 | if (hint != null && hint.startsWith(INDEXED_NESTED_LOOP_JOIN_HINT)) { |
| 1082 | callExpr.addHint(IndexedNLJoinExpressionAnnotation.INSTANCE); |
| 1083 | } |
| 1084 | return callExpr; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | |
| 1089 | Expression ParenthesizedExpression() throws ParseException: |
| 1090 | { |
| 1091 | Expression expr; |
| 1092 | } |
| 1093 | { |
| 1094 | <LEFTPAREN> expr = Expression() <RIGHTPAREN> |
| 1095 | { |
| 1096 | return expr; |
| 1097 | } |
| 1098 | } |
| 1099 | |
| 1100 | Expression IfThenElse() throws ParseException: |
| 1101 | { |
| 1102 | Expression condExpr; |
| 1103 | Expression thenExpr; |
| 1104 | Expression elseExpr; |
| 1105 | IfExpr ifExpr = new IfExpr(); |
| 1106 | } |
| 1107 | { |
| 1108 | "if" <LEFTPAREN> condExpr = Expression() <RIGHTPAREN> "then" thenExpr = Expression() "else" elseExpr = Expression() |
| 1109 | |
| 1110 | { |
| 1111 | ifExpr.setCondExpr(condExpr); |
| 1112 | ifExpr.setThenExpr(thenExpr); |
| 1113 | ifExpr.setElseExpr(elseExpr); |
| 1114 | return ifExpr; |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | Expression FLWOGR() throws ParseException: |
| 1119 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1120 | FLWOGRExpression flworg = new FLWOGRExpression(); |
| 1121 | List<Clause> clauseList = new ArrayList<Clause>(); |
| 1122 | Expression returnExpr; |
| 1123 | Clause tmp; |
| 1124 | createNewScope(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1125 | } |
| 1126 | { |
| 1127 | (tmp = ForClause() {clauseList.add(tmp);} | tmp = LetClause() {clauseList.add(tmp);} | tmp = MetaVariableClause() {clauseList.add(tmp);}) |
| 1128 | (tmp = Clause() {clauseList.add(tmp);})* "return" returnExpr = Expression() |
| 1129 | |
| 1130 | { |
| 1131 | flworg.setClauseList(clauseList); |
| 1132 | flworg.setReturnExpr(returnExpr); |
| 1133 | removeCurrentScope(); |
| 1134 | return flworg; |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | List<Clause> Clauses() throws ParseException: |
| 1139 | { |
| 1140 | List<Clause> clauses = new ArrayList<Clause>(); |
| 1141 | Clause c = null; |
| 1142 | } |
| 1143 | { |
| 1144 | ( |
| 1145 | ( |
| 1146 | c = Clause() { |
| 1147 | clauses.add(c); |
| 1148 | } |
| 1149 | )* |
| 1150 | ) |
| 1151 | { |
| 1152 | return clauses; |
| 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | Clause Clause() throws ParseException : |
| 1157 | { |
| 1158 | Clause clause; |
| 1159 | } |
| 1160 | { |
| 1161 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1162 | clause = ForClause() |
| 1163 | | clause = LetClause() |
| 1164 | | clause = WhereClause() |
| 1165 | | clause = OrderbyClause() |
| 1166 | | clause = GroupClause() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1167 | | clause = LimitClause() |
| 1168 | | clause = DistinctClause() |
| 1169 | | clause = MetaVariableClause() |
| 1170 | | clause = JoinClause() |
| 1171 | ) |
| 1172 | { |
| 1173 | return clause; |
| 1174 | } |
| 1175 | } |
| 1176 | |
| 1177 | Clause MetaVariableClause() throws ParseException : |
| 1178 | { |
| 1179 | MetaVariableClause mc = new MetaVariableClause(); |
| 1180 | VarIdentifier var = new VarIdentifier(); |
| 1181 | Token t; |
| 1182 | } |
| 1183 | { |
| 1184 | <METAVARIABLECLAUSE> |
| 1185 | { |
| 1186 | t = getToken(0); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1187 | mc.setVar(var); |
| 1188 | var.setValue(t.toString()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1189 | return mc; |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | Clause JoinClause() throws ParseException : |
| 1194 | { |
| 1195 | Expression whereExpr; |
| 1196 | List<Clause> leftClauses, rightClauses; |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1197 | JoinClause.JoinKind kind = JoinClause.JoinKind.INNER; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1198 | } |
| 1199 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1200 | ("join" | "loj" { kind = JoinClause.JoinKind.LEFT_OUTER; } ) |
| 1201 | <LEFTPAREN> <LEFTPAREN> leftClauses = Clauses() <RIGHTPAREN> "," |
| 1202 | <LEFTPAREN> rightClauses = Clauses() <RIGHTPAREN> "," |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1203 | whereExpr = Expression() <RIGHTPAREN> |
| 1204 | { |
| 1205 | JoinClause jc = new JoinClause(kind); |
| 1206 | jc.setLeftClauses(leftClauses); |
| 1207 | jc.setRightClauses(rightClauses); |
| 1208 | jc.setWhereExpr(whereExpr); |
| 1209 | return jc; |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | Clause ForClause()throws ParseException : |
| 1214 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1215 | ForClause fc = new ForClause(); |
| 1216 | VariableExpr varExp; |
| 1217 | VariableExpr varPos = null; |
| 1218 | Expression inExp; |
| 1219 | extendCurrentScope(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1220 | } |
| 1221 | { |
| 1222 | "for" varExp = Variable() |
| 1223 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1224 | getCurrentScope().addNewVarSymbolToScope(varExp.getVar()); |
| 1225 | } |
| 1226 | ("at" varPos = Variable() |
| 1227 | { |
| 1228 | getCurrentScope().addNewVarSymbolToScope(varPos.getVar()); |
| 1229 | } |
| 1230 | )? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1231 | "in" ( inExp = Expression() ) |
| 1232 | { |
| 1233 | fc.setVarExpr(varExp); |
| 1234 | fc.setInExpr(inExp); |
| 1235 | if (varPos != null) { |
| 1236 | fc.setPosExpr(varPos); |
| 1237 | } |
| 1238 | return fc; |
| 1239 | } |
| 1240 | } |
| 1241 | |
| 1242 | Clause LetClause() throws ParseException: |
| 1243 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1244 | LetClause lc = new LetClause(); |
| 1245 | VariableExpr varExp; |
| 1246 | Expression beExp; |
| 1247 | extendCurrentScope(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1248 | } |
| 1249 | { |
ilovesoup | b2527c1 | 2012-07-12 03:21:13 +0000 | [diff] [blame] | 1250 | "let" varExp = Variable() ":=" beExp = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1251 | { |
| 1252 | getCurrentScope().addNewVarSymbolToScope(varExp.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1253 | lc.setVarExpr(varExp); |
| 1254 | lc.setBeExpr(beExp); |
| 1255 | return lc; |
| 1256 | } |
| 1257 | } |
| 1258 | |
| 1259 | Clause WhereClause()throws ParseException : |
| 1260 | { |
| 1261 | WhereClause wc = new WhereClause(); |
| 1262 | Expression whereExpr; |
| 1263 | } |
| 1264 | { |
| 1265 | "where" whereExpr = Expression() |
| 1266 | { |
| 1267 | wc.setWhereExpr(whereExpr); |
| 1268 | return wc; |
| 1269 | } |
| 1270 | } |
| 1271 | |
| 1272 | Clause OrderbyClause()throws ParseException : |
| 1273 | { |
| 1274 | OrderbyClause oc = new OrderbyClause(); |
| 1275 | Expression orderbyExpr; |
| 1276 | List<Expression> orderbyList = new ArrayList<Expression>(); |
| 1277 | List<OrderbyClause.OrderModifier> modifierList = new ArrayList<OrderbyClause.OrderModifier >(); |
| 1278 | int numOfOrderby = 0; |
| 1279 | } |
| 1280 | { |
| 1281 | ( |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1282 | "order" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1283 | { |
| 1284 | String hint = getHint(token); |
| 1285 | if (hint != null && hint.startsWith(INMEMORY_HINT)) { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1286 | String splits[] = hint.split(" +"); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1287 | int numFrames = Integer.parseInt(splits[1]); |
| 1288 | int numTuples = Integer.parseInt(splits[2]); |
| 1289 | oc.setNumFrames(numFrames); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1290 | oc.setNumTuples(numTuples); |
| 1291 | } |
| 1292 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1293 | "by" orderbyExpr = Expression() |
| 1294 | { |
| 1295 | orderbyList.add(orderbyExpr); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1296 | OrderbyClause.OrderModifier modif = OrderbyClause.OrderModifier.ASC; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1297 | } |
| 1298 | ( ("asc" { modif = OrderbyClause.OrderModifier.ASC; }) |
| 1299 | | ("desc" { modif = OrderbyClause.OrderModifier.DESC; }))? |
| 1300 | { |
| 1301 | modifierList.add(modif); |
| 1302 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1303 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1304 | ("," orderbyExpr = Expression() |
| 1305 | { |
| 1306 | orderbyList.add(orderbyExpr); |
| 1307 | modif = OrderbyClause.OrderModifier.ASC; |
| 1308 | } |
| 1309 | ( ("asc" { modif = OrderbyClause.OrderModifier.ASC; }) |
| 1310 | | ("desc" { modif = OrderbyClause.OrderModifier.DESC; }))? |
| 1311 | { |
| 1312 | modifierList.add(modif); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1313 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1314 | )* |
| 1315 | ) |
| 1316 | { |
| 1317 | oc.setModifierList(modifierList); |
| 1318 | oc.setOrderbyList(orderbyList); |
| 1319 | return oc; |
| 1320 | } |
| 1321 | } |
| 1322 | Clause GroupClause()throws ParseException : |
| 1323 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1324 | GroupbyClause gbc = new GroupbyClause(); |
| 1325 | // GbyVariableExpressionPair pair = new GbyVariableExpressionPair(); |
| 1326 | List<GbyVariableExpressionPair> vePairList = new ArrayList<GbyVariableExpressionPair>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1327 | List<GbyVariableExpressionPair> decorPairList = new ArrayList<GbyVariableExpressionPair>(); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1328 | List<VariableExpr> withVarList= new ArrayList<VariableExpr>(); |
| 1329 | VariableExpr var = null; |
| 1330 | VariableExpr withVar = null; |
| 1331 | Expression expr = null; |
| 1332 | VariableExpr decorVar = null; |
| 1333 | Expression decorExpr = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1334 | } |
| 1335 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1336 | { |
| 1337 | Scope newScope = extendCurrentScopeNoPush(true); |
| 1338 | // extendCurrentScope(true); |
| 1339 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1340 | "group" |
| 1341 | { |
| 1342 | String hint = getHint(token); |
| 1343 | if (hint != null && hint.equals(HASH_GROUP_BY_HINT)) { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1344 | gbc.setHashGroupByHint(true); |
| 1345 | } |
| 1346 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1347 | "by" (LOOKAHEAD(2) var = Variable() |
| 1348 | { |
| 1349 | newScope.addNewVarSymbolToScope(var.getVar()); |
| 1350 | } ":=")? |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1351 | expr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1352 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1353 | GbyVariableExpressionPair pair1 = new GbyVariableExpressionPair(var, expr); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1354 | vePairList.add(pair1); |
| 1355 | } |
| 1356 | ("," ( LOOKAHEAD(2) var = Variable() |
| 1357 | { |
| 1358 | newScope.addNewVarSymbolToScope(var.getVar()); |
| 1359 | } ":=")? |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1360 | expr = Expression() |
| 1361 | { |
| 1362 | GbyVariableExpressionPair pair2 = new GbyVariableExpressionPair(var, expr); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1363 | vePairList.add(pair2); |
| 1364 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1365 | )* |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1366 | ("decor" decorVar = Variable() ":=" decorExpr = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1367 | { |
| 1368 | newScope.addNewVarSymbolToScope(decorVar.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1369 | GbyVariableExpressionPair pair3 = new GbyVariableExpressionPair(decorVar, decorExpr); |
| 1370 | decorPairList.add(pair3); |
| 1371 | } |
| 1372 | ("," "decor" decorVar = Variable() ":=" decorExpr = Expression() |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1373 | { |
| 1374 | newScope.addNewVarSymbolToScope(decorVar.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1375 | GbyVariableExpressionPair pair4 = new GbyVariableExpressionPair(decorVar, decorExpr); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1376 | decorPairList.add(pair4); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1377 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1378 | )* |
| 1379 | )? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1380 | "with" withVar = VariableRef() |
| 1381 | { |
| 1382 | if(withVar.getIsNewVar()==true) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1383 | throw new ParseException("can't find variable " + withVar.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1384 | withVarList.add(withVar); |
| 1385 | newScope.addNewVarSymbolToScope(withVar.getVar()); |
| 1386 | } |
| 1387 | ("," withVar = VariableRef() |
| 1388 | { |
| 1389 | if(withVar.getIsNewVar()==true) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1390 | throw new ParseException("can't find variable " + withVar.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1391 | withVarList.add(withVar); |
| 1392 | newScope.addNewVarSymbolToScope(withVar.getVar()); |
| 1393 | })* |
| 1394 | { |
| 1395 | gbc.setGbyPairList(vePairList); |
| 1396 | gbc.setDecorPairList(decorPairList); |
| 1397 | gbc.setWithVarList(withVarList); |
| 1398 | replaceCurrentScope(newScope); |
| 1399 | return gbc; |
| 1400 | } |
| 1401 | } |
| 1402 | |
| 1403 | |
| 1404 | LimitClause LimitClause() throws ParseException: |
| 1405 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1406 | LimitClause lc = new LimitClause(); |
| 1407 | Expression expr; |
| 1408 | pushForbiddenScope(getCurrentScope()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1409 | } |
| 1410 | { |
| 1411 | "limit" expr = Expression() { lc.setLimitExpr(expr); } |
| 1412 | ("offset" expr = Expression() { lc.setOffset(expr); })? |
| 1413 | |
| 1414 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1415 | popForbiddenScope(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1416 | return lc; |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | DistinctClause DistinctClause() throws ParseException: |
| 1421 | { |
| 1422 | List<Expression> exprs = new ArrayList<Expression>(); |
| 1423 | Expression expr; |
| 1424 | } |
| 1425 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1426 | "distinct" "by" expr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1427 | { |
| 1428 | exprs.add(expr); |
| 1429 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1430 | ("," expr = Expression() |
| 1431 | { |
| 1432 | exprs.add(expr); |
| 1433 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1434 | )* |
| 1435 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1436 | return new DistinctClause(exprs); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1437 | } |
| 1438 | } |
| 1439 | |
| 1440 | |
| 1441 | QuantifiedExpression QuantifiedExpression()throws ParseException: |
| 1442 | { |
| 1443 | QuantifiedExpression qc = new QuantifiedExpression(); |
| 1444 | List<QuantifiedPair> quantifiedList = new ArrayList<QuantifiedPair>(); |
| 1445 | Expression satisfiesExpr; |
| 1446 | VariableExpr var; |
| 1447 | Expression inExpr; |
| 1448 | QuantifiedPair pair; |
| 1449 | } |
| 1450 | { |
| 1451 | { |
| 1452 | createNewScope(); |
| 1453 | } |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1454 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1455 | ( ("some" { qc.setQuantifier(QuantifiedExpression.Quantifier.SOME); }) |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1456 | | ("every" { qc.setQuantifier(QuantifiedExpression.Quantifier.EVERY); })) |
| 1457 | var = Variable() "in" inExpr = Expression() |
| 1458 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1459 | pair = new QuantifiedPair(var, inExpr); |
| 1460 | getCurrentScope().addNewVarSymbolToScope(var.getVar()); |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1461 | quantifiedList.add(pair); |
| 1462 | } |
| 1463 | ( |
| 1464 | "," var = Variable() "in" inExpr = Expression() |
| 1465 | { |
| 1466 | pair = new QuantifiedPair(var, inExpr); |
| 1467 | getCurrentScope().addNewVarSymbolToScope(var.getVar()); |
| 1468 | quantifiedList.add(pair); |
| 1469 | } |
| 1470 | )* |
| 1471 | "satisfies" satisfiesExpr = Expression() |
| 1472 | { |
| 1473 | qc.setSatisfiesExpr(satisfiesExpr); |
| 1474 | qc.setQuantifiedList(quantifiedList); |
| 1475 | removeCurrentScope(); |
| 1476 | return qc; |
| 1477 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1478 | } |
| 1479 | |
| 1480 | TOKEN_MGR_DECLS: |
| 1481 | { |
| 1482 | public int commentDepth = 0; |
| 1483 | } |
| 1484 | |
| 1485 | <DEFAULT> |
| 1486 | TOKEN : |
| 1487 | { |
| 1488 | <CARET : "^" > |
| 1489 | } |
| 1490 | |
| 1491 | <DEFAULT> |
| 1492 | TOKEN : |
| 1493 | { |
| 1494 | <DATASET : "dataset" > |
| 1495 | } |
| 1496 | |
| 1497 | <DEFAULT> |
| 1498 | TOKEN : |
| 1499 | { |
| 1500 | <LEFTPAREN : "(" > |
| 1501 | } |
| 1502 | |
| 1503 | <DEFAULT> |
| 1504 | TOKEN : |
| 1505 | { |
| 1506 | <RIGHTPAREN : ")" > |
| 1507 | } |
| 1508 | |
| 1509 | |
| 1510 | <DEFAULT> |
| 1511 | TOKEN : |
| 1512 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1513 | <INTEGER_LITERAL : (<DIGIT>)+ > |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1514 | } |
| 1515 | |
| 1516 | |
| 1517 | <DEFAULT> |
| 1518 | TOKEN : |
| 1519 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1520 | <NULL : "null"> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | <DEFAULT> |
| 1524 | TOKEN : |
| 1525 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1526 | <TRUE : "true"> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | <DEFAULT> |
| 1530 | TOKEN : |
| 1531 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1532 | <FALSE : "false"> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1533 | } |
| 1534 | |
| 1535 | <DEFAULT> |
| 1536 | TOKEN : |
| 1537 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1538 | <#DIGIT : ["0" - "9"]> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1539 | } |
| 1540 | |
| 1541 | |
| 1542 | TOKEN: |
| 1543 | { |
| 1544 | < DOUBLE_LITERAL: <INTEGER> |
| 1545 | | <INTEGER> ( "." <INTEGER> )? |
| 1546 | | "." <INTEGER> |
| 1547 | > |
| 1548 | | |
| 1549 | < FLOAT_LITERAL: <INTEGER> ( "f" | "F" ) |
| 1550 | | <INTEGER> ( "." <INTEGER> ( "f" | "F" ) )? |
| 1551 | | "." <INTEGER> ( "f" | "F" ) |
| 1552 | > |
| 1553 | | |
| 1554 | <INTEGER : (<DIGIT>)+ > |
| 1555 | } |
| 1556 | |
| 1557 | <DEFAULT> |
| 1558 | TOKEN : |
| 1559 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1560 | <#LETTER : ["A" - "Z", "a" - "z"]> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1561 | } |
| 1562 | |
| 1563 | <DEFAULT> |
| 1564 | TOKEN : |
| 1565 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1566 | <SPECIALCHARS : ["$", "_", "-"] > |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1567 | } |
| 1568 | |
| 1569 | <DEFAULT> |
| 1570 | TOKEN : |
| 1571 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1572 | <STRING_LITERAL : ("\"" (<EscapeQuot> | ~["\""])* "\"") | ("\'"(<EscapeApos> | ~["\'"])* "\'")> |
| 1573 | | |
| 1574 | < #EscapeQuot: "\\\"" > |
| 1575 | | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1576 | < #EscapeApos: "\\\'" > |
| 1577 | } |
| 1578 | |
| 1579 | <DEFAULT> |
| 1580 | TOKEN : |
| 1581 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1582 | <IDENTIFIER : (<LETTER>)+ (<LETTER> | <DIGIT> | <SPECIALCHARS>)*> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1583 | } |
| 1584 | |
| 1585 | <DEFAULT> |
| 1586 | TOKEN : |
| 1587 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1588 | <VARIABLE : "$" <IDENTIFIER> > |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1589 | } |
| 1590 | |
| 1591 | <DEFAULT> |
| 1592 | TOKEN : |
| 1593 | { |
| 1594 | <METAVARIABLECLAUSE : "#" <IDENTIFIER> > |
| 1595 | } |
| 1596 | |
| 1597 | <DEFAULT> |
| 1598 | TOKEN : |
| 1599 | { |
| 1600 | <METAVARIABLE : "$$" <IDENTIFIER> > |
| 1601 | } |
| 1602 | |
| 1603 | SKIP: |
| 1604 | { |
| 1605 | " " |
| 1606 | | "\t" |
| 1607 | | "\r" |
| 1608 | | "\n" |
| 1609 | } |
| 1610 | |
| 1611 | SKIP: |
| 1612 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1613 | <"//" (~["\n"])* "\n"> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | SKIP: |
| 1617 | { |
Taewoo Kim | a12d8cd | 2015-03-04 13:47:08 -0800 | [diff] [blame] | 1618 | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")?> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1619 | } |
| 1620 | |
| 1621 | |
| 1622 | SKIP: |
| 1623 | { |
| 1624 | <"/*"> {commentDepth=1;}: INSIDE_COMMENT |
| 1625 | } |
| 1626 | |
| 1627 | <INSIDE_COMMENT> |
| 1628 | SPECIAL_TOKEN: |
| 1629 | { |
| 1630 | <"+"(" ")*(~["/","*"])*> |
| 1631 | } |
| 1632 | |
| 1633 | <INSIDE_COMMENT> |
| 1634 | SKIP: |
| 1635 | { |
| 1636 | <"/*"> {commentDepth++;} |
| 1637 | } |
| 1638 | |
| 1639 | <INSIDE_COMMENT> |
| 1640 | SKIP: |
| 1641 | { |
| 1642 | <"*/"> {commentDepth--; if (commentDepth == 0) SwitchTo(DEFAULT);} |
| 1643 | | <~[]> |
| 1644 | } |