vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | options { |
| 2 | |
| 3 | |
| 4 | STATIC = false; |
| 5 | |
| 6 | } |
| 7 | |
| 8 | |
| 9 | PARSER_BEGIN(AQLParser) |
| 10 | |
| 11 | package edu.uci.ics.asterix.aql.parser; |
| 12 | |
| 13 | import java.io.*; |
| 14 | import java.util.List; |
| 15 | import java.util.ArrayList; |
| 16 | import java.util.Stack; |
| 17 | |
| 18 | import java.util.Map; |
| 19 | import java.util.HashMap; |
| 20 | import edu.uci.ics.asterix.aql.literal.FloatLiteral; |
| 21 | import edu.uci.ics.asterix.aql.literal.DoubleLiteral; |
| 22 | import edu.uci.ics.asterix.aql.literal.FalseLiteral; |
ilovesoup | c9fef1d | 2012-07-08 19:30:42 +0000 | [diff] [blame] | 23 | import edu.uci.ics.asterix.aql.base.Literal; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 24 | import edu.uci.ics.asterix.aql.literal.IntegerLiteral; |
ilovesoup | c9fef1d | 2012-07-08 19:30:42 +0000 | [diff] [blame] | 25 | import edu.uci.ics.asterix.aql.literal.LongIntegerLiteral; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 26 | import edu.uci.ics.asterix.aql.literal.NullLiteral; |
| 27 | import edu.uci.ics.asterix.aql.literal.StringLiteral; |
| 28 | import edu.uci.ics.asterix.aql.literal.TrueLiteral; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 29 | import edu.uci.ics.asterix.metadata.bootstrap.MetadataConstants; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 30 | |
| 31 | import edu.uci.ics.asterix.aql.base.*; |
| 32 | import edu.uci.ics.asterix.aql.expression.*; |
| 33 | import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType; |
| 34 | import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType; |
| 35 | import edu.uci.ics.asterix.aql.expression.visitor.AQLPrintVisitor; |
| 36 | import edu.uci.ics.asterix.aql.expression.UnaryExpr.Sign; |
| 37 | import edu.uci.ics.asterix.aql.base.Statement.Kind; |
| 38 | import edu.uci.ics.asterix.aql.context.Scope; |
| 39 | import edu.uci.ics.asterix.aql.context.RootScopeFactory; |
| 40 | import edu.uci.ics.asterix.common.annotations.*; |
| 41 | import edu.uci.ics.asterix.common.exceptions.AsterixException; |
ramangrover29 | a13f242 | 2012-03-15 23:01:27 +0000 | [diff] [blame] | 42 | import edu.uci.ics.asterix.om.functions.AsterixFunction; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 43 | import edu.uci.ics.asterix.common.functions.FunctionSignature; |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 44 | import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation; |
| 45 | import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IndexedNLJoinExpressionAnnotation; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 46 | import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; |
| 47 | import edu.uci.ics.hyracks.algebricks.common.utils.Pair; |
| 48 | import edu.uci.ics.hyracks.algebricks.common.utils.Triple; |
| 49 | |
| 50 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 51 | |
| 52 | |
| 53 | public class AQLParser extends ScopeChecker { |
| 54 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 55 | // optimizer hints |
| 56 | private static final String HASH_GROUP_BY_HINT = "hash"; |
| 57 | private static final String BROADCAST_JOIN_HINT = "bcast"; |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 58 | private static final String INDEXED_NESTED_LOOP_JOIN_HINT = "indexnl"; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 59 | private static final String INMEMORY_HINT = "inmem"; |
| 60 | private static final String VAL_FILE_HINT = "val-files"; |
| 61 | private static final String VAL_FILE_SAME_INDEX_HINT = "val-file-same-idx"; |
| 62 | private static final String INTERVAL_HINT = "interval"; |
| 63 | private static final String COMPOSE_VAL_FILES_HINT = "compose-val-files"; |
| 64 | private static final String INSERT_RAND_INT_HINT = "insert-rand-int"; |
| 65 | private static final String LIST_VAL_FILE_HINT = "list-val-file"; |
| 66 | private static final String LIST_HINT = "list"; |
| 67 | private static final String DATETIME_BETWEEN_YEARS_HINT = "datetime-between-years"; |
| 68 | private static final String DATE_BETWEEN_YEARS_HINT = "date-between-years"; |
| 69 | private static final String DATETIME_ADD_RAND_HOURS_HINT = "datetime-add-rand-hours"; |
| 70 | private static final String AUTO_HINT = "auto"; |
| 71 | |
| 72 | private static final String GEN_FIELDS_HINT = "gen-fields"; |
| 73 | |
| 74 | // data generator hints |
| 75 | private static final String DGEN_HINT = "dgen"; |
| 76 | |
| 77 | private static String getHint(Token t) { |
| 78 | if (t.specialToken == null) { |
| 79 | return null; |
| 80 | } |
| 81 | String s = t.specialToken.image; |
| 82 | int n = s.length(); |
| 83 | if (n < 2) { |
| 84 | return null; |
| 85 | } |
| 86 | return s.substring(1).trim(); |
| 87 | } |
| 88 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 89 | public AQLParser(String s){ |
| 90 | this(new StringReader(s)); |
| 91 | super.setInput(s); |
| 92 | } |
| 93 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 94 | public static void main(String args[]) throws ParseException, TokenMgrError, IOException, FileNotFoundException, AsterixException { |
| 95 | File file = new File(args[0]); |
| 96 | Reader fis = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); |
| 97 | AQLParser parser = new AQLParser(fis); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 98 | List<Statement> st = parser.Statement(); |
| 99 | //st.accept(new AQLPrintVisitor(), 0); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | |
| 103 | } |
| 104 | |
| 105 | PARSER_END(AQLParser) |
| 106 | |
| 107 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 108 | List<Statement> Statement() throws ParseException: |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 109 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 110 | scopeStack.push(RootScopeFactory.createRootScope(this)); |
| 111 | List<Statement> decls = new ArrayList<Statement>(); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 112 | Query query=null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 113 | } |
| 114 | { |
| 115 | ( |
| 116 | ( |
| 117 | ( |
| 118 | "use" |
| 119 | { |
| 120 | decls.add(DataverseDeclaration()); |
| 121 | } |
| 122 | | "declare" "function" { |
| 123 | decls.add(FunctionDeclaration()); |
| 124 | } |
| 125 | | "create" ( |
| 126 | { |
| 127 | String hint = getHint(token); |
| 128 | boolean dgen = false; |
| 129 | if (hint != null && hint.startsWith(DGEN_HINT)) { |
| 130 | dgen = true; |
| 131 | } |
| 132 | } |
| 133 | "type" |
| 134 | { |
| 135 | decls.add(TypeDeclaration(dgen, hint)); |
| 136 | } |
| 137 | | "nodegroup" |
| 138 | { |
| 139 | decls.add(NodegroupDeclaration()); |
| 140 | } |
| 141 | | "external" <DATASET> |
| 142 | { |
| 143 | decls.add(DatasetDeclaration(DatasetType.EXTERNAL)); |
| 144 | } |
| 145 | | "feed" <DATASET> |
| 146 | { |
| 147 | decls.add(DatasetDeclaration(DatasetType.FEED)); |
| 148 | } |
| 149 | | <DATASET> |
| 150 | { |
| 151 | decls.add(DatasetDeclaration(DatasetType.INTERNAL)); |
| 152 | } |
| 153 | | "index" |
| 154 | { |
| 155 | decls.add(CreateIndexStatement()); |
| 156 | } |
| 157 | | "dataverse" |
| 158 | { |
| 159 | decls.add(CreateDataverseStatement()); |
| 160 | } |
| 161 | | "function" |
| 162 | { |
| 163 | decls.add(FunctionCreation()); |
| 164 | } |
| 165 | ) |
| 166 | | "load" { |
| 167 | decls.add(LoadStatement()); |
| 168 | } |
| 169 | |
| 170 | | "drop" |
| 171 | ( |
| 172 | <DATASET> |
| 173 | { |
| 174 | decls.add(DropStatement()); |
| 175 | } |
| 176 | | "index" |
| 177 | { |
| 178 | decls.add(IndexDropStatement()); |
| 179 | } |
| 180 | | "nodegroup" |
| 181 | { |
| 182 | decls.add(NodeGroupDropStatement()); |
| 183 | } |
| 184 | | "type" |
| 185 | { |
| 186 | decls.add(TypeDropStatement()); |
| 187 | } |
| 188 | | "dataverse" |
| 189 | { |
| 190 | decls.add(DataverseDropStatement()); |
| 191 | } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 192 | | "function" |
| 193 | { |
| 194 | decls.add(FunctionDropStatement()); |
| 195 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 196 | ) |
| 197 | | "write" { |
| 198 | decls.add(WriteStatement()); |
| 199 | } |
| 200 | | "set" { |
| 201 | decls.add(SetStatement()); |
| 202 | } |
| 203 | | "insert" { |
| 204 | decls.add(InsertStatement()); |
| 205 | } |
| 206 | | "delete" { |
| 207 | decls.add(DeleteStatement()); |
| 208 | } |
| 209 | | "update" { |
| 210 | decls.add(UpdateStatement()); |
| 211 | } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 212 | | "begin" "feed" |
| 213 | { |
| 214 | Pair<Identifier,Identifier> nameComponents = getDotSeparatedPair(); |
| 215 | decls.add(new BeginFeedStatement(nameComponents.first, nameComponents.second, getVarCounter())); |
| 216 | } ";" |
| 217 | |
| 218 | | "suspend" "feed" |
| 219 | { |
| 220 | decls.add(ControlFeedDeclaration(ControlFeedStatement.OperationType.SUSPEND)); |
| 221 | } ";" |
| 222 | | "resume" "feed" { |
| 223 | decls.add(ControlFeedDeclaration(ControlFeedStatement.OperationType.RESUME)); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 224 | } ";" |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 225 | | "end" "feed" { |
| 226 | decls.add(ControlFeedDeclaration(ControlFeedStatement.OperationType.END)); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 227 | } ";" |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 228 | | "alter" "feed" { |
| 229 | decls.add(AlterFeedDeclaration()); |
| 230 | } ";" |
| 231 | |
| 232 | | (query = Query()) { |
| 233 | decls.add(query); |
| 234 | } |
| 235 | )* |
| 236 | // (query = Query())? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 237 | ) |
| 238 | |
| 239 | <EOF> |
| 240 | ) |
| 241 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 242 | return decls; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 243 | } |
| 244 | } |
| 245 | |
| 246 | InsertStatement InsertStatement() throws ParseException: |
| 247 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 248 | Identifier dataverseName; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 249 | Identifier datasetName; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 250 | Pair<Identifier,Identifier> nameComponents = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 251 | Query query; |
| 252 | } |
| 253 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 254 | "into" <DATASET> |
| 255 | |
| 256 | { |
| 257 | nameComponents = getDotSeparatedPair(); |
| 258 | dataverseName = nameComponents.first; |
| 259 | datasetName = nameComponents.second; |
| 260 | } |
| 261 | |
| 262 | <LEFTPAREN> query = Query() <RIGHTPAREN> ";" |
| 263 | {return new InsertStatement(dataverseName, datasetName, query, getVarCounter());} |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | DeleteStatement DeleteStatement() throws ParseException: |
| 267 | { |
| 268 | VariableExpr var = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 269 | Identifier dataverseName; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 270 | Identifier datasetName = null; |
| 271 | Expression condition = null; |
| 272 | Clause dieClause = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 273 | Pair<Identifier, Identifier> nameComponents; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 274 | } |
| 275 | { |
| 276 | var = Variable() { getCurrentScope().addNewVarSymbolToScope(var.getVar()); } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 277 | "from" |
| 278 | <DATASET> |
| 279 | { |
| 280 | nameComponents = getDotSeparatedPair(); |
| 281 | } |
| 282 | ("where" condition = Expression())? (dieClause = DieClause())? ";" |
| 283 | {return new DeleteStatement(var, nameComponents.first, nameComponents.second, condition, dieClause, getVarCounter()); } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | UpdateStatement UpdateStatement() throws ParseException: |
| 287 | { |
| 288 | VariableExpr vars; |
| 289 | Expression target; |
| 290 | Expression condition; |
| 291 | UpdateClause uc; |
| 292 | List<UpdateClause> ucs = new ArrayList<UpdateClause>(); |
| 293 | } |
| 294 | { |
| 295 | vars = Variable() "in" target = Expression() |
| 296 | "where" condition = Expression() |
| 297 | <LEFTPAREN> (uc=UpdateClause() {ucs.add(uc); } ("," uc=UpdateClause() {ucs.add(uc); } )*) <RIGHTPAREN> ";" |
| 298 | {return new UpdateStatement(vars, target, condition, ucs);} |
| 299 | } |
| 300 | |
| 301 | |
| 302 | |
| 303 | UpdateClause UpdateClause() throws ParseException: |
| 304 | { |
| 305 | Expression target = null; |
| 306 | Expression value = null ; |
| 307 | InsertStatement is = null; |
| 308 | DeleteStatement ds = null; |
| 309 | UpdateStatement us = null; |
| 310 | Expression condition = null; |
| 311 | UpdateClause ifbranch = null; |
| 312 | UpdateClause elsebranch = null; |
| 313 | } |
| 314 | { |
| 315 | "set" target = Expression() ":=" value = Expression() |
| 316 | | "insert" is = InsertStatement() |
| 317 | | "delete" ds = DeleteStatement() |
| 318 | | "update" us = UpdateStatement() |
| 319 | | "if" <LEFTPAREN> condition = Expression() <RIGHTPAREN> "then" ifbranch = UpdateClause() [LOOKAHEAD(1) "else" elsebranch = UpdateClause()] |
| 320 | {return new UpdateClause(target, value, is, ds, us, condition, ifbranch, elsebranch);} |
| 321 | } |
| 322 | |
| 323 | |
| 324 | Statement SetStatement() throws ParseException: |
| 325 | { |
| 326 | String pn = null; |
| 327 | Statement stmt = null; |
| 328 | } |
| 329 | { |
| 330 | <IDENTIFIER> { pn = token.image; } |
| 331 | <STRING_LITERAL> |
| 332 | { String pv = removeQuotesAndEscapes(token.image); } |
| 333 | ";" |
| 334 | { |
| 335 | return new SetStatement(pn, pv); |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | Statement WriteStatement() throws ParseException: |
| 340 | { |
| 341 | Identifier nodeName = null; |
| 342 | String fileName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 343 | Statement stmt = null; |
| 344 | Query query; |
| 345 | String writerClass = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 346 | Pair<Identifier,Identifier> nameComponents = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 347 | } |
| 348 | { |
| 349 | (( "output" "to" |
| 350 | <IDENTIFIER> { nodeName = new Identifier(token.image); } |
| 351 | ":" <STRING_LITERAL> { fileName = removeQuotesAndEscapes(token.image); } |
| 352 | ( "using" <STRING_LITERAL> { writerClass = removeQuotesAndEscapes(token.image); } )? |
| 353 | { |
| 354 | stmt = new WriteStatement(nodeName, fileName, writerClass); |
| 355 | } ) |
| 356 | | |
| 357 | ( "into" |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 358 | <DATASET> |
| 359 | |
| 360 | { |
| 361 | nameComponents = getDotSeparatedPair(); |
| 362 | } |
| 363 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 364 | <LEFTPAREN> query = Query() <RIGHTPAREN> |
| 365 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 366 | stmt = new WriteFromQueryResultStatement(nameComponents.first, nameComponents.second, query, getVarCounter()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 367 | } )) |
| 368 | |
| 369 | ";" |
| 370 | { |
| 371 | return stmt; |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | CreateIndexStatement CreateIndexStatement() throws ParseException: |
| 376 | { |
| 377 | CreateIndexStatement cis = new CreateIndexStatement(); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 378 | Pair<Identifier,Identifier> nameComponents = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 379 | } |
| 380 | { |
| 381 | <IDENTIFIER> { cis.setIndexName(new Identifier(token.image)); } |
| 382 | ( |
| 383 | "if not exists" |
| 384 | { |
| 385 | cis.setIfNotExists(true); |
| 386 | } |
| 387 | )? |
| 388 | "on" |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 389 | |
| 390 | { |
| 391 | nameComponents = getDotSeparatedPair(); |
| 392 | cis.setDataverseName(nameComponents.first); |
| 393 | cis.setDatasetName(nameComponents.second); |
| 394 | } |
| 395 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 396 | <LEFTPAREN> |
| 397 | ( <IDENTIFIER> { cis.addFieldExpr(token.image); } ) |
| 398 | ("," <IDENTIFIER> { cis.addFieldExpr(token.image); })* |
| 399 | <RIGHTPAREN> |
| 400 | ("type" |
alexander.behm | b742e09 | 2012-11-24 11:54:56 +0000 | [diff] [blame] | 401 | ("btree" { cis.setIndexType(IndexType.BTREE); } |
alexander.behm | c576c60 | 2012-07-06 02:41:15 +0000 | [diff] [blame] | 402 | | "rtree" { cis.setIndexType(IndexType.RTREE); } |
alexander.behm | b742e09 | 2012-11-24 11:54:56 +0000 | [diff] [blame] | 403 | | "keyword" { cis.setIndexType(IndexType.WORD_INVIX); } |
| 404 | | "fuzzy keyword" { cis.setIndexType(IndexType.FUZZY_WORD_INVIX); } |
alexander.behm | c576c60 | 2012-07-06 02:41:15 +0000 | [diff] [blame] | 405 | | "ngram" |
| 406 | <LEFTPAREN> |
| 407 | (<INTEGER_LITERAL> |
| 408 | { |
| 409 | cis.setIndexType(IndexType.NGRAM_INVIX); |
| 410 | cis.setGramLength(Integer.valueOf(token.image)); |
| 411 | } |
| 412 | ) |
alexander.behm | b742e09 | 2012-11-24 11:54:56 +0000 | [diff] [blame] | 413 | <RIGHTPAREN> |
| 414 | | "fuzzy ngram" |
| 415 | <LEFTPAREN> |
| 416 | (<INTEGER_LITERAL> |
| 417 | { |
| 418 | cis.setIndexType(IndexType.FUZZY_NGRAM_INVIX); |
| 419 | cis.setGramLength(Integer.valueOf(token.image)); |
| 420 | } |
| 421 | ) |
| 422 | <RIGHTPAREN> |
alexander.behm | c576c60 | 2012-07-06 02:41:15 +0000 | [diff] [blame] | 423 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 424 | ";" |
| 425 | | ";" |
| 426 | ) |
| 427 | { |
| 428 | return cis; |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | DataverseDecl DataverseDeclaration() throws ParseException: |
| 433 | { |
| 434 | Identifier dvName = null; |
| 435 | } |
| 436 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 437 | "dataverse" <IDENTIFIER> { defaultDataverse = token.image;} |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 438 | ";" |
| 439 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 440 | return new DataverseDecl(new Identifier(defaultDataverse)); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 441 | } |
| 442 | } |
| 443 | |
| 444 | DropStatement DropStatement() throws ParseException : |
| 445 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 446 | Identifier dataverseName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 447 | Identifier datasetName = null; |
| 448 | boolean ifExists = false; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 449 | Pair<Identifier,Identifier> nameComponents=null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 450 | } |
| 451 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 452 | { |
| 453 | nameComponents = getDotSeparatedPair(); |
| 454 | dataverseName = nameComponents.first; |
| 455 | datasetName = nameComponents.second; |
| 456 | } |
| 457 | |
| 458 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 459 | ( |
| 460 | "if exists" |
| 461 | { |
| 462 | ifExists = true; |
| 463 | } |
| 464 | )? ";" |
| 465 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 466 | return new DropStatement(dataverseName, datasetName, ifExists); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 467 | } |
| 468 | } |
| 469 | |
| 470 | IndexDropStatement IndexDropStatement() throws ParseException : |
| 471 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 472 | Identifier dataverseName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 473 | Identifier datasetName = null; |
| 474 | Identifier indexName = null; |
| 475 | boolean ifExists = false; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 476 | Triple<Identifier,Identifier,Identifier> nameComponents=null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 477 | } |
| 478 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 479 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 480 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 481 | nameComponents = getDotSeparatedTriple(); |
| 482 | dataverseName = nameComponents.first; |
| 483 | datasetName = nameComponents.second; |
| 484 | indexName = nameComponents.third; |
| 485 | } |
| 486 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 487 | ( |
| 488 | "if exists" |
| 489 | { |
| 490 | ifExists = true; |
| 491 | } |
| 492 | )? ";" |
| 493 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 494 | return new IndexDropStatement(dataverseName, datasetName, indexName, ifExists); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 495 | } |
| 496 | } |
| 497 | |
| 498 | NodeGroupDropStatement NodeGroupDropStatement() throws ParseException : |
| 499 | { |
| 500 | Identifier groupName = null; |
| 501 | boolean ifExists = false; |
| 502 | } |
| 503 | { |
| 504 | < IDENTIFIER > |
| 505 | { |
| 506 | groupName = new Identifier(token.image); |
| 507 | } |
| 508 | ( |
| 509 | "if exists" |
| 510 | { |
| 511 | ifExists = true; |
| 512 | } |
| 513 | )? ";" |
| 514 | { |
| 515 | return new NodeGroupDropStatement(groupName, ifExists); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | TypeDropStatement TypeDropStatement() throws ParseException : |
| 520 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 521 | Identifier dataverseName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 522 | Identifier typeName = null; |
| 523 | boolean ifExists = false; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 524 | Pair<Identifier,Identifier> nameComponents; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 525 | } |
| 526 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 527 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 528 | nameComponents = getDotSeparatedPair(); |
| 529 | dataverseName = nameComponents.first == null ? new Identifier(defaultDataverse) : nameComponents.first; |
| 530 | typeName = nameComponents.second; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 531 | } |
| 532 | ( |
| 533 | "if exists" |
| 534 | { |
| 535 | ifExists = true; |
| 536 | } |
| 537 | )? ";" |
| 538 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 539 | return new TypeDropStatement(dataverseName, typeName, ifExists); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
| 543 | DataverseDropStatement DataverseDropStatement() throws ParseException : |
| 544 | { |
| 545 | Identifier dataverseName = null; |
| 546 | boolean ifExists = false; |
| 547 | } |
| 548 | { |
| 549 | < IDENTIFIER > |
| 550 | { |
| 551 | dataverseName = new Identifier(token.image); |
| 552 | } |
| 553 | ( |
| 554 | "if exists" |
| 555 | { |
| 556 | ifExists = true; |
| 557 | } |
| 558 | )? ";" |
| 559 | { |
| 560 | return new DataverseDropStatement(dataverseName, ifExists); |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | CreateDataverseStatement CreateDataverseStatement() throws ParseException : |
| 565 | { |
| 566 | Identifier dvName = null; |
| 567 | boolean ifNotExists = false; |
| 568 | String format = null; |
| 569 | } |
| 570 | { |
| 571 | < IDENTIFIER > |
| 572 | { |
| 573 | dvName = new Identifier(token.image); |
| 574 | } |
| 575 | ( |
| 576 | "if not exists" |
| 577 | { |
| 578 | ifNotExists = true; |
| 579 | } |
| 580 | )? |
| 581 | ( |
| 582 | "with format" < STRING_LITERAL > |
| 583 | { |
| 584 | format = removeQuotesAndEscapes(token.image); |
| 585 | } |
| 586 | )? |
| 587 | ";" |
| 588 | { |
| 589 | return new CreateDataverseStatement(dvName, format, ifNotExists); |
| 590 | } |
| 591 | } |
| 592 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 593 | |
| 594 | FunctionDropStatement FunctionDropStatement() throws ParseException : |
| 595 | { |
| 596 | String dataverse; |
| 597 | String functionName; |
| 598 | int arity=0; |
| 599 | boolean ifExists = false; |
| 600 | Pair<Identifier, Identifier> nameComponents=null; |
| 601 | } |
| 602 | { |
| 603 | { |
| 604 | nameComponents = getDotSeparatedPair(); |
| 605 | dataverse = nameComponents.first != null ? nameComponents.first.getValue() : defaultDataverse; |
| 606 | functionName = nameComponents.second.getValue(); |
| 607 | } |
| 608 | |
| 609 | "@" |
| 610 | <INTEGER_LITERAL> |
| 611 | { |
| 612 | Token t= getToken(0); |
| 613 | arity = new Integer(t.image); |
| 614 | if( arity < 0 && arity != FunctionIdentifier.VARARGS){ |
| 615 | throw new ParseException(" invalid arity:" + arity); |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | ( |
| 620 | "if exists" |
| 621 | { |
| 622 | ifExists = true; |
| 623 | } |
| 624 | )? ";" |
| 625 | { |
| 626 | return new FunctionDropStatement(new FunctionSignature(dataverse, functionName, arity), ifExists); |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 631 | LoadFromFileStatement LoadStatement() throws ParseException: |
| 632 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 633 | Identifier dataverseName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 634 | Identifier datasetName = null; |
| 635 | boolean alreadySorted = false; |
| 636 | String adapterClassname; |
| 637 | Map<String,String> properties; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 638 | Pair<Identifier,Identifier> nameComponents = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 639 | } |
| 640 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 641 | <DATASET> |
| 642 | { |
| 643 | nameComponents = getDotSeparatedPair(); |
| 644 | dataverseName = nameComponents.first; |
| 645 | datasetName = nameComponents.second; |
| 646 | } |
| 647 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 648 | "using" |
| 649 | |
| 650 | <STRING_LITERAL> |
| 651 | { |
| 652 | adapterClassname = removeQuotesAndEscapes(token.image); |
| 653 | } |
| 654 | |
| 655 | { |
| 656 | properties = getConfiguration(); |
| 657 | } |
| 658 | |
| 659 | ("pre-sorted" |
| 660 | { alreadySorted = true; } |
| 661 | )? |
| 662 | |
| 663 | ";" |
| 664 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 665 | return new LoadFromFileStatement(dataverseName, datasetName, adapterClassname, properties, alreadySorted); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 666 | } |
| 667 | } |
| 668 | |
| 669 | |
| 670 | |
| 671 | DatasetDecl DatasetDeclaration(DatasetType datasetType) throws ParseException : |
| 672 | { |
| 673 | DatasetDecl dd = null; |
| 674 | Identifier datasetName = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 675 | Identifier dataverseName = null; |
| 676 | Identifier itemDataverseName = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 677 | Identifier itemTypeName = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 678 | String nameComponentFirst = null; |
| 679 | String nameComponentSecond = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 680 | boolean ifNotExists = false; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 681 | IDatasetDetailsDecl datasetDetails = null; |
| 682 | Pair<Identifier,Identifier> nameComponents = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 683 | } |
| 684 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 685 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 686 | nameComponents = getDotSeparatedPair(); |
| 687 | dataverseName = nameComponents.first; |
| 688 | datasetName = nameComponents.second; |
| 689 | } |
| 690 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 691 | ( |
| 692 | "if not exists" |
| 693 | { |
| 694 | ifNotExists = true; |
| 695 | } |
| 696 | )? |
| 697 | ( |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 698 | < LEFTPAREN > <IDENTIFIER> |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 699 | { |
| 700 | itemTypeName = new Identifier(token.image); |
| 701 | } |
| 702 | < RIGHTPAREN > |
RamanGrover29@gmail.com | c022a0d | 2012-07-28 05:13:44 +0000 | [diff] [blame] | 703 | ) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 704 | { |
| 705 | if(datasetType == DatasetType.INTERNAL) { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 706 | datasetDetails = InternalDatasetDeclaration(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 707 | } |
| 708 | else if(datasetType == DatasetType.EXTERNAL) { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 709 | datasetDetails = ExternalDatasetDeclaration(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 710 | } |
| 711 | else if(datasetType == DatasetType.FEED) { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 712 | datasetDetails = FeedDatasetDeclaration(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 713 | } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 714 | dd = new DatasetDecl(dataverseName, datasetName, itemTypeName, datasetType, datasetDetails,ifNotExists); |
| 715 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 716 | } |
| 717 | { |
| 718 | return dd; |
| 719 | } |
| 720 | } |
| 721 | |
| 722 | InternalDetailsDecl InternalDatasetDeclaration() throws ParseException : |
| 723 | { |
| 724 | InternalDetailsDecl idd = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 725 | List<String> partitioningExprs = new ArrayList<String>(); |
| 726 | Identifier nodeGroupName=null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 727 | } |
| 728 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 729 | "partitioned" "by" "key" |
| 730 | < IDENTIFIER > |
| 731 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 732 | partitioningExprs.add(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 733 | } |
| 734 | ( |
| 735 | "," < IDENTIFIER > |
| 736 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 737 | partitioningExprs.add(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 738 | } |
| 739 | )* |
| 740 | ( |
| 741 | "on" < IDENTIFIER > |
| 742 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 743 | nodeGroupName = new Identifier(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 744 | } |
| 745 | )? |
| 746 | ";" |
| 747 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 748 | idd = new InternalDetailsDecl(nodeGroupName, partitioningExprs); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 749 | return idd; |
| 750 | } |
| 751 | } |
| 752 | |
| 753 | ExternalDetailsDecl ExternalDatasetDeclaration() throws ParseException : |
| 754 | { |
| 755 | ExternalDetailsDecl edd = null; |
| 756 | String adapterClassname = null; |
| 757 | Map < String, String > properties; |
| 758 | } |
| 759 | { |
| 760 | { |
| 761 | edd = new ExternalDetailsDecl(); |
| 762 | } |
| 763 | |
| 764 | "using" |
| 765 | |
| 766 | <STRING_LITERAL> |
| 767 | { |
| 768 | adapterClassname = removeQuotesAndEscapes(token.image); |
| 769 | } |
| 770 | |
| 771 | { |
| 772 | properties = getConfiguration(); |
| 773 | } |
| 774 | |
| 775 | { |
| 776 | edd = new ExternalDetailsDecl(); |
| 777 | edd.setAdapter(adapterClassname); |
| 778 | edd.setProperties(properties); |
| 779 | } |
| 780 | ";" |
| 781 | |
| 782 | { |
| 783 | return edd; |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | FeedDetailsDecl FeedDatasetDeclaration() throws ParseException : |
| 788 | { |
| 789 | FeedDetailsDecl fdd = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 790 | String adapterFactoryClassname = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 791 | Map < String, String > properties; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 792 | Pair<Identifier,Identifier> nameComponents; |
| 793 | List<String> partitioningExprs = new ArrayList<String>(); |
| 794 | Identifier nodeGroupName=null; |
| 795 | FunctionSignature appliedFunction=null; |
| 796 | String dataverse; |
| 797 | String functionName; |
| 798 | int arity; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 799 | } |
| 800 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 801 | "using" |
| 802 | |
| 803 | <STRING_LITERAL> |
| 804 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 805 | adapterFactoryClassname = removeQuotesAndEscapes(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | { |
| 809 | properties = getConfiguration(); |
| 810 | } |
| 811 | |
| 812 | ("apply" "function" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 813 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 814 | nameComponents = getDotSeparatedPair(); |
| 815 | dataverse = nameComponents.first != null ? nameComponents.first.getValue() : defaultDataverse; |
| 816 | functionName = nameComponents.second.getValue(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 817 | } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 818 | ("@" <IDENTIFIER> |
| 819 | { |
| 820 | arity = Integer.parseInt(token.image); |
| 821 | } |
| 822 | ) |
| 823 | |
| 824 | { |
| 825 | appliedFunction = new FunctionSignature(dataverse, functionName, arity); |
| 826 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 827 | )? |
| 828 | |
| 829 | "partitioned" "by" "key" |
| 830 | < IDENTIFIER > |
| 831 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 832 | partitioningExprs.add(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 833 | } |
| 834 | ( |
| 835 | "," < IDENTIFIER > |
| 836 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 837 | partitioningExprs.add(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 838 | } |
| 839 | )* |
| 840 | ( |
| 841 | "on" < IDENTIFIER > |
| 842 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 843 | nodeGroupName = new Identifier(token.image); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 844 | } |
| 845 | )? |
| 846 | ";" |
| 847 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 848 | fdd = new FeedDetailsDecl(adapterFactoryClassname, properties, appliedFunction, nodeGroupName, partitioningExprs); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 849 | return fdd; |
| 850 | } |
| 851 | } |
| 852 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 853 | ControlFeedStatement ControlFeedDeclaration(ControlFeedStatement.OperationType operationType) throws ParseException : |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 854 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 855 | Pair<Identifier,Identifier> nameComponents = null; |
| 856 | } |
| 857 | { |
| 858 | { |
| 859 | nameComponents = getDotSeparatedPair(); |
| 860 | return new ControlFeedStatement(operationType, nameComponents.first, nameComponents.second); |
| 861 | } |
| 862 | } |
| 863 | |
| 864 | |
| 865 | ControlFeedStatement AlterFeedDeclaration() throws ParseException : |
| 866 | { |
| 867 | Pair<Identifier,Identifier> nameComponents = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 868 | Map < String, String > configuration = new HashMap < String, String > (); |
| 869 | } |
| 870 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 871 | { |
| 872 | nameComponents = getDotSeparatedPair(); |
| 873 | } |
| 874 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 875 | "set" |
| 876 | { |
| 877 | configuration = getConfiguration(); |
| 878 | } |
| 879 | ";" |
| 880 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 881 | return new ControlFeedStatement(ControlFeedStatement.OperationType.ALTER, nameComponents.first, nameComponents.second, configuration); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 882 | } |
| 883 | } |
| 884 | |
| 885 | Map<String,String> getConfiguration() throws ParseException : |
| 886 | { |
| 887 | Map<String,String> configuration = new HashMap<String,String>(); |
| 888 | String key; |
| 889 | String value; |
| 890 | } |
| 891 | { |
| 892 | |
| 893 | <LEFTPAREN> |
| 894 | ( |
| 895 | ( |
| 896 | <LEFTPAREN> |
| 897 | ( |
| 898 | <STRING_LITERAL> |
| 899 | { |
| 900 | key = removeQuotesAndEscapes(token.image); |
| 901 | } |
| 902 | "=" <STRING_LITERAL> |
| 903 | { |
| 904 | value = removeQuotesAndEscapes(token.image); |
| 905 | } |
| 906 | ) |
| 907 | <RIGHTPAREN> |
| 908 | { |
| 909 | configuration.put(key, value); |
| 910 | } |
| 911 | ) |
| 912 | ( |
| 913 | "," <LEFTPAREN> |
| 914 | ( |
| 915 | <STRING_LITERAL> |
| 916 | { |
| 917 | key = removeQuotesAndEscapes(token.image); |
| 918 | } |
| 919 | "=" <STRING_LITERAL> |
| 920 | { |
| 921 | value = removeQuotesAndEscapes(token.image); |
| 922 | } |
| 923 | ) |
| 924 | <RIGHTPAREN> |
| 925 | { |
| 926 | configuration.put(key, value); |
| 927 | } |
| 928 | )* |
| 929 | )? |
| 930 | <RIGHTPAREN> |
| 931 | { |
| 932 | return configuration; |
| 933 | } |
| 934 | } |
| 935 | |
| 936 | |
| 937 | NodegroupDecl NodegroupDeclaration() throws ParseException : |
| 938 | { |
| 939 | Identifier name = null; |
| 940 | List < Identifier > ncNames = new ArrayList < Identifier > (); |
| 941 | boolean ifNotExists = false; |
| 942 | } |
| 943 | { |
| 944 | < IDENTIFIER > |
| 945 | { |
| 946 | name = new Identifier(token.image); |
| 947 | } |
| 948 | ( |
| 949 | "if not exists" |
| 950 | { |
| 951 | ifNotExists = true; |
| 952 | } |
| 953 | )? |
| 954 | "on" < IDENTIFIER > |
| 955 | { |
| 956 | ncNames.add(new Identifier(token.image)); |
| 957 | } |
| 958 | ( |
| 959 | "," < IDENTIFIER > |
| 960 | { |
| 961 | ncNames.add(new Identifier(token.image)); |
| 962 | } |
| 963 | )* |
| 964 | ";" |
| 965 | { |
| 966 | return new NodegroupDecl(name, ncNames, ifNotExists); |
| 967 | } |
| 968 | } |
| 969 | |
| 970 | |
| 971 | TypeDecl TypeDeclaration(boolean dgen, String hint) throws ParseException: |
| 972 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 973 | Identifier dataverse; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 974 | Identifier ident; |
| 975 | TypeExpression typeExpr; |
| 976 | boolean ifNotExists = false; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 977 | Pair<Identifier,Identifier> nameComponents=null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 978 | } |
| 979 | { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 980 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 981 | nameComponents = getDotSeparatedPair(); |
| 982 | dataverse = nameComponents.first; |
| 983 | ident = nameComponents.second; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 984 | } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 985 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 986 | ( |
| 987 | "if not exists" |
| 988 | { |
| 989 | ifNotExists = true; |
| 990 | } |
| 991 | )? |
| 992 | "as" |
| 993 | ( typeExpr = TypeExpr() ) |
RamanGrover29@gmail.com | c022a0d | 2012-07-28 05:13:44 +0000 | [diff] [blame] | 994 | (";")? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 995 | { |
| 996 | long numValues = -1; |
| 997 | String filename = null; |
| 998 | if (dgen) { |
| 999 | String splits[] = hint.split(" +"); |
| 1000 | if (splits.length != 3) { |
| 1001 | throw new ParseException("Expecting /*+ dgen <filename> <numberOfItems> */"); |
| 1002 | } |
| 1003 | filename = splits[1]; |
| 1004 | numValues = Long.parseLong(splits[2]); |
| 1005 | } |
| 1006 | TypeDataGen tddg = new TypeDataGen(dgen, filename, numValues); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1007 | return new TypeDecl(dataverse, ident, typeExpr, tddg, ifNotExists); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | TypeExpression TypeExpr() throws ParseException: |
| 1012 | { |
| 1013 | TypeExpression typeExpr = null; |
| 1014 | } |
| 1015 | { |
| 1016 | ( |
| 1017 | typeExpr = RecordTypeDef() |
| 1018 | | typeExpr = TypeReference() |
| 1019 | | typeExpr = OrderedListTypeDef() |
| 1020 | | typeExpr = UnorderedListTypeDef() |
| 1021 | ) |
| 1022 | { |
| 1023 | return typeExpr; |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | RecordTypeDefinition RecordTypeDef() throws ParseException: |
| 1028 | { |
| 1029 | RecordTypeDefinition recType = new RecordTypeDefinition(); |
| 1030 | RecordTypeDefinition.RecordKind recordKind = null; |
| 1031 | } |
| 1032 | { |
| 1033 | ( "closed" { recordKind = RecordTypeDefinition.RecordKind.CLOSED; } |
| 1034 | | "open" { recordKind = RecordTypeDefinition.RecordKind.OPEN; } )? |
| 1035 | "{" |
| 1036 | { |
| 1037 | String hint = getHint(token); |
| 1038 | if (hint != null) { |
| 1039 | String splits[] = hint.split(" +"); |
| 1040 | if (splits[0].equals(GEN_FIELDS_HINT)) { |
| 1041 | if (splits.length != 5) { |
| 1042 | throw new ParseException("Expecting: /*+ gen-fields <type> <min> <max> <prefix>*/"); |
| 1043 | } |
| 1044 | if (!splits[1].equals("int")) { |
| 1045 | throw new ParseException("The only supported type for gen-fields is int."); |
| 1046 | } |
| 1047 | UndeclaredFieldsDataGen ufdg = new UndeclaredFieldsDataGen(UndeclaredFieldsDataGen.Type.INT, |
| 1048 | Integer.parseInt(splits[2]), Integer.parseInt(splits[3]), splits[4]); |
| 1049 | recType.setUndeclaredFieldsDataGen(ufdg); |
| 1050 | } |
| 1051 | } |
| 1052 | |
| 1053 | } |
| 1054 | ( |
| 1055 | RecordField(recType) |
| 1056 | ( "," RecordField(recType) )* |
| 1057 | )? |
| 1058 | "}" |
| 1059 | { |
| 1060 | if (recordKind == null) { |
| 1061 | recordKind = RecordTypeDefinition.RecordKind.OPEN; |
| 1062 | } |
| 1063 | recType.setRecordKind(recordKind); |
| 1064 | return recType; |
| 1065 | } |
| 1066 | } |
| 1067 | |
| 1068 | void RecordField(RecordTypeDefinition recType) throws ParseException: |
| 1069 | { |
| 1070 | String fieldName; |
| 1071 | TypeExpression type = null; |
| 1072 | boolean nullable = false; |
| 1073 | } |
| 1074 | { |
| 1075 | <IDENTIFIER> |
| 1076 | { |
| 1077 | Token t = getToken(0); |
| 1078 | fieldName = t.toString(); |
| 1079 | String hint = getHint(t); |
| 1080 | IRecordFieldDataGen rfdg = null; |
| 1081 | if (hint != null) { |
| 1082 | String splits[] = hint.split(" +"); |
| 1083 | if (splits[0].equals(VAL_FILE_HINT)) { |
| 1084 | File[] valFiles = new File[splits.length - 1]; |
| 1085 | for (int k=1; k<splits.length; k++) { |
| 1086 | valFiles[k-1] = new File(splits[k]); |
| 1087 | } |
| 1088 | rfdg = new FieldValFileDataGen(valFiles); |
| 1089 | } else if (splits[0].equals(VAL_FILE_SAME_INDEX_HINT)) { |
| 1090 | rfdg = new FieldValFileSameIndexDataGen(new File(splits[1]), splits[2]); |
| 1091 | } else if (splits[0].equals(LIST_VAL_FILE_HINT)) { |
| 1092 | rfdg = new ListValFileDataGen(new File(splits[1]), Integer.parseInt(splits[2]), Integer.parseInt(splits[3])); |
| 1093 | } else if (splits[0].equals(LIST_HINT)) { |
| 1094 | rfdg = new ListDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2])); |
| 1095 | } else if (splits[0].equals(INTERVAL_HINT)) { |
| 1096 | FieldIntervalDataGen.ValueType vt; |
| 1097 | if (splits[1].equals("int")) { |
| 1098 | vt = FieldIntervalDataGen.ValueType.INT; |
| 1099 | } else if (splits[1].equals("long")) { |
| 1100 | vt = FieldIntervalDataGen.ValueType.LONG; |
| 1101 | } else if (splits[1].equals("float")) { |
| 1102 | vt = FieldIntervalDataGen.ValueType.FLOAT; |
| 1103 | } else if (splits[1].equals("double")) { |
| 1104 | vt = FieldIntervalDataGen.ValueType.DOUBLE; |
| 1105 | } else { |
| 1106 | throw new ParseException("Unknown type for interval data gen: " + splits[1]); |
| 1107 | } |
| 1108 | rfdg = new FieldIntervalDataGen(vt, splits[2], splits[3]); |
| 1109 | } else if (splits[0].equals(INSERT_RAND_INT_HINT)) { |
| 1110 | rfdg = new InsertRandIntDataGen(splits[1], splits[2]); |
| 1111 | } else if (splits[0].equals(DATE_BETWEEN_YEARS_HINT)) { |
| 1112 | rfdg = new DateBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2])); |
| 1113 | } else if (splits[0].equals(DATETIME_BETWEEN_YEARS_HINT)) { |
| 1114 | rfdg = new DatetimeBetweenYearsDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2])); |
| 1115 | } else if (splits[0].equals(DATETIME_ADD_RAND_HOURS_HINT)) { |
| 1116 | rfdg = new DatetimeAddRandHoursDataGen(Integer.parseInt(splits[1]), Integer.parseInt(splits[2]), splits[3]); |
| 1117 | } else if (splits[0].equals(AUTO_HINT)) { |
| 1118 | rfdg = new AutoDataGen(splits[1]); |
| 1119 | } |
| 1120 | } |
| 1121 | } |
| 1122 | ":" |
| 1123 | ( type = TypeExpr() ) |
| 1124 | ("?" { nullable = true; } )? |
| 1125 | { |
| 1126 | recType.addField(fieldName, type, nullable, rfdg); |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | TypeReferenceExpression TypeReference() throws ParseException: |
| 1131 | {} |
| 1132 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1133 | <IDENTIFIER> |
| 1134 | { |
| 1135 | Token t = getToken(0); |
| 1136 | Identifier id = new Identifier(t.toString()); |
| 1137 | return new TypeReferenceExpression(id); |
| 1138 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | OrderedListTypeDefinition OrderedListTypeDef() throws ParseException: |
| 1142 | { |
| 1143 | TypeExpression type = null; |
| 1144 | } |
| 1145 | { |
| 1146 | "[" |
| 1147 | ( type = TypeExpr() ) |
| 1148 | "]" |
| 1149 | { |
| 1150 | return new OrderedListTypeDefinition(type); |
| 1151 | } |
| 1152 | } |
| 1153 | |
| 1154 | |
| 1155 | UnorderedListTypeDefinition UnorderedListTypeDef() throws ParseException: |
| 1156 | { |
| 1157 | TypeExpression type = null; |
| 1158 | } |
| 1159 | { |
| 1160 | "{{" |
| 1161 | ( type = TypeExpr() ) |
| 1162 | "}}" |
| 1163 | { |
| 1164 | return new UnorderedListTypeDefinition(type); |
| 1165 | } |
| 1166 | } |
| 1167 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1168 | Pair<Identifier,Identifier> getDotSeparatedPair() throws ParseException: |
| 1169 | { |
| 1170 | Identifier first = null; |
| 1171 | Identifier second = null; |
| 1172 | } |
| 1173 | { |
| 1174 | < IDENTIFIER > |
| 1175 | { |
| 1176 | first = new Identifier(token.image); |
| 1177 | } |
| 1178 | ("." <IDENTIFIER> |
| 1179 | { |
| 1180 | second = new Identifier(token.image); |
| 1181 | } |
| 1182 | )? |
| 1183 | |
| 1184 | { |
| 1185 | if(second == null){ |
| 1186 | second = first; |
| 1187 | first = null; |
| 1188 | } |
| 1189 | |
| 1190 | return new Pair<Identifier,Identifier>(first,second); |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | Triple<Identifier,Identifier,Identifier> getDotSeparatedTriple() throws ParseException: |
| 1195 | { |
| 1196 | Identifier first = null; |
| 1197 | Identifier second = null; |
| 1198 | Identifier third = null; |
| 1199 | } |
| 1200 | { |
| 1201 | < IDENTIFIER > |
| 1202 | { |
| 1203 | first = new Identifier(token.image); |
| 1204 | } |
| 1205 | "." <IDENTIFIER> |
| 1206 | { |
| 1207 | second = new Identifier(token.image); |
| 1208 | } |
| 1209 | ( |
| 1210 | "." <IDENTIFIER> |
| 1211 | { |
| 1212 | third = new Identifier(token.image); |
| 1213 | } |
| 1214 | )? |
| 1215 | |
| 1216 | { |
| 1217 | if(third == null){ |
| 1218 | third = second; |
| 1219 | second = first; |
| 1220 | first = null; |
| 1221 | } |
| 1222 | |
| 1223 | return new Triple<Identifier,Identifier,Identifier>(first,second,third); |
| 1224 | } |
| 1225 | } |
| 1226 | |
| 1227 | |
| 1228 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1229 | |
| 1230 | FunctionDecl FunctionDeclaration() throws ParseException: |
| 1231 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1232 | FunctionDecl funcDecl; |
| 1233 | FunctionSignature signature; |
ramangrover29 | a13f242 | 2012-03-15 23:01:27 +0000 | [diff] [blame] | 1234 | String functionName; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1235 | int arity = 0; |
| 1236 | List<VarIdentifier> paramList = new ArrayList<VarIdentifier>(); |
| 1237 | Expression funcBody; |
| 1238 | VarIdentifier var = null; |
| 1239 | createNewScope(); |
| 1240 | } |
| 1241 | { |
| 1242 | |
| 1243 | <IDENTIFIER> |
| 1244 | { |
| 1245 | Token t = getToken(0); |
ramangrover29 | a13f242 | 2012-03-15 23:01:27 +0000 | [diff] [blame] | 1246 | functionName = t.toString(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1247 | } |
| 1248 | <LEFTPAREN> (<VARIABLE> |
| 1249 | { |
| 1250 | var = new VarIdentifier(); |
| 1251 | var.setValue(getToken(0).toString()); |
| 1252 | paramList.add(var); |
| 1253 | getCurrentScope().addNewVarSymbolToScope(var); |
| 1254 | arity++; |
| 1255 | } |
| 1256 | ("," <VARIABLE> |
| 1257 | { |
| 1258 | var = new VarIdentifier(); |
| 1259 | var.setValue(getToken(0).toString()); |
| 1260 | paramList.add(var); |
| 1261 | getCurrentScope().addNewVarSymbolToScope(var); |
| 1262 | arity++; |
| 1263 | })*)? <RIGHTPAREN> "{" funcBody = Expression() "}" |
| 1264 | |
| 1265 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1266 | signature = new FunctionSignature(defaultDataverse, functionName, arity); |
| 1267 | getCurrentScope().addFunctionDescriptor(signature, false); |
| 1268 | funcDecl = new FunctionDecl(signature, paramList, funcBody); |
| 1269 | return funcDecl; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1270 | } |
| 1271 | } |
| 1272 | |
| 1273 | CreateFunctionStatement FunctionCreation() throws ParseException: |
| 1274 | { |
| 1275 | CreateFunctionStatement cfs = null; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1276 | FunctionSignature signature; |
| 1277 | String dataverse; |
ramangrover29 | a13f242 | 2012-03-15 23:01:27 +0000 | [diff] [blame] | 1278 | String functionName; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1279 | boolean ifNotExists = false; |
| 1280 | List<VarIdentifier> paramList = new ArrayList<VarIdentifier>(); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1281 | String functionBody; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1282 | VarIdentifier var = null; |
| 1283 | createNewScope(); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1284 | Expression functionBodyExpr; |
| 1285 | Token beginPos; |
| 1286 | Token endPos; |
| 1287 | Pair<Identifier,Identifier> nameComponents=null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1288 | } |
| 1289 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1290 | { |
| 1291 | nameComponents = getDotSeparatedPair(); |
| 1292 | dataverse = nameComponents.first != null ? nameComponents.first.getValue() : defaultDataverse; |
| 1293 | functionName= nameComponents.second.getValue(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1294 | } |
| 1295 | |
| 1296 | ( |
| 1297 | "if not exists" |
| 1298 | { |
| 1299 | ifNotExists = true; |
| 1300 | } |
| 1301 | )? |
| 1302 | |
| 1303 | <LEFTPAREN> (<VARIABLE> |
| 1304 | { |
| 1305 | var = new VarIdentifier(); |
| 1306 | var.setValue(getToken(0).toString()); |
| 1307 | paramList.add(var); |
| 1308 | getCurrentScope().addNewVarSymbolToScope(var); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1309 | } |
| 1310 | ("," <VARIABLE> |
| 1311 | { |
| 1312 | var = new VarIdentifier(); |
| 1313 | var.setValue(getToken(0).toString()); |
| 1314 | paramList.add(var); |
| 1315 | getCurrentScope().addNewVarSymbolToScope(var); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1316 | })*)? <RIGHTPAREN> "{" |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1317 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1318 | beginPos = getToken(0); |
| 1319 | } |
| 1320 | functionBodyExpr = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1321 | "}" |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1322 | { |
| 1323 | endPos = getToken(0); |
| 1324 | functionBody = extractFragment(beginPos.beginLine, beginPos.beginColumn, endPos.beginLine, endPos.beginColumn); |
| 1325 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1326 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1327 | signature = new FunctionSignature(dataverse, functionName, paramList.size()); |
| 1328 | getCurrentScope().addFunctionDescriptor(signature, false); |
| 1329 | cfs = new CreateFunctionStatement(signature, paramList, functionBody, ifNotExists); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1330 | return cfs; |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | |
| 1335 | |
| 1336 | Query Query()throws ParseException: |
| 1337 | { |
| 1338 | Query query = new Query(); |
| 1339 | Expression expr; |
| 1340 | } |
| 1341 | { |
| 1342 | expr = Expression() |
RamanGrover29@gmail.com | c022a0d | 2012-07-28 05:13:44 +0000 | [diff] [blame] | 1343 | (";")? |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1344 | { |
| 1345 | query.setBody(expr); |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1346 | query.setVarCounter(getVarCounter()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1347 | return query; |
| 1348 | } |
RamanGrover29@gmail.com | c022a0d | 2012-07-28 05:13:44 +0000 | [diff] [blame] | 1349 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1350 | } |
| 1351 | |
| 1352 | |
| 1353 | |
| 1354 | Expression Expression(): |
| 1355 | { |
| 1356 | Expression expr = null; |
| 1357 | Expression exprP = null; |
| 1358 | } |
| 1359 | { |
| 1360 | ( |
| 1361 | |
| 1362 | //OperatorExpr | IfThenElse | FLWOGRExpression | QuantifiedExpression |
| 1363 | expr = OperatorExpr() |
| 1364 | | expr = IfThenElse() |
| 1365 | | expr = FLWOGR() |
| 1366 | | expr = QuantifiedExpression() |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1367 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1368 | |
| 1369 | ) |
| 1370 | { |
| 1371 | return (exprP==null) ? expr : exprP; |
| 1372 | } |
| 1373 | } |
| 1374 | |
| 1375 | |
| 1376 | |
| 1377 | Expression OperatorExpr()throws ParseException: |
| 1378 | { |
| 1379 | OperatorExpr op = null; |
| 1380 | Expression operand = null; |
| 1381 | } |
| 1382 | { |
| 1383 | operand = AndExpr() |
| 1384 | ( |
| 1385 | |
| 1386 | "or" |
| 1387 | { |
| 1388 | if (op == null) { |
| 1389 | op = new OperatorExpr(); |
| 1390 | op.addOperand(operand); |
| 1391 | op.setCurrentop(true); |
| 1392 | } |
| 1393 | Token t = getToken(0); |
| 1394 | op.addOperator(t.toString()); |
| 1395 | } |
| 1396 | |
| 1397 | operand = AndExpr() |
| 1398 | { |
| 1399 | op.addOperand(operand); |
| 1400 | } |
| 1401 | |
| 1402 | )* |
| 1403 | |
| 1404 | { |
| 1405 | return op==null? operand: op; |
| 1406 | } |
| 1407 | } |
| 1408 | |
| 1409 | Expression AndExpr()throws ParseException: |
| 1410 | { |
| 1411 | OperatorExpr op = null; |
| 1412 | Expression operand = null; |
| 1413 | } |
| 1414 | { |
| 1415 | operand = RelExpr() |
| 1416 | ( |
| 1417 | |
| 1418 | "and" |
| 1419 | { |
| 1420 | if (op == null) { |
| 1421 | op = new OperatorExpr(); |
| 1422 | op.addOperand(operand); |
| 1423 | op.setCurrentop(true); |
| 1424 | } |
| 1425 | Token t = getToken(0); |
| 1426 | op.addOperator(t.toString()); |
| 1427 | } |
| 1428 | |
| 1429 | operand = RelExpr() |
| 1430 | { |
| 1431 | op.addOperand(operand); |
| 1432 | } |
| 1433 | |
| 1434 | )* |
| 1435 | |
| 1436 | { |
| 1437 | return op==null? operand: op; |
| 1438 | } |
| 1439 | } |
| 1440 | |
| 1441 | |
| 1442 | |
| 1443 | Expression RelExpr()throws ParseException: |
| 1444 | { |
| 1445 | OperatorExpr op = null; |
| 1446 | Expression operand = null; |
| 1447 | boolean broadcast = false; |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1448 | IExpressionAnnotation annotation = null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1449 | } |
| 1450 | { |
| 1451 | operand = AddExpr() |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1452 | { |
| 1453 | if (operand instanceof VariableExpr) { |
| 1454 | String hint = getHint(token); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1455 | if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) { |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1456 | broadcast = true; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1457 | } |
| 1458 | } |
| 1459 | } |
| 1460 | |
| 1461 | ( |
| 1462 | LOOKAHEAD(2)( "<" | ">" | "<=" | ">=" | "=" | "!=" |"~=") |
| 1463 | { |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1464 | String mhint = getHint(token); |
| 1465 | if (mhint != null && mhint.equals(INDEXED_NESTED_LOOP_JOIN_HINT)) { |
| 1466 | annotation = IndexedNLJoinExpressionAnnotation.INSTANCE; |
| 1467 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1468 | if (op == null) { |
| 1469 | op = new OperatorExpr(); |
| 1470 | op.addOperand(operand, broadcast); |
| 1471 | op.setCurrentop(true); |
| 1472 | broadcast = false; |
| 1473 | } |
| 1474 | Token t = getToken(0); |
| 1475 | op.addOperator(t.toString()); |
| 1476 | } |
| 1477 | |
| 1478 | operand = AddExpr() |
| 1479 | { |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1480 | broadcast = false; |
| 1481 | if (operand instanceof VariableExpr) { |
| 1482 | String hint = getHint(token); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1483 | if (hint != null && hint.equals(BROADCAST_JOIN_HINT)) { |
| 1484 | broadcast = true; |
| 1485 | } |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1486 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1487 | op.addOperand(operand, broadcast); |
| 1488 | } |
| 1489 | )? |
| 1490 | |
| 1491 | { |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1492 | if (annotation != null) { |
| 1493 | op.addHint(annotation); |
| 1494 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1495 | return op==null? operand: op; |
| 1496 | } |
| 1497 | } |
| 1498 | |
| 1499 | Expression AddExpr()throws ParseException: |
| 1500 | { |
| 1501 | OperatorExpr op = null; |
| 1502 | Expression operand = null; |
| 1503 | } |
| 1504 | { |
| 1505 | operand = MultExpr() |
| 1506 | |
| 1507 | ( ("+" | "-") |
| 1508 | { |
| 1509 | if (op == null) { |
| 1510 | op = new OperatorExpr(); |
| 1511 | op.addOperand(operand); |
| 1512 | op.setCurrentop(true); |
| 1513 | } |
| 1514 | Token t = getToken(0); |
| 1515 | ((OperatorExpr)op).addOperator(t.toString()); |
| 1516 | } |
| 1517 | |
| 1518 | operand = MultExpr() |
| 1519 | { |
| 1520 | op.addOperand(operand); |
| 1521 | } |
| 1522 | )* |
| 1523 | |
| 1524 | { |
| 1525 | return op==null? operand: op; |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | Expression MultExpr()throws ParseException: |
| 1530 | { |
| 1531 | OperatorExpr op = null; |
| 1532 | Expression operand = null; |
| 1533 | } |
| 1534 | { |
| 1535 | operand = UnionExpr() |
| 1536 | |
| 1537 | (( "*" | "/" | "%" | <CARET> | "idiv") |
| 1538 | { |
| 1539 | if (op == null) { |
| 1540 | op = new OperatorExpr(); |
| 1541 | op.addOperand(operand); |
| 1542 | op.setCurrentop(true); |
| 1543 | } |
| 1544 | Token t = getToken(0); |
| 1545 | op.addOperator(t.toString()); |
| 1546 | } |
| 1547 | operand = UnionExpr() |
| 1548 | { |
| 1549 | op.addOperand(operand); |
| 1550 | } |
| 1551 | )* |
| 1552 | |
| 1553 | { |
| 1554 | return op==null?operand:op; |
| 1555 | } |
| 1556 | } |
| 1557 | |
| 1558 | Expression UnionExpr() throws ParseException: |
| 1559 | { |
| 1560 | UnionExpr union = null; |
| 1561 | Expression operand1 = null; |
| 1562 | Expression operand2 = null; |
| 1563 | } |
| 1564 | { |
| 1565 | operand1 = UnaryExpr() |
| 1566 | ("union" |
| 1567 | (operand2 = UnaryExpr()) { |
| 1568 | if (union == null) { |
| 1569 | union = new UnionExpr(); |
| 1570 | union.addExpr(operand1); |
| 1571 | } |
| 1572 | union.addExpr(operand2); |
| 1573 | } )* |
| 1574 | { |
| 1575 | return (union == null)? operand1: union; |
| 1576 | } |
| 1577 | } |
| 1578 | |
| 1579 | Expression UnaryExpr() throws ParseException: |
| 1580 | { |
| 1581 | Expression uexpr = null; |
| 1582 | Expression expr = null; |
| 1583 | } |
| 1584 | { |
| 1585 | (( "+"|"-") |
| 1586 | { |
| 1587 | uexpr = new UnaryExpr(); |
| 1588 | Token t = getToken(0); |
| 1589 | if("+".equals(t.toString())) |
| 1590 | ((UnaryExpr)uexpr).setSign(Sign.POSITIVE); |
| 1591 | else if("-".equals(t.toString())) |
| 1592 | ((UnaryExpr)uexpr).setSign(Sign.NEGATIVE); |
| 1593 | else |
| 1594 | throw new ParseException(); |
| 1595 | } |
| 1596 | )? |
| 1597 | |
| 1598 | expr = ValueExpr() |
| 1599 | { |
| 1600 | if(uexpr!=null){ |
| 1601 | ((UnaryExpr)uexpr).setExpr(expr); |
| 1602 | return uexpr; |
| 1603 | } |
| 1604 | else{ |
| 1605 | return expr; |
| 1606 | } |
| 1607 | } |
| 1608 | } |
| 1609 | |
| 1610 | Expression ValueExpr() throws ParseException: |
| 1611 | { |
| 1612 | Expression expr; |
| 1613 | } |
| 1614 | { |
| 1615 | expr = FieldOrIndexAccessor() |
| 1616 | { |
| 1617 | return expr; |
| 1618 | } |
| 1619 | } |
| 1620 | |
| 1621 | |
| 1622 | Expression FieldOrIndexAccessor()throws ParseException: |
| 1623 | { |
| 1624 | Expression expr = null; |
| 1625 | Identifier ident = null; |
| 1626 | AbstractAccessor fa = null; |
| 1627 | int index; |
| 1628 | |
| 1629 | } |
| 1630 | { |
| 1631 | ( expr = PrimaryExpr() |
| 1632 | |
| 1633 | ) |
| 1634 | |
| 1635 | |
| 1636 | ( |
| 1637 | ( |
| 1638 | ident = Field() |
| 1639 | { |
| 1640 | if(fa == null) |
| 1641 | fa = new FieldAccessor(expr, ident); |
| 1642 | else |
| 1643 | fa = new FieldAccessor(fa, ident); |
| 1644 | } |
| 1645 | ) |
| 1646 | | ( |
| 1647 | index = Index() |
| 1648 | { |
| 1649 | if(fa == null) |
| 1650 | fa = new IndexAccessor(expr, index); |
| 1651 | else |
| 1652 | fa = new IndexAccessor(fa, index); |
| 1653 | } |
| 1654 | ) |
| 1655 | )* |
| 1656 | |
| 1657 | |
| 1658 | { |
| 1659 | return fa==null?expr:fa; |
| 1660 | } |
| 1661 | } |
| 1662 | |
| 1663 | Identifier Field() throws ParseException: |
| 1664 | { |
| 1665 | Identifier ident = null; |
| 1666 | |
| 1667 | } |
| 1668 | { |
| 1669 | "." < IDENTIFIER > |
| 1670 | { |
| 1671 | |
| 1672 | ident = new Identifier(); |
| 1673 | ident.setValue(getToken(0).toString()); |
| 1674 | |
| 1675 | return ident; |
| 1676 | } |
| 1677 | } |
| 1678 | |
| 1679 | int Index() throws ParseException: |
| 1680 | { |
| 1681 | Expression expr = null; |
| 1682 | int idx = -2; |
| 1683 | } |
| 1684 | { |
| 1685 | "[" ( expr = Expression() |
| 1686 | { |
| 1687 | if(expr.getKind() == Expression.Kind.LITERAL_EXPRESSION) |
| 1688 | { |
ilovesoup | c9fef1d | 2012-07-08 19:30:42 +0000 | [diff] [blame] | 1689 | Literal lit = ((LiteralExpr)expr).getValue(); |
| 1690 | if(lit.getLiteralType() == Literal.Type.INTEGER || |
| 1691 | lit.getLiteralType() == Literal.Type.LONG) { |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1692 | idx = Integer.valueOf(lit.getStringValue()); |
ilovesoup | c9fef1d | 2012-07-08 19:30:42 +0000 | [diff] [blame] | 1693 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1694 | else { |
| 1695 | throw new ParseException("Index should be an INTEGER"); |
| 1696 | } |
| 1697 | } |
| 1698 | |
| 1699 | } |
| 1700 | |
| 1701 | | "?" |
| 1702 | { |
| 1703 | idx = IndexAccessor.ANY; |
| 1704 | // ANY |
| 1705 | } |
| 1706 | |
| 1707 | ) |
| 1708 | |
| 1709 | "]" |
| 1710 | { |
| 1711 | return idx; |
| 1712 | } |
| 1713 | } |
| 1714 | |
| 1715 | |
| 1716 | Expression PrimaryExpr()throws ParseException: |
| 1717 | { |
| 1718 | Expression expr = null; |
| 1719 | } |
| 1720 | { |
ilovesoup | c9fef1d | 2012-07-08 19:30:42 +0000 | [diff] [blame] | 1721 | //Literal | VariableRef | ListConstructor | RecordConstructor | FunctionCallExpr | ParenthesizedExpression |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1722 | ( |
| 1723 | expr =Literal() |
| 1724 | | expr = FunctionCallExpr() |
| 1725 | | expr =VariableRef() |
| 1726 | |
| 1727 | { |
| 1728 | if(((VariableExpr)expr).getIsNewVar() == true) |
| 1729 | throw new ParseException("can't find variable " + ((VariableExpr)expr).getVar()); |
| 1730 | } |
| 1731 | | expr = ListConstructor() |
| 1732 | | expr = RecordConstructor() |
| 1733 | | expr = ParenthesizedExpression() |
| 1734 | ) |
| 1735 | { |
| 1736 | return expr; |
| 1737 | } |
| 1738 | } |
| 1739 | |
| 1740 | Expression Literal() throws ParseException: |
| 1741 | { |
| 1742 | |
| 1743 | LiteralExpr lit = new LiteralExpr(); |
| 1744 | Token t; |
| 1745 | } |
| 1746 | { |
| 1747 | ( |
| 1748 | <STRING_LITERAL> |
| 1749 | { |
| 1750 | t= getToken(0); |
| 1751 | lit.setValue( new StringLiteral(removeQuotesAndEscapes(t.image))); |
| 1752 | } |
| 1753 | |
| 1754 | | <INTEGER_LITERAL> |
| 1755 | { |
| 1756 | t= getToken(0); |
ilovesoup | c9fef1d | 2012-07-08 19:30:42 +0000 | [diff] [blame] | 1757 | try { |
| 1758 | lit.setValue(new IntegerLiteral(new Integer(t.image))); |
| 1759 | } catch(NumberFormatException ex) { |
| 1760 | lit.setValue(new LongIntegerLiteral(new Long(t.image))); |
| 1761 | } |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1762 | } |
| 1763 | | < FLOAT_LITERAL > |
| 1764 | { |
| 1765 | t= getToken(0); |
| 1766 | lit.setValue(new FloatLiteral(new Float(t.image))); |
| 1767 | } |
| 1768 | | < DOUBLE_LITERAL > |
| 1769 | { |
| 1770 | t= getToken(0); |
| 1771 | lit.setValue(new DoubleLiteral(new Double(t.image))); |
| 1772 | } |
| 1773 | | <NULL> |
| 1774 | { |
| 1775 | t= getToken(0); |
| 1776 | lit.setValue(NullLiteral.INSTANCE); |
| 1777 | } |
| 1778 | | <TRUE> |
| 1779 | { |
| 1780 | t= getToken(0); |
| 1781 | lit.setValue(TrueLiteral.INSTANCE); |
| 1782 | } |
| 1783 | | <FALSE> |
| 1784 | { |
| 1785 | t= getToken(0); |
| 1786 | lit.setValue(FalseLiteral.INSTANCE); |
| 1787 | } |
| 1788 | ) |
| 1789 | { |
| 1790 | return lit; |
| 1791 | } |
| 1792 | } |
| 1793 | |
| 1794 | |
| 1795 | VariableExpr VariableRef() throws ParseException: |
| 1796 | { |
| 1797 | VariableExpr varExp = new VariableExpr(); |
| 1798 | VarIdentifier var = new VarIdentifier(); |
| 1799 | Token t; |
| 1800 | } |
| 1801 | { |
| 1802 | <VARIABLE> |
| 1803 | { |
| 1804 | t = getToken(0);//get current token |
| 1805 | String varName = t.toString(); |
| 1806 | Identifier ident = lookupSymbol(varName); |
| 1807 | if (isInForbiddenScopes(varName)) { |
| 1808 | 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."); |
| 1809 | } |
| 1810 | if(ident != null) { // exist such ident |
| 1811 | varExp.setIsNewVar(false); |
| 1812 | varExp.setVar((VarIdentifier)ident); |
| 1813 | } else { |
| 1814 | varExp.setVar(var); |
| 1815 | } |
| 1816 | var.setValue(t.toString()); |
| 1817 | return varExp; |
| 1818 | } |
| 1819 | } |
| 1820 | |
| 1821 | |
| 1822 | VariableExpr Variable() throws ParseException: |
| 1823 | { |
| 1824 | VariableExpr varExp = new VariableExpr(); |
| 1825 | VarIdentifier var = new VarIdentifier(); |
| 1826 | Token t; |
| 1827 | } |
| 1828 | { |
| 1829 | <VARIABLE> |
| 1830 | { |
| 1831 | t = getToken(0);//get current token |
| 1832 | Identifier ident = lookupSymbol(t.toString()); |
| 1833 | if(ident != null) { // exist such ident |
| 1834 | varExp.setIsNewVar(false); |
| 1835 | } |
| 1836 | varExp.setVar(var); |
| 1837 | var.setValue(t.toString()); |
| 1838 | return varExp; |
| 1839 | } |
| 1840 | } |
| 1841 | |
| 1842 | Expression ListConstructor() throws ParseException: |
| 1843 | { |
| 1844 | Expression expr = null; |
| 1845 | } |
| 1846 | { |
| 1847 | ( |
| 1848 | expr = OrderedListConstructor() | expr = UnorderedListConstructor() |
| 1849 | ) |
| 1850 | |
| 1851 | { |
| 1852 | return expr; |
| 1853 | } |
| 1854 | } |
| 1855 | |
| 1856 | |
| 1857 | ListConstructor OrderedListConstructor() throws ParseException: |
| 1858 | { |
| 1859 | ListConstructor expr = new ListConstructor(); |
| 1860 | Expression tmp = null; |
| 1861 | List<Expression> exprList = new ArrayList<Expression>(); |
| 1862 | expr.setType(ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR); |
| 1863 | } |
| 1864 | { |
| 1865 | |
| 1866 | "[" |
| 1867 | ( tmp = Expression() |
| 1868 | { |
| 1869 | exprList.add(tmp); |
| 1870 | } |
| 1871 | |
| 1872 | ("," tmp = Expression() { exprList.add(tmp); })* |
| 1873 | )? |
| 1874 | |
| 1875 | "]" |
| 1876 | |
| 1877 | { |
| 1878 | expr.setExprList(exprList); |
| 1879 | return expr; |
| 1880 | } |
| 1881 | } |
| 1882 | |
| 1883 | ListConstructor UnorderedListConstructor() throws ParseException: |
| 1884 | { |
| 1885 | ListConstructor expr = new ListConstructor(); |
| 1886 | Expression tmp = null; |
| 1887 | List<Expression> exprList = new ArrayList<Expression>(); |
| 1888 | expr.setType(ListConstructor.Type.UNORDERED_LIST_CONSTRUCTOR); |
| 1889 | } |
| 1890 | { |
| 1891 | |
| 1892 | "{{" ( tmp = Expression() |
| 1893 | { |
| 1894 | exprList.add(tmp); |
| 1895 | } |
| 1896 | ("," tmp = Expression() { exprList.add(tmp); })*)? "}}" |
| 1897 | { |
| 1898 | expr.setExprList(exprList); |
| 1899 | return expr; |
| 1900 | } |
| 1901 | } |
| 1902 | |
| 1903 | RecordConstructor RecordConstructor() throws ParseException: |
| 1904 | { |
| 1905 | RecordConstructor expr = new RecordConstructor(); |
| 1906 | FieldBinding tmp = null; |
| 1907 | List<FieldBinding> fbList = new ArrayList<FieldBinding>(); |
| 1908 | } |
| 1909 | { |
| 1910 | "{" (tmp = FieldBinding() |
| 1911 | { |
| 1912 | fbList.add(tmp); |
| 1913 | } |
| 1914 | ("," tmp = FieldBinding() { fbList.add(tmp); })*)? "}" |
| 1915 | { |
| 1916 | expr.setFbList(fbList); |
| 1917 | return expr; |
| 1918 | } |
| 1919 | } |
| 1920 | |
| 1921 | FieldBinding FieldBinding() throws ParseException: |
| 1922 | { |
| 1923 | FieldBinding fb = new FieldBinding(); |
| 1924 | Expression left, right; |
| 1925 | } |
| 1926 | { |
| 1927 | left = Expression() ":" right = Expression() |
| 1928 | { |
| 1929 | fb.setLeftExpr(left); |
| 1930 | fb.setRightExpr(right); |
| 1931 | return fb; |
| 1932 | } |
| 1933 | } |
| 1934 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1935 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1936 | Expression FunctionCallExpr() throws ParseException: |
| 1937 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1938 | CallExpr callExpr; |
alexander.behm | 07617fd | 2012-07-25 10:13:50 +0000 | [diff] [blame] | 1939 | List<Expression> argList = new ArrayList<Expression>(); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1940 | Expression tmp; |
| 1941 | int arity = 0; |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1942 | String funcName; |
| 1943 | String dataverse; |
| 1944 | String hint=null; |
| 1945 | String id1=null; |
| 1946 | String id2=null; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1947 | } |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1948 | { |
| 1949 | ( <IDENTIFIER> { dataverse = defaultDataverse; funcName = token.image;} ("." <IDENTIFIER> { dataverse = funcName; funcName = token.image;})? | <DATASET> {dataverse = MetadataConstants.METADATA_DATAVERSE_NAME; funcName = getToken(0).toString();}) |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1950 | { |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1951 | hint = getHint(token); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1952 | } |
| 1953 | <LEFTPAREN> (tmp = Expression() |
| 1954 | { |
| 1955 | argList.add(tmp); |
| 1956 | arity ++; |
| 1957 | } ("," tmp = Expression() { argList.add(tmp); arity++; })*)? <RIGHTPAREN> |
| 1958 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1959 | { |
| 1960 | FunctionSignature signature = lookupFunctionSignature(dataverse, funcName.toString(), arity); |
| 1961 | if(signature == null) |
| 1962 | { |
| 1963 | signature = new FunctionSignature(dataverse, funcName.toString(), arity); |
| 1964 | } |
| 1965 | callExpr = new CallExpr(signature,argList); |
| 1966 | if (hint != null && hint.startsWith(INDEXED_NESTED_LOOP_JOIN_HINT)) { |
| 1967 | callExpr.addHint(IndexedNLJoinExpressionAnnotation.INSTANCE); |
| 1968 | } |
| 1969 | return callExpr; |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1970 | } |
| 1971 | } |
| 1972 | |
| 1973 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 1974 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1975 | Expression ParenthesizedExpression() throws ParseException: |
| 1976 | { |
| 1977 | Expression expr; |
| 1978 | } |
| 1979 | { |
| 1980 | <LEFTPAREN> expr = Expression() <RIGHTPAREN> |
| 1981 | { |
| 1982 | return expr; |
| 1983 | } |
| 1984 | } |
| 1985 | |
| 1986 | Expression IfThenElse() throws ParseException: |
| 1987 | { |
| 1988 | Expression condExpr; |
| 1989 | Expression thenExpr; |
| 1990 | Expression elseExpr; |
| 1991 | IfExpr ifExpr = new IfExpr(); |
| 1992 | } |
| 1993 | { |
| 1994 | "if" <LEFTPAREN> condExpr = Expression() <RIGHTPAREN> "then" thenExpr = Expression() "else" elseExpr = Expression() |
| 1995 | |
| 1996 | { |
| 1997 | ifExpr.setCondExpr(condExpr); |
| 1998 | ifExpr.setThenExpr(thenExpr); |
| 1999 | ifExpr.setElseExpr(elseExpr); |
| 2000 | return ifExpr; |
| 2001 | } |
| 2002 | } |
| 2003 | |
| 2004 | Expression FLWOGR() throws ParseException: |
| 2005 | { |
| 2006 | FLWOGRExpression flworg = new FLWOGRExpression(); |
| 2007 | List<Clause> clauseList = new ArrayList<Clause>(); |
| 2008 | Expression returnExpr; |
| 2009 | Clause tmp; |
| 2010 | createNewScope(); |
| 2011 | } |
| 2012 | { |
| 2013 | (tmp = ForClause() {clauseList.add(tmp);} | tmp = LetClause() {clauseList.add(tmp);}) |
| 2014 | (tmp = Clause() {clauseList.add(tmp);})* "return" returnExpr = Expression() |
| 2015 | |
| 2016 | { |
| 2017 | flworg.setClauseList(clauseList); |
| 2018 | flworg.setReturnExpr(returnExpr); |
| 2019 | removeCurrentScope(); |
| 2020 | return flworg; |
| 2021 | } |
| 2022 | } |
| 2023 | |
| 2024 | Clause Clause()throws ParseException : |
| 2025 | { |
| 2026 | Clause clause; |
| 2027 | } |
| 2028 | { |
| 2029 | ( |
| 2030 | clause = ForClause() |
| 2031 | | clause = LetClause() |
| 2032 | | clause = WhereClause() |
| 2033 | | clause = OrderbyClause() |
| 2034 | | clause = GroupClause() |
| 2035 | | clause = LimitClause() |
| 2036 | | clause = DistinctClause() |
| 2037 | | clause = DieClause() |
| 2038 | ) |
| 2039 | { |
| 2040 | return clause; |
| 2041 | } |
| 2042 | } |
| 2043 | |
| 2044 | Clause ForClause()throws ParseException : |
| 2045 | { |
| 2046 | ForClause fc = new ForClause(); |
| 2047 | VariableExpr varExp; |
| 2048 | VariableExpr varPos = null; |
| 2049 | Expression inExp; |
| 2050 | extendCurrentScope(); |
| 2051 | } |
| 2052 | { |
| 2053 | "for" varExp = Variable() |
| 2054 | { |
| 2055 | getCurrentScope().addNewVarSymbolToScope(varExp.getVar()); |
| 2056 | } |
| 2057 | ("at" varPos = Variable() |
| 2058 | { |
| 2059 | getCurrentScope().addNewVarSymbolToScope(varPos.getVar()); |
| 2060 | } |
| 2061 | )? |
| 2062 | "in" ( inExp = Expression() ) |
| 2063 | { |
| 2064 | fc.setVarExpr(varExp); |
| 2065 | fc.setInExpr(inExp); |
| 2066 | if (varPos != null) { |
| 2067 | fc.setPosExpr(varPos); |
| 2068 | } |
| 2069 | return fc; |
| 2070 | } |
| 2071 | } |
| 2072 | |
| 2073 | Clause LetClause() throws ParseException: |
| 2074 | { |
| 2075 | LetClause lc = new LetClause(); |
| 2076 | VariableExpr varExp; |
| 2077 | Expression beExp; |
| 2078 | extendCurrentScope(); |
| 2079 | } |
| 2080 | { |
ilovesoup | b2527c1 | 2012-07-12 03:21:13 +0000 | [diff] [blame] | 2081 | "let" varExp = Variable() ":=" beExp = Expression() |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2082 | { |
| 2083 | getCurrentScope().addNewVarSymbolToScope(varExp.getVar()); |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2084 | lc.setVarExpr(varExp); |
| 2085 | lc.setBeExpr(beExp); |
| 2086 | return lc; |
| 2087 | } |
| 2088 | } |
| 2089 | |
| 2090 | Clause WhereClause()throws ParseException : |
| 2091 | { |
| 2092 | WhereClause wc = new WhereClause(); |
| 2093 | Expression whereExpr; |
| 2094 | } |
| 2095 | { |
| 2096 | "where" whereExpr = Expression() |
| 2097 | { |
| 2098 | wc.setWhereExpr(whereExpr); |
| 2099 | return wc; |
| 2100 | } |
| 2101 | } |
| 2102 | |
| 2103 | Clause OrderbyClause()throws ParseException : |
| 2104 | { |
| 2105 | OrderbyClause oc = new OrderbyClause(); |
| 2106 | Expression orderbyExpr; |
| 2107 | List<Expression> orderbyList = new ArrayList<Expression>(); |
| 2108 | List<OrderbyClause.OrderModifier> modifierList = new ArrayList<OrderbyClause.OrderModifier >(); |
| 2109 | int numOfOrderby = 0; |
| 2110 | } |
| 2111 | { |
| 2112 | ( |
| 2113 | "order" |
| 2114 | { |
| 2115 | String hint = getHint(token); |
| 2116 | if (hint != null && hint.startsWith(INMEMORY_HINT)) { |
| 2117 | String splits[] = hint.split(" +"); |
| 2118 | int numFrames = Integer.parseInt(splits[1]); |
| 2119 | int numTuples = Integer.parseInt(splits[2]); |
| 2120 | oc.setNumFrames(numFrames); |
| 2121 | oc.setNumTuples(numTuples); |
| 2122 | } |
| 2123 | } |
| 2124 | "by" orderbyExpr = Expression() |
| 2125 | { |
| 2126 | orderbyList.add(orderbyExpr); |
| 2127 | OrderbyClause.OrderModifier modif = OrderbyClause.OrderModifier.ASC; |
| 2128 | } |
| 2129 | ( ("asc" { modif = OrderbyClause.OrderModifier.ASC; }) |
| 2130 | | ("desc" { modif = OrderbyClause.OrderModifier.DESC; }))? |
| 2131 | { |
| 2132 | modifierList.add(modif); |
| 2133 | } |
| 2134 | |
| 2135 | ("," orderbyExpr = Expression() |
| 2136 | { |
| 2137 | orderbyList.add(orderbyExpr); |
| 2138 | modif = OrderbyClause.OrderModifier.ASC; |
| 2139 | } |
| 2140 | ( ("asc" { modif = OrderbyClause.OrderModifier.ASC; }) |
| 2141 | | ("desc" { modif = OrderbyClause.OrderModifier.DESC; }))? |
| 2142 | { |
| 2143 | modifierList.add(modif); |
| 2144 | } |
| 2145 | )* |
| 2146 | ) |
| 2147 | { |
| 2148 | oc.setModifierList(modifierList); |
| 2149 | oc.setOrderbyList(orderbyList); |
| 2150 | return oc; |
| 2151 | } |
| 2152 | } |
| 2153 | Clause GroupClause()throws ParseException : |
| 2154 | { |
| 2155 | GroupbyClause gbc = new GroupbyClause(); |
| 2156 | // GbyVariableExpressionPair pair = new GbyVariableExpressionPair(); |
| 2157 | List<GbyVariableExpressionPair> vePairList = new ArrayList<GbyVariableExpressionPair>(); |
| 2158 | List<GbyVariableExpressionPair> decorPairList = new ArrayList<GbyVariableExpressionPair>(); |
| 2159 | List<VariableExpr> withVarList= new ArrayList<VariableExpr>(); |
| 2160 | VariableExpr var = null; |
| 2161 | VariableExpr withVar = null; |
| 2162 | Expression expr = null; |
| 2163 | VariableExpr decorVar = null; |
| 2164 | Expression decorExpr = null; |
| 2165 | } |
| 2166 | { |
| 2167 | { |
| 2168 | Scope newScope = extendCurrentScopeNoPush(true); |
| 2169 | // extendCurrentScope(true); |
| 2170 | } |
| 2171 | "group" |
| 2172 | { |
| 2173 | String hint = getHint(token); |
| 2174 | if (hint != null && hint.equals(HASH_GROUP_BY_HINT)) { |
| 2175 | gbc.setHashGroupByHint(true); |
| 2176 | } |
| 2177 | } |
| 2178 | "by" (LOOKAHEAD(2) var = Variable() |
| 2179 | { |
| 2180 | newScope.addNewVarSymbolToScope(var.getVar()); |
| 2181 | } ":=")? |
| 2182 | expr = Expression() |
| 2183 | { |
| 2184 | GbyVariableExpressionPair pair1 = new GbyVariableExpressionPair(var, expr); |
| 2185 | vePairList.add(pair1); |
| 2186 | } |
| 2187 | ("," ( LOOKAHEAD(2) var = Variable() |
| 2188 | { |
| 2189 | newScope.addNewVarSymbolToScope(var.getVar()); |
| 2190 | } ":=")? |
| 2191 | expr = Expression() |
| 2192 | { |
| 2193 | GbyVariableExpressionPair pair2 = new GbyVariableExpressionPair(var, expr); |
| 2194 | vePairList.add(pair2); |
| 2195 | } |
| 2196 | )* |
| 2197 | ("decor" decorVar = Variable() ":=" decorExpr = Expression() |
| 2198 | { |
| 2199 | newScope.addNewVarSymbolToScope(decorVar.getVar()); |
| 2200 | GbyVariableExpressionPair pair3 = new GbyVariableExpressionPair(decorVar, decorExpr); |
| 2201 | decorPairList.add(pair3); |
| 2202 | } |
| 2203 | ("," "decor" decorVar = Variable() ":=" decorExpr = Expression() |
| 2204 | { |
| 2205 | newScope.addNewVarSymbolToScope(decorVar.getVar()); |
| 2206 | GbyVariableExpressionPair pair4 = new GbyVariableExpressionPair(decorVar, decorExpr); |
| 2207 | decorPairList.add(pair4); |
| 2208 | } |
| 2209 | )* |
| 2210 | )? |
| 2211 | "with" withVar = VariableRef() |
| 2212 | { |
| 2213 | if(withVar.getIsNewVar()==true) |
| 2214 | throw new ParseException("can't find variable " + withVar.getVar()); |
| 2215 | withVarList.add(withVar); |
| 2216 | newScope.addNewVarSymbolToScope(withVar.getVar()); |
| 2217 | } |
| 2218 | ("," withVar = VariableRef() |
| 2219 | { |
| 2220 | if(withVar.getIsNewVar()==true) |
| 2221 | throw new ParseException("can't find variable " + withVar.getVar()); |
| 2222 | withVarList.add(withVar); |
| 2223 | newScope.addNewVarSymbolToScope(withVar.getVar()); |
| 2224 | })* |
| 2225 | { |
| 2226 | gbc.setGbyPairList(vePairList); |
| 2227 | gbc.setDecorPairList(decorPairList); |
| 2228 | gbc.setWithVarList(withVarList); |
| 2229 | replaceCurrentScope(newScope); |
| 2230 | return gbc; |
| 2231 | } |
| 2232 | } |
| 2233 | |
| 2234 | |
| 2235 | LimitClause LimitClause() throws ParseException: |
| 2236 | { |
| 2237 | LimitClause lc = new LimitClause(); |
| 2238 | Expression expr; |
| 2239 | pushForbiddenScope(getCurrentScope()); |
| 2240 | } |
| 2241 | { |
| 2242 | "limit" expr = Expression() { lc.setLimitExpr(expr); } |
| 2243 | ("offset" expr = Expression() { lc.setOffset(expr); })? |
| 2244 | |
| 2245 | { |
| 2246 | popForbiddenScope(); |
| 2247 | return lc; |
| 2248 | } |
| 2249 | } |
| 2250 | |
| 2251 | DistinctClause DistinctClause() throws ParseException: |
| 2252 | { |
| 2253 | List<Expression> exprs = new ArrayList<Expression>(); |
| 2254 | Expression expr; |
| 2255 | } |
| 2256 | { |
| 2257 | "distinct" "by" expr = Expression() |
| 2258 | { |
| 2259 | exprs.add(expr); |
| 2260 | } |
| 2261 | ("," expr = Expression() |
| 2262 | { |
| 2263 | exprs.add(expr); |
| 2264 | } |
| 2265 | )* |
| 2266 | { |
| 2267 | return new DistinctClause(exprs); |
| 2268 | } |
| 2269 | } |
| 2270 | |
| 2271 | DieClause DieClause() throws ParseException: |
| 2272 | { |
| 2273 | DieClause lc = new DieClause(); |
| 2274 | Expression expr; |
| 2275 | pushForbiddenScope(getCurrentScope()); |
| 2276 | } |
| 2277 | { |
| 2278 | "die" "after" expr = Expression() { lc.setDieExpr(expr); } |
| 2279 | { |
| 2280 | popForbiddenScope(); |
| 2281 | return lc; |
| 2282 | } |
| 2283 | } |
| 2284 | |
| 2285 | |
| 2286 | QuantifiedExpression QuantifiedExpression()throws ParseException: |
| 2287 | { |
| 2288 | QuantifiedExpression qc = new QuantifiedExpression(); |
| 2289 | List<QuantifiedPair> quantifiedList = new ArrayList<QuantifiedPair>(); |
| 2290 | Expression satisfiesExpr; |
| 2291 | VariableExpr var; |
| 2292 | Expression inExpr; |
| 2293 | QuantifiedPair pair; |
| 2294 | } |
| 2295 | { |
| 2296 | { |
| 2297 | createNewScope(); |
| 2298 | } |
| 2299 | |
| 2300 | ( ("some" { qc.setQuantifier(QuantifiedExpression.Quantifier.SOME); }) |
| 2301 | | ("every" { qc.setQuantifier(QuantifiedExpression.Quantifier.EVERY); })) |
| 2302 | var = Variable() "in" inExpr = Expression() |
| 2303 | { |
| 2304 | pair = new QuantifiedPair(var, inExpr); |
| 2305 | getCurrentScope().addNewVarSymbolToScope(var.getVar()); |
| 2306 | quantifiedList.add(pair); |
| 2307 | } |
| 2308 | ( |
| 2309 | "," var = Variable() "in" inExpr = Expression() |
| 2310 | { |
| 2311 | pair = new QuantifiedPair(var, inExpr); |
| 2312 | getCurrentScope().addNewVarSymbolToScope(var.getVar()); |
| 2313 | quantifiedList.add(pair); |
| 2314 | } |
| 2315 | )* |
| 2316 | "satisfies" satisfiesExpr = Expression() |
| 2317 | { |
| 2318 | qc.setSatisfiesExpr(satisfiesExpr); |
| 2319 | qc.setQuantifiedList(quantifiedList); |
| 2320 | removeCurrentScope(); |
| 2321 | return qc; |
| 2322 | } |
| 2323 | } |
| 2324 | |
| 2325 | TOKEN_MGR_DECLS: |
| 2326 | { |
| 2327 | public int commentDepth = 0; |
| 2328 | } |
| 2329 | |
| 2330 | <DEFAULT> |
| 2331 | TOKEN : |
| 2332 | { |
| 2333 | <CARET : "^" > |
| 2334 | } |
| 2335 | |
| 2336 | <DEFAULT> |
| 2337 | TOKEN : |
| 2338 | { |
| 2339 | <DATASET : "dataset" > |
| 2340 | } |
| 2341 | |
| 2342 | <DEFAULT> |
| 2343 | TOKEN : |
| 2344 | { |
| 2345 | <LEFTPAREN : "(" > |
| 2346 | } |
| 2347 | |
| 2348 | <DEFAULT> |
| 2349 | TOKEN : |
| 2350 | { |
| 2351 | <RIGHTPAREN : ")" > |
| 2352 | } |
| 2353 | |
| 2354 | |
| 2355 | <DEFAULT> |
| 2356 | TOKEN : |
| 2357 | { |
| 2358 | <INTEGER_LITERAL : (<DIGIT>)+ > |
| 2359 | } |
| 2360 | |
| 2361 | |
| 2362 | <DEFAULT> |
| 2363 | TOKEN : |
| 2364 | { |
| 2365 | <NULL : "null"> |
| 2366 | } |
| 2367 | |
| 2368 | <DEFAULT> |
| 2369 | TOKEN : |
| 2370 | { |
| 2371 | <TRUE : "true"> |
| 2372 | } |
| 2373 | |
| 2374 | <DEFAULT> |
| 2375 | TOKEN : |
| 2376 | { |
| 2377 | <FALSE : "false"> |
| 2378 | } |
| 2379 | |
| 2380 | <DEFAULT> |
| 2381 | TOKEN : |
| 2382 | { |
| 2383 | <#DIGIT : ["0" - "9"]> |
| 2384 | } |
| 2385 | |
| 2386 | |
| 2387 | TOKEN: |
| 2388 | { |
| 2389 | < DOUBLE_LITERAL: <INTEGER> |
| 2390 | | <INTEGER> ( "." <INTEGER> )? |
| 2391 | | "." <INTEGER> |
| 2392 | > |
| 2393 | | |
| 2394 | < FLOAT_LITERAL: <INTEGER> ( "f" | "F" ) |
| 2395 | | <INTEGER> ( "." <INTEGER> ( "f" | "F" ) )? |
| 2396 | | "." <INTEGER> ( "f" | "F" ) |
| 2397 | > |
| 2398 | | |
| 2399 | <INTEGER : (<DIGIT>)+ > |
| 2400 | } |
| 2401 | |
| 2402 | <DEFAULT> |
| 2403 | TOKEN : |
| 2404 | { |
| 2405 | <#LETTER : ["A" - "Z", "a" - "z"]> |
| 2406 | } |
| 2407 | |
| 2408 | <DEFAULT> |
| 2409 | TOKEN : |
| 2410 | { |
| 2411 | <SPECIALCHARS : ["$", "_", "-"] > |
| 2412 | } |
| 2413 | |
| 2414 | <DEFAULT> |
| 2415 | TOKEN : |
| 2416 | { |
| 2417 | <STRING_LITERAL : ("\"" (<EscapeQuot> | ~["\""])* "\"") | ("\'"(<EscapeApos> | ~["\'"])* "\'")> |
| 2418 | | |
| 2419 | < #EscapeQuot: "\\\"" > |
| 2420 | | |
| 2421 | < #EscapeApos: "\\\'" > |
| 2422 | } |
| 2423 | |
| 2424 | <DEFAULT> |
| 2425 | TOKEN : |
| 2426 | { |
| 2427 | <IDENTIFIER : (<LETTER>)+ (<LETTER> | <DIGIT> | <SPECIALCHARS>)*> |
| 2428 | } |
| 2429 | |
RamanGrover29@gmail.com | 58cf330 | 2012-11-09 00:27:45 +0000 | [diff] [blame] | 2430 | |
vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 2431 | <DEFAULT> |
| 2432 | TOKEN : |
| 2433 | { |
| 2434 | <VARIABLE : "$" <IDENTIFIER> > |
| 2435 | } |
| 2436 | |
| 2437 | SKIP: |
| 2438 | { |
| 2439 | " " |
| 2440 | | "\t" |
| 2441 | | "\r" |
| 2442 | | "\n" |
| 2443 | } |
| 2444 | |
| 2445 | SKIP: |
| 2446 | { |
| 2447 | <"//" (~["\n"])* "\n"> |
| 2448 | } |
| 2449 | |
| 2450 | SKIP: |
| 2451 | { |
| 2452 | <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")?> |
| 2453 | } |
| 2454 | |
| 2455 | |
| 2456 | SKIP: |
| 2457 | { |
| 2458 | <"/*"> {commentDepth=1;}: INSIDE_COMMENT |
| 2459 | } |
| 2460 | |
| 2461 | <INSIDE_COMMENT> |
| 2462 | SPECIAL_TOKEN: |
| 2463 | { |
| 2464 | <"+"(" ")*(~["*"])*> |
| 2465 | } |
| 2466 | |
| 2467 | <INSIDE_COMMENT> |
| 2468 | SKIP: |
| 2469 | { |
| 2470 | <"/*"> {commentDepth++;} |
| 2471 | } |
| 2472 | |
| 2473 | <INSIDE_COMMENT> |
| 2474 | SKIP: |
| 2475 | { |
| 2476 | <"*/"> {commentDepth--; if (commentDepth == 0) SwitchTo(DEFAULT);} |
| 2477 | | <~[]> |
| 2478 | } |