1 3 package org.apache.ojb.jdo.jdoql; 4 5 19 20 import antlr.ASTFactory; 21 import antlr.ASTPair; 22 import antlr.NoViableAltException; 23 import antlr.ParserSharedInputState; 24 import antlr.RecognitionException; 25 import antlr.Token; 26 import antlr.TokenBuffer; 27 import antlr.TokenStream; 28 import antlr.TokenStreamException; 29 import antlr.collections.AST; 30 import antlr.collections.impl.ASTArray; 31 import antlr.collections.impl.BitSet; 32 33 public class JDOQLParser extends antlr.LLkParser implements JDOQLParserTokenTypes 34 { 35 36 protected JDOQLParser(TokenBuffer tokenBuf, int k) { 37 super(tokenBuf,k); 38 tokenNames = _tokenNames; 39 buildTokenTypeASTClassMap(); 40 astFactory = new ASTFactory(getTokenTypeToASTClassMap()); 41 } 42 43 public JDOQLParser(TokenBuffer tokenBuf) { 44 this(tokenBuf,2); 45 } 46 47 protected JDOQLParser(TokenStream lexer, int k) { 48 super(lexer,k); 49 tokenNames = _tokenNames; 50 buildTokenTypeASTClassMap(); 51 astFactory = new ASTFactory(getTokenTypeToASTClassMap()); 52 } 53 54 public JDOQLParser(TokenStream lexer) { 55 this(lexer,2); 56 } 57 58 public JDOQLParser(ParserSharedInputState state) { 59 super(state,2); 60 tokenNames = _tokenNames; 61 buildTokenTypeASTClassMap(); 62 astFactory = new ASTFactory(getTokenTypeToASTClassMap()); 63 } 64 65 public final void declareParameters() throws RecognitionException, TokenStreamException { 66 67 returnAST = null; 68 ASTPair currentAST = new ASTPair(); 69 AST declareParameters_AST = null; 70 71 parameter(); 72 astFactory.addASTChild(currentAST, returnAST); 73 { 74 _loop3: 75 do { 76 if ((LA(1)==SEP_COMMA) && (_tokenSet_0.member(LA(2)))) { 77 match(SEP_COMMA); 78 parameter(); 79 astFactory.addASTChild(currentAST, returnAST); 80 } 81 else { 82 break _loop3; 83 } 84 85 } while (true); 86 } 87 { 88 switch ( LA(1)) { 89 case SEP_COMMA: 90 { 91 match(SEP_COMMA); 92 break; 93 } 94 case EOF: 95 { 96 break; 97 } 98 default: 99 { 100 throw new NoViableAltException(LT(1), getFilename()); 101 } 102 } 103 } 104 if ( inputState.guessing==0 ) { 105 declareParameters_AST = currentAST.root; 106 declareParameters_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(PARAMETERS,"PARAMETERS")).add(declareParameters_AST)); 107 currentAST.root = declareParameters_AST; 108 currentAST.child = declareParameters_AST!=null &&declareParameters_AST.getFirstChild()!=null ? 109 declareParameters_AST.getFirstChild() : declareParameters_AST; 110 currentAST.advanceChildToEnd(); 111 } 112 declareParameters_AST = currentAST.root; 113 returnAST = declareParameters_AST; 114 } 115 116 public final void parameter() throws RecognitionException, TokenStreamException { 117 118 returnAST = null; 119 ASTPair currentAST = new ASTPair(); 120 AST parameter_AST = null; 121 122 type(); 123 astFactory.addASTChild(currentAST, returnAST); 124 identifier(); 125 astFactory.addASTChild(currentAST, returnAST); 126 if ( inputState.guessing==0 ) { 127 parameter_AST = currentAST.root; 128 parameter_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(PARAMETER,"PARAMETER")).add(parameter_AST)); 129 currentAST.root = parameter_AST; 130 currentAST.child = parameter_AST!=null &¶meter_AST.getFirstChild()!=null ? 131 parameter_AST.getFirstChild() : parameter_AST; 132 currentAST.advanceChildToEnd(); 133 } 134 parameter_AST = currentAST.root; 135 returnAST = parameter_AST; 136 } 137 138 public final void type() throws RecognitionException, TokenStreamException { 139 140 returnAST = null; 141 ASTPair currentAST = new ASTPair(); 142 AST type_AST = null; 143 144 switch ( LA(1)) { 145 case LITERAL_BOOLEAN: 146 case LITERAL_BYTE: 147 case LITERAL_SHORT: 148 case LITERAL_INT: 149 case LITERAL_LONG: 150 case LITERAL_CHAR: 151 case LITERAL_FLOAT: 152 case LITERAL_DOUBLE: 153 { 154 primitiveType(); 155 astFactory.addASTChild(currentAST, returnAST); 156 type_AST = currentAST.root; 157 break; 158 } 159 case IDENTIFIER: 160 { 161 name(); 162 astFactory.addASTChild(currentAST, returnAST); 163 type_AST = currentAST.root; 164 break; 165 } 166 default: 167 { 168 throw new NoViableAltException(LT(1), getFilename()); 169 } 170 } 171 returnAST = type_AST; 172 } 173 174 public final void identifier() throws RecognitionException, TokenStreamException { 175 176 returnAST = null; 177 ASTPair currentAST = new ASTPair(); 178 AST identifier_AST = null; 179 180 AST tmp3_AST = null; 181 tmp3_AST = astFactory.create(LT(1)); 182 astFactory.addASTChild(currentAST, tmp3_AST); 183 match(IDENTIFIER); 184 identifier_AST = currentAST.root; 185 returnAST = identifier_AST; 186 } 187 188 public final void declareVariables() throws RecognitionException, TokenStreamException { 189 190 returnAST = null; 191 ASTPair currentAST = new ASTPair(); 192 AST declareVariables_AST = null; 193 194 variable(); 195 astFactory.addASTChild(currentAST, returnAST); 196 { 197 _loop8: 198 do { 199 if ((LA(1)==SEP_SEMICOLON) && (_tokenSet_0.member(LA(2)))) { 200 match(SEP_SEMICOLON); 201 variable(); 202 astFactory.addASTChild(currentAST, returnAST); 203 } 204 else { 205 break _loop8; 206 } 207 208 } while (true); 209 } 210 { 211 switch ( LA(1)) { 212 case SEP_SEMICOLON: 213 { 214 match(SEP_SEMICOLON); 215 break; 216 } 217 case EOF: 218 { 219 break; 220 } 221 default: 222 { 223 throw new NoViableAltException(LT(1), getFilename()); 224 } 225 } 226 } 227 if ( inputState.guessing==0 ) { 228 declareVariables_AST = currentAST.root; 229 declareVariables_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(VARIABLES,"VARIABLES")).add(declareVariables_AST)); 230 currentAST.root = declareVariables_AST; 231 currentAST.child = declareVariables_AST!=null &&declareVariables_AST.getFirstChild()!=null ? 232 declareVariables_AST.getFirstChild() : declareVariables_AST; 233 currentAST.advanceChildToEnd(); 234 } 235 declareVariables_AST = currentAST.root; 236 returnAST = declareVariables_AST; 237 } 238 239 public final void variable() throws RecognitionException, TokenStreamException { 240 241 returnAST = null; 242 ASTPair currentAST = new ASTPair(); 243 AST variable_AST = null; 244 245 type(); 246 astFactory.addASTChild(currentAST, returnAST); 247 identifier(); 248 astFactory.addASTChild(currentAST, returnAST); 249 if ( inputState.guessing==0 ) { 250 variable_AST = currentAST.root; 251 variable_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(VARIABLE,"VARIABLE")).add(variable_AST)); 252 currentAST.root = variable_AST; 253 currentAST.child = variable_AST!=null &&variable_AST.getFirstChild()!=null ? 254 variable_AST.getFirstChild() : variable_AST; 255 currentAST.advanceChildToEnd(); 256 } 257 variable_AST = currentAST.root; 258 returnAST = variable_AST; 259 } 260 261 public final void declareImports() throws RecognitionException, TokenStreamException { 262 263 returnAST = null; 264 ASTPair currentAST = new ASTPair(); 265 AST declareImports_AST = null; 266 267 importDeclaration(); 268 astFactory.addASTChild(currentAST, returnAST); 269 { 270 _loop13: 271 do { 272 if ((LA(1)==SEP_SEMICOLON) && (LA(2)==LITERAL_IMPORT)) { 273 match(SEP_SEMICOLON); 274 importDeclaration(); 275 astFactory.addASTChild(currentAST, returnAST); 276 } 277 else { 278 break _loop13; 279 } 280 281 } while (true); 282 } 283 { 284 switch ( LA(1)) { 285 case SEP_SEMICOLON: 286 { 287 match(SEP_SEMICOLON); 288 break; 289 } 290 case EOF: 291 { 292 break; 293 } 294 default: 295 { 296 throw new NoViableAltException(LT(1), getFilename()); 297 } 298 } 299 } 300 if ( inputState.guessing==0 ) { 301 declareImports_AST = currentAST.root; 302 declareImports_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(IMPORTS,"IMPORTS")).add(declareImports_AST)); 303 currentAST.root = declareImports_AST; 304 currentAST.child = declareImports_AST!=null &&declareImports_AST.getFirstChild()!=null ? 305 declareImports_AST.getFirstChild() : declareImports_AST; 306 currentAST.advanceChildToEnd(); 307 } 308 declareImports_AST = currentAST.root; 309 returnAST = declareImports_AST; 310 } 311 312 public final void importDeclaration() throws RecognitionException, TokenStreamException { 313 314 returnAST = null; 315 ASTPair currentAST = new ASTPair(); 316 AST importDeclaration_AST = null; 317 Token node = null; 318 AST node_AST = null; 319 320 node = LT(1); 321 node_AST = astFactory.create(node); 322 astFactory.makeASTRoot(currentAST, node_AST); 323 match(LITERAL_IMPORT); 324 name(); 325 astFactory.addASTChild(currentAST, returnAST); 326 if ( inputState.guessing==0 ) { 327 node_AST.setType(IMPORT); 328 } 329 { 330 switch ( LA(1)) { 331 case SEP_DOT: 332 { 333 match(SEP_DOT); 334 match(OP_MULTIPLY); 335 if ( inputState.guessing==0 ) { 336 node_AST.setType(ON_DEMAND_IMPORT); 337 } 338 break; 339 } 340 case EOF: 341 case SEP_SEMICOLON: 342 { 343 break; 344 } 345 default: 346 { 347 throw new NoViableAltException(LT(1), getFilename()); 348 } 349 } 350 } 351 importDeclaration_AST = currentAST.root; 352 returnAST = importDeclaration_AST; 353 } 354 355 public final void name() throws RecognitionException, TokenStreamException { 356 357 returnAST = null; 358 ASTPair currentAST = new ASTPair(); 359 AST name_AST = null; 360 Token dot = null; 361 AST dot_AST = null; 362 AST i_AST = null; 363 364 identifier(); 365 astFactory.addASTChild(currentAST, returnAST); 366 { 367 _loop80: 368 do { 369 if ((LA(1)==SEP_DOT) && (LA(2)==IDENTIFIER)) { 370 dot = LT(1); 371 dot_AST = astFactory.create(dot); 372 match(SEP_DOT); 373 identifier(); 374 i_AST = returnAST; 375 if ( inputState.guessing==0 ) { 376 name_AST = currentAST.root; 377 378 name_AST.setText(name_AST.getText() + dot_AST.getText() + i_AST.getText()); 379 380 } 381 } 382 else { 383 break _loop80; 384 } 385 386 } while (true); 387 } 388 if ( inputState.guessing==0 ) { 389 name_AST = currentAST.root; 390 name_AST.setType(NAME); 391 } 392 name_AST = currentAST.root; 393 returnAST = name_AST; 394 } 395 396 public final void setOrdering() throws RecognitionException, TokenStreamException { 397 398 returnAST = null; 399 ASTPair currentAST = new ASTPair(); 400 AST setOrdering_AST = null; 401 402 orderSpecification(); 403 astFactory.addASTChild(currentAST, returnAST); 404 { 405 _loop19: 406 do { 407 if ((LA(1)==SEP_COMMA) && (_tokenSet_1.member(LA(2)))) { 408 match(SEP_COMMA); 409 orderSpecification(); 410 astFactory.addASTChild(currentAST, returnAST); 411 } 412 else { 413 break _loop19; 414 } 415 416 } while (true); 417 } 418 { 419 switch ( LA(1)) { 420 case SEP_COMMA: 421 { 422 match(SEP_COMMA); 423 break; 424 } 425 case EOF: 426 { 427 break; 428 } 429 default: 430 { 431 throw new NoViableAltException(LT(1), getFilename()); 432 } 433 } 434 } 435 if ( inputState.guessing==0 ) { 436 setOrdering_AST = currentAST.root; 437 setOrdering_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(ORDERSPECS,"ORDERSPECS")).add(setOrdering_AST)); 438 currentAST.root = setOrdering_AST; 439 currentAST.child = setOrdering_AST!=null &&setOrdering_AST.getFirstChild()!=null ? 440 setOrdering_AST.getFirstChild() : setOrdering_AST; 441 currentAST.advanceChildToEnd(); 442 } 443 setOrdering_AST = currentAST.root; 444 returnAST = setOrdering_AST; 445 } 446 447 public final void orderSpecification() throws RecognitionException, TokenStreamException { 448 449 returnAST = null; 450 ASTPair currentAST = new ASTPair(); 451 AST orderSpecification_AST = null; 452 453 expression(); 454 astFactory.addASTChild(currentAST, returnAST); 455 { 456 switch ( LA(1)) { 457 case LITERAL_ASCENDING: 458 { 459 AST tmp12_AST = null; 460 tmp12_AST = astFactory.create(LT(1)); 461 astFactory.addASTChild(currentAST, tmp12_AST); 462 match(LITERAL_ASCENDING); 463 break; 464 } 465 case LITERAL_DESCENDING: 466 { 467 AST tmp13_AST = null; 468 tmp13_AST = astFactory.create(LT(1)); 469 astFactory.addASTChild(currentAST, tmp13_AST); 470 match(LITERAL_DESCENDING); 471 break; 472 } 473 default: 474 { 475 throw new NoViableAltException(LT(1), getFilename()); 476 } 477 } 478 } 479 if ( inputState.guessing==0 ) { 480 orderSpecification_AST = currentAST.root; 481 orderSpecification_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(ORDERSPEC,"ORDERSPEC")).add(orderSpecification_AST)); 482 currentAST.root = orderSpecification_AST; 483 currentAST.child = orderSpecification_AST!=null &&orderSpecification_AST.getFirstChild()!=null ? 484 orderSpecification_AST.getFirstChild() : orderSpecification_AST; 485 currentAST.advanceChildToEnd(); 486 } 487 orderSpecification_AST = currentAST.root; 488 returnAST = orderSpecification_AST; 489 } 490 491 public final void expression() throws RecognitionException, TokenStreamException { 492 493 returnAST = null; 494 ASTPair currentAST = new ASTPair(); 495 AST expression_AST = null; 496 497 conditionalOrExpression(); 498 astFactory.addASTChild(currentAST, returnAST); 499 expression_AST = currentAST.root; 500 returnAST = expression_AST; 501 } 502 503 public final void primary() throws RecognitionException, TokenStreamException { 504 505 returnAST = null; 506 ASTPair currentAST = new ASTPair(); 507 AST primary_AST = null; 508 509 { 510 switch ( LA(1)) { 511 case LITERAL_TRUE: 512 case LITERAL_FALSE: 513 case LITERAL_NULL: 514 case FLOATING_POINT_LITERAL: 515 case INTEGER_LITERAL: 516 case CHARACTER_LITERAL: 517 case STRING_LITERAL: 518 { 519 literal(); 520 astFactory.addASTChild(currentAST, returnAST); 521 break; 522 } 523 case LITERAL_THIS: 524 { 525 AST tmp14_AST = null; 526 tmp14_AST = astFactory.create(LT(1)); 527 astFactory.makeASTRoot(currentAST, tmp14_AST); 528 match(LITERAL_THIS); 529 break; 530 } 531 case SEP_OPENING_PARENTHESIS: 532 { 533 match(SEP_OPENING_PARENTHESIS); 534 expression(); 535 astFactory.addASTChild(currentAST, returnAST); 536 match(SEP_CLOSING_PARENTHESIS); 537 break; 538 } 539 case IDENTIFIER: 540 { 541 directAccess(); 542 astFactory.addASTChild(currentAST, returnAST); 543 break; 544 } 545 default: 546 { 547 throw new NoViableAltException(LT(1), getFilename()); 548 } 549 } 550 } 551 primary_AST = currentAST.root; 552 returnAST = primary_AST; 553 } 554 555 public final void literal() throws RecognitionException, TokenStreamException { 556 557 returnAST = null; 558 ASTPair currentAST = new ASTPair(); 559 AST literal_AST = null; 560 561 switch ( LA(1)) { 562 case LITERAL_TRUE: 563 { 564 AST tmp17_AST = null; 565 tmp17_AST = astFactory.create(LT(1)); 566 astFactory.addASTChild(currentAST, tmp17_AST); 567 match(LITERAL_TRUE); 568 literal_AST = currentAST.root; 569 break; 570 } 571 case LITERAL_FALSE: 572 { 573 AST tmp18_AST = null; 574 tmp18_AST = astFactory.create(LT(1)); 575 astFactory.addASTChild(currentAST, tmp18_AST); 576 match(LITERAL_FALSE); 577 literal_AST = currentAST.root; 578 break; 579 } 580 case LITERAL_NULL: 581 { 582 AST tmp19_AST = null; 583 tmp19_AST = astFactory.create(LT(1)); 584 astFactory.addASTChild(currentAST, tmp19_AST); 585 match(LITERAL_NULL); 586 literal_AST = currentAST.root; 587 break; 588 } 589 case INTEGER_LITERAL: 590 { 591 AST tmp20_AST = null; 592 tmp20_AST = astFactory.create(LT(1)); 593 astFactory.addASTChild(currentAST, tmp20_AST); 594 match(INTEGER_LITERAL); 595 literal_AST = currentAST.root; 596 break; 597 } 598 case FLOATING_POINT_LITERAL: 599 { 600 AST tmp21_AST = null; 601 tmp21_AST = astFactory.create(LT(1)); 602 astFactory.addASTChild(currentAST, tmp21_AST); 603 match(FLOATING_POINT_LITERAL); 604 literal_AST = currentAST.root; 605 break; 606 } 607 case CHARACTER_LITERAL: 608 { 609 AST tmp22_AST = null; 610 tmp22_AST = astFactory.create(LT(1)); 611 astFactory.addASTChild(currentAST, tmp22_AST); 612 match(CHARACTER_LITERAL); 613 literal_AST = currentAST.root; 614 break; 615 } 616 case STRING_LITERAL: 617 { 618 AST tmp23_AST = null; 619 tmp23_AST = astFactory.create(LT(1)); 620 astFactory.addASTChild(currentAST, tmp23_AST); 621 match(STRING_LITERAL); 622 literal_AST = currentAST.root; 623 break; 624 } 625 default: 626 { 627 throw new NoViableAltException(LT(1), getFilename()); 628 } 629 } 630 returnAST = literal_AST; 631 } 632 633 public final void directAccess() throws RecognitionException, TokenStreamException { 634 635 returnAST = null; 636 ASTPair currentAST = new ASTPair(); 637 AST directAccess_AST = null; 638 Token id = null; 639 AST id_AST = null; 640 641 id = LT(1); 642 id_AST = astFactory.create(id); 643 astFactory.makeASTRoot(currentAST, id_AST); 644 match(IDENTIFIER); 645 { 646 switch ( LA(1)) { 647 case SEP_OPENING_PARENTHESIS: 648 { 649 match(SEP_OPENING_PARENTHESIS); 650 argList(); 651 astFactory.addASTChild(currentAST, returnAST); 652 match(SEP_CLOSING_PARENTHESIS); 653 if ( inputState.guessing==0 ) { 654 directAccess_AST = currentAST.root; 655 directAccess_AST.setType(METHOD_INVOCATION); 656 } 657 break; 658 } 659 case EOF: 660 case LITERAL_ASCENDING: 661 case LITERAL_DESCENDING: 662 case OP_GREATER_OR_EQUAL: 663 case OP_LOWER_OR_EQUAL: 664 case OP_NOT_EQUAL: 665 case OP_AND: 666 case OP_OR: 667 case SEP_DOT: 668 case SEP_CLOSING_PARENTHESIS: 669 case SEP_COMMA: 670 case OP_EQUAL: 671 case OP_GREATER: 672 case OP_LOWER: 673 case OP_BITWISE_AND: 674 case OP_BITWISE_OR: 675 case OP_BITWISE_XOR: 676 case OP_BINARY_PLUS: 677 case OP_BINARY_MINUS: 678 case OP_MULTIPLY: 679 case OP_DIVIDE: 680 { 681 if ( inputState.guessing==0 ) { 682 directAccess_AST = currentAST.root; 683 directAccess_AST.setType(NAME_EXPRESSION); 684 } 685 break; 686 } 687 default: 688 { 689 throw new NoViableAltException(LT(1), getFilename()); 690 } 691 } 692 } 693 directAccess_AST = currentAST.root; 694 returnAST = directAccess_AST; 695 } 696 697 public final void argList() throws RecognitionException, TokenStreamException { 698 699 returnAST = null; 700 ASTPair currentAST = new ASTPair(); 701 AST argList_AST = null; 702 703 { 704 switch ( LA(1)) { 705 case LITERAL_TRUE: 706 case LITERAL_FALSE: 707 case LITERAL_NULL: 708 case LITERAL_THIS: 709 case FLOATING_POINT_LITERAL: 710 case INTEGER_LITERAL: 711 case SEP_OPENING_PARENTHESIS: 712 case OP_NOT: 713 case OP_BITWISE_COMPLEMENT: 714 case OP_BINARY_PLUS: 715 case OP_BINARY_MINUS: 716 case IDENTIFIER: 717 case CHARACTER_LITERAL: 718 case STRING_LITERAL: 719 { 720 expression(); 721 astFactory.addASTChild(currentAST, returnAST); 722 { 723 _loop30: 724 do { 725 if ((LA(1)==SEP_COMMA)) { 726 match(SEP_COMMA); 727 expression(); 728 astFactory.addASTChild(currentAST, returnAST); 729 } 730 else { 731 break _loop30; 732 } 733 734 } while (true); 735 } 736 if ( inputState.guessing==0 ) { 737 argList_AST = currentAST.root; 738 argList_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(ARG_LIST,"ARG_LIST")).add(argList_AST)); 739 currentAST.root = argList_AST; 740 currentAST.child = argList_AST!=null &&argList_AST.getFirstChild()!=null ? 741 argList_AST.getFirstChild() : argList_AST; 742 currentAST.advanceChildToEnd(); 743 } 744 break; 745 } 746 case SEP_CLOSING_PARENTHESIS: 747 { 748 if ( inputState.guessing==0 ) { 749 argList_AST = currentAST.root; 750 argList_AST = astFactory.create(ARG_LIST,"ARG_LIST"); 751 currentAST.root = argList_AST; 752 currentAST.child = argList_AST!=null &&argList_AST.getFirstChild()!=null ? 753 argList_AST.getFirstChild() : argList_AST; 754 currentAST.advanceChildToEnd(); 755 } 756 break; 757 } 758 default: 759 { 760 throw new NoViableAltException(LT(1), getFilename()); 761 } 762 } 763 } 764 argList_AST = currentAST.root; 765 returnAST = argList_AST; 766 } 767 768 public final void postfixExpression() throws RecognitionException, TokenStreamException { 769 770 returnAST = null; 771 ASTPair currentAST = new ASTPair(); 772 AST postfixExpression_AST = null; 773 774 primary(); 775 astFactory.addASTChild(currentAST, returnAST); 776 { 777 _loop33: 778 do { 779 if ((LA(1)==SEP_DOT)) { 780 AST tmp27_AST = null; 781 tmp27_AST = astFactory.create(LT(1)); 782 astFactory.makeASTRoot(currentAST, tmp27_AST); 783 match(SEP_DOT); 784 directAccess(); 785 astFactory.addASTChild(currentAST, returnAST); 786 } 787 else { 788 break _loop33; 789 } 790 791 } while (true); 792 } 793 postfixExpression_AST = currentAST.root; 794 returnAST = postfixExpression_AST; 795 } 796 797 public final void unaryExpression() throws RecognitionException, TokenStreamException { 798 799 returnAST = null; 800 ASTPair currentAST = new ASTPair(); 801 AST unaryExpression_AST = null; 802 Token op1 = null; 803 AST op1_AST = null; 804 Token op2 = null; 805 AST op2_AST = null; 806 807 { 808 switch ( LA(1)) { 809 case OP_BINARY_MINUS: 810 { 811 op1 = LT(1); 812 op1_AST = astFactory.create(op1); 813 astFactory.makeASTRoot(currentAST, op1_AST); 814 match(OP_BINARY_MINUS); 815 unaryExpression(); 816 astFactory.addASTChild(currentAST, returnAST); 817 if ( inputState.guessing==0 ) { 818 819 op1_AST.setType(OP_UNARY_MINUS); 820 821 } 822 break; 823 } 824 case OP_BINARY_PLUS: 825 { 826 op2 = LT(1); 827 op2_AST = astFactory.create(op2); 828 astFactory.makeASTRoot(currentAST, op2_AST); 829 match(OP_BINARY_PLUS); 830 unaryExpression(); 831 astFactory.addASTChild(currentAST, returnAST); 832 if ( inputState.guessing==0 ) { 833 834 op2_AST.setType(OP_UNARY_PLUS); 835 836 } 837 break; 838 } 839 case LITERAL_TRUE: 840 case LITERAL_FALSE: 841 case LITERAL_NULL: 842 case LITERAL_THIS: 843 case FLOATING_POINT_LITERAL: 844 case INTEGER_LITERAL: 845 case SEP_OPENING_PARENTHESIS: 846 case OP_NOT: 847 case OP_BITWISE_COMPLEMENT: 848 case IDENTIFIER: 849 case CHARACTER_LITERAL: 850 case STRING_LITERAL: 851 { 852 unaryExpressionNotPlusMinus(); 853 astFactory.addASTChild(currentAST, returnAST); 854 break; 855 } 856 default: 857 { 858 throw new NoViableAltException(LT(1), getFilename()); 859 } 860 } 861 } 862 unaryExpression_AST = currentAST.root; 863 returnAST = unaryExpression_AST; 864 } 865 866 public final void unaryExpressionNotPlusMinus() throws RecognitionException, TokenStreamException { 867 868 returnAST = null; 869 ASTPair currentAST = new ASTPair(); 870 AST unaryExpressionNotPlusMinus_AST = null; 871 872 { 873 switch ( LA(1)) { 874 case OP_BITWISE_COMPLEMENT: 875 { 876 AST tmp28_AST = null; 877 tmp28_AST = astFactory.create(LT(1)); 878 astFactory.makeASTRoot(currentAST, tmp28_AST); 879 match(OP_BITWISE_COMPLEMENT); 880 unaryExpression(); 881 astFactory.addASTChild(currentAST, returnAST); 882 break; 883 } 884 case OP_NOT: 885 { 886 AST tmp29_AST = null; 887 tmp29_AST = astFactory.create(LT(1)); 888 astFactory.makeASTRoot(currentAST, tmp29_AST); 889 match(OP_NOT); 890 unaryExpression(); 891 astFactory.addASTChild(currentAST, returnAST); 892 break; 893 } 894 default: 895 boolean synPredMatched39 = false; 896 if (((LA(1)==SEP_OPENING_PARENTHESIS) && (_tokenSet_0.member(LA(2))))) { 897 int _m39 = mark(); 898 synPredMatched39 = true; 899 inputState.guessing++; 900 try { 901 { 902 match(SEP_OPENING_PARENTHESIS); 903 type(); 904 match(SEP_CLOSING_PARENTHESIS); 905 unaryExpression(); 906 } 907 } 908 catch (RecognitionException pe) { 909 synPredMatched39 = false; 910 } 911 rewind(_m39); 912 inputState.guessing--; 913 } 914 if ( synPredMatched39 ) { 915 castExpression(); 916 astFactory.addASTChild(currentAST, returnAST); 917 } 918 else if ((_tokenSet_2.member(LA(1))) && (_tokenSet_3.member(LA(2)))) { 919 postfixExpression(); 920 astFactory.addASTChild(currentAST, returnAST); 921 } 922 else { 923 throw new NoViableAltException(LT(1), getFilename()); 924 } 925 } 926 } 927 unaryExpressionNotPlusMinus_AST = currentAST.root; 928 returnAST = unaryExpressionNotPlusMinus_AST; 929 } 930 931 public final void castExpression() throws RecognitionException, TokenStreamException { 932 933 returnAST = null; 934 ASTPair currentAST = new ASTPair(); 935 AST castExpression_AST = null; 936 937 match(SEP_OPENING_PARENTHESIS); 938 type(); 939 astFactory.addASTChild(currentAST, returnAST); 940 match(SEP_CLOSING_PARENTHESIS); 941 unaryExpression(); 942 astFactory.addASTChild(currentAST, returnAST); 943 if ( inputState.guessing==0 ) { 944 castExpression_AST = currentAST.root; 945 castExpression_AST = astFactory.make( (new ASTArray(2)).add(astFactory.create(CAST,"CAST")).add(castExpression_AST)); 946 currentAST.root = castExpression_AST; 947 currentAST.child = castExpression_AST!=null &&castExpression_AST.getFirstChild()!=null ? 948 castExpression_AST.getFirstChild() : castExpression_AST; 949 currentAST.advanceChildToEnd(); 950 } 951 castExpression_AST = currentAST.root; 952 returnAST = castExpression_AST; 953 } 954 955 public final void multiplicativeExpression() throws RecognitionException, TokenStreamException { 956 957 returnAST = null; 958 ASTPair currentAST = new ASTPair(); 959 AST multiplicativeExpression_AST = null; 960 961 unaryExpression(); 962 astFactory.addASTChild(currentAST, returnAST); 963 { 964 _loop44: 965 do { 966 if ((LA(1)==OP_MULTIPLY||LA(1)==OP_DIVIDE)) { 967 { 968 switch ( LA(1)) { 969 case OP_MULTIPLY: 970 { 971 AST tmp32_AST = null; 972 tmp32_AST = astFactory.create(LT(1)); 973 astFactory.makeASTRoot(currentAST, tmp32_AST); 974 match(OP_MULTIPLY); 975 break; 976 } 977 case OP_DIVIDE: 978 { 979 AST tmp33_AST = null; 980 tmp33_AST = astFactory.create(LT(1)); 981 astFactory.makeASTRoot(currentAST, tmp33_AST); 982 match(OP_DIVIDE); 983 break; 984 } 985 default: 986 { 987 throw new NoViableAltException(LT(1), getFilename()); 988 } 989 } 990 } 991 unaryExpression(); 992 astFactory.addASTChild(currentAST, returnAST); 993 } 994 else { 995 break _loop44; 996 } 997 998 } while (true); 999 } 1000 multiplicativeExpression_AST = currentAST.root; 1001 returnAST = multiplicativeExpression_AST; 1002 } 1003 1004 public final void additiveExpression() throws RecognitionException, TokenStreamException { 1005 1006 returnAST = null; 1007 ASTPair currentAST = new ASTPair(); 1008 AST additiveExpression_AST = null; 1009 1010 multiplicativeExpression(); 1011 astFactory.addASTChild(currentAST, returnAST); 1012 { 1013 _loop48: 1014 do { 1015 if ((LA(1)==OP_BINARY_PLUS||LA(1)==OP_BINARY_MINUS)) { 1016 { 1017 switch ( LA(1)) { 1018 case OP_BINARY_PLUS: 1019 { 1020 AST tmp34_AST = null; 1021 tmp34_AST = astFactory.create(LT(1)); 1022 astFactory.makeASTRoot(currentAST, tmp34_AST); 1023 match(OP_BINARY_PLUS); 1024 break; 1025 } 1026 case OP_BINARY_MINUS: 1027 { 1028 AST tmp35_AST = null; 1029 tmp35_AST = astFactory.create(LT(1)); 1030 astFactory.makeASTRoot(currentAST, tmp35_AST); 1031 match(OP_BINARY_MINUS); 1032 break; 1033 } 1034 default: 1035 { 1036 throw new NoViableAltException(LT(1), getFilename()); 1037 } 1038 } 1039 } 1040 multiplicativeExpression(); 1041 astFactory.addASTChild(currentAST, returnAST); 1042 } 1043 else { 1044 break _loop48; 1045 } 1046 1047 } while (true); 1048 } 1049 additiveExpression_AST = currentAST.root; 1050 returnAST = additiveExpression_AST; 1051 } 1052 1053 public final void relationalExpression() throws RecognitionException, TokenStreamException { 1054 1055 returnAST = null; 1056 ASTPair currentAST = new ASTPair(); 1057 AST relationalExpression_AST = null; 1058 1059 additiveExpression(); 1060 astFactory.addASTChild(currentAST, returnAST); 1061 { 1062 _loop52: 1063 do { 1064 if ((_tokenSet_4.member(LA(1)))) { 1065 { 1066 switch ( LA(1)) { 1067 case OP_LOWER: 1068 { 1069 AST tmp36_AST = null; 1070 tmp36_AST = astFactory.create(LT(1)); 1071 astFactory.makeASTRoot(currentAST, tmp36_AST); 1072 match(OP_LOWER); 1073 break; 1074 } 1075 case OP_GREATER: 1076 { 1077 AST tmp37_AST = null; 1078 tmp37_AST = astFactory.create(LT(1)); 1079 astFactory.makeASTRoot(currentAST, tmp37_AST); 1080 match(OP_GREATER); 1081 break; 1082 } 1083 case OP_LOWER_OR_EQUAL: 1084 { 1085 AST tmp38_AST = null; 1086 tmp38_AST = astFactory.create(LT(1)); 1087 astFactory.makeASTRoot(currentAST, tmp38_AST); 1088 match(OP_LOWER_OR_EQUAL); 1089 break; 1090 } 1091 case OP_GREATER_OR_EQUAL: 1092 { 1093 AST tmp39_AST = null; 1094 tmp39_AST = astFactory.create(LT(1)); 1095 astFactory.makeASTRoot(currentAST, tmp39_AST); 1096 match(OP_GREATER_OR_EQUAL); 1097 break; 1098 } 1099 default: 1100 { 1101 throw new NoViableAltException(LT(1), getFilename()); 1102 } 1103 } 1104 } 1105 additiveExpression(); 1106 astFactory.addASTChild(currentAST, returnAST); 1107 } 1108 else { 1109 break _loop52; 1110 } 1111 1112 } while (true); 1113 } 1114 relationalExpression_AST = currentAST.root; 1115 returnAST = relationalExpression_AST; 1116 } 1117 1118 public final void equalityExpression() throws RecognitionException, TokenStreamException { 1119 1120 returnAST = null; 1121 ASTPair currentAST = new ASTPair(); 1122 AST equalityExpression_AST = null; 1123 1124 relationalExpression(); 1125 astFactory.addASTChild(currentAST, returnAST); 1126 { 1127 _loop56: 1128 do { 1129 if ((LA(1)==OP_NOT_EQUAL||LA(1)==OP_EQUAL)) { 1130 { 1131 switch ( LA(1)) { 1132 case OP_EQUAL: 1133 { 1134 AST tmp40_AST = null; 1135 tmp40_AST = astFactory.create(LT(1)); 1136 astFactory.makeASTRoot(currentAST, tmp40_AST); 1137 match(OP_EQUAL); 1138 break; 1139 } 1140 case OP_NOT_EQUAL: 1141 { 1142 AST tmp41_AST = null; 1143 tmp41_AST = astFactory.create(LT(1)); 1144 astFactory.makeASTRoot(currentAST, tmp41_AST); 1145 match(OP_NOT_EQUAL); 1146 break; 1147 } 1148 default: 1149 { 1150 throw new NoViableAltException(LT(1), getFilename()); 1151 } 1152 } 1153 } 1154 relationalExpression(); 1155 astFactory.addASTChild(currentAST, returnAST); 1156 } 1157 else { 1158 break _loop56; 1159 } 1160 1161 } while (true); 1162 } 1163 equalityExpression_AST = currentAST.root; 1164 returnAST = equalityExpression_AST; 1165 } 1166 1167 public final void andExpression() throws RecognitionException, TokenStreamException { 1168 1169 returnAST = null; 1170 ASTPair currentAST = new ASTPair(); 1171 AST andExpression_AST = null; 1172 1173 equalityExpression(); 1174 astFactory.addASTChild(currentAST, returnAST); 1175 { 1176 _loop59: 1177 do { 1178 if ((LA(1)==OP_BITWISE_AND)) { 1179 AST tmp42_AST = null; 1180 tmp42_AST = astFactory.create(LT(1)); 1181 astFactory.makeASTRoot(currentAST, tmp42_AST); 1182 match(OP_BITWISE_AND); 1183 equalityExpression(); 1184 astFactory.addASTChild(currentAST, returnAST); 1185 } 1186 else { 1187 break _loop59; 1188 } 1189 1190 } while (true); 1191 } 1192 andExpression_AST = currentAST.root; 1193 returnAST = andExpression_AST; 1194 } 1195 1196 public final void exclusiveOrExpression() throws RecognitionException, TokenStreamException { 1197 1198 returnAST = null; 1199 ASTPair currentAST = new ASTPair(); 1200 AST exclusiveOrExpression_AST = null; 1201 1202 andExpression(); 1203 astFactory.addASTChild(currentAST, returnAST); 1204 { 1205 _loop62: 1206 do { 1207 if ((LA(1)==OP_BITWISE_XOR)) { 1208 AST tmp43_AST = null; 1209 tmp43_AST = astFactory.create(LT(1)); 1210 astFactory.makeASTRoot(currentAST, tmp43_AST); 1211 match(OP_BITWISE_XOR); 1212 andExpression(); 1213 astFactory.addASTChild(currentAST, returnAST); 1214 } 1215 else { 1216 break _loop62; 1217 } 1218 1219 } while (true); 1220 } 1221 exclusiveOrExpression_AST = currentAST.root; 1222 returnAST = exclusiveOrExpression_AST; 1223 } 1224 1225 public final void inclusiveOrExpression() throws RecognitionException, TokenStreamException { 1226 1227 returnAST = null; 1228 ASTPair currentAST = new ASTPair(); 1229 AST inclusiveOrExpression_AST = null; 1230 1231 exclusiveOrExpression(); 1232 astFactory.addASTChild(currentAST, returnAST); 1233 { 1234 _loop65: 1235 do { 1236 if ((LA(1)==OP_BITWISE_OR)) { 1237 AST tmp44_AST = null; 1238 tmp44_AST = astFactory.create(LT(1)); 1239 astFactory.makeASTRoot(currentAST, tmp44_AST); 1240 match(OP_BITWISE_OR); 1241 exclusiveOrExpression(); 1242 astFactory.addASTChild(currentAST, returnAST); 1243 } 1244 else { 1245 break _loop65; 1246 } 1247 1248 } while (true); 1249 } 1250 inclusiveOrExpression_AST = currentAST.root; 1251 returnAST = inclusiveOrExpression_AST; 1252 } 1253 1254 public final void conditionalAndExpression() throws RecognitionException, TokenStreamException { 1255 1256 returnAST = null; 1257 ASTPair currentAST = new ASTPair(); 1258 AST conditionalAndExpression_AST = null; 1259 1260 inclusiveOrExpression(); 1261 astFactory.addASTChild(currentAST, returnAST); 1262 { 1263 _loop68: 1264 do { 1265 if ((LA(1)==OP_AND)) { 1266 AST tmp45_AST = null; 1267 tmp45_AST = astFactory.create(LT(1)); 1268 astFactory.makeASTRoot(currentAST, tmp45_AST); 1269 match(OP_AND); 1270 inclusiveOrExpression(); 1271 astFactory.addASTChild(currentAST, returnAST); 1272 } 1273 else { 1274 break _loop68; 1275 } 1276 1277 } while (true); 1278 } 1279 conditionalAndExpression_AST = currentAST.root; 1280 returnAST = conditionalAndExpression_AST; 1281 } 1282 1283 public final void conditionalOrExpression() throws RecognitionException, TokenStreamException { 1284 1285 returnAST = null; 1286 ASTPair currentAST = new ASTPair(); 1287 AST conditionalOrExpression_AST = null; 1288 1289 conditionalAndExpression(); 1290 astFactory.addASTChild(currentAST, returnAST); 1291 { 1292 _loop71: 1293 do { 1294 if ((LA(1)==OP_OR)) { 1295 AST tmp46_AST = null; 1296 tmp46_AST = astFactory.create(LT(1)); 1297 astFactory.makeASTRoot(currentAST, tmp46_AST); 1298 match(OP_OR); 1299 conditionalAndExpression(); 1300 astFactory.addASTChild(currentAST, returnAST); 1301 } 1302 else { 1303 break _loop71; 1304 } 1305 1306 } while (true); 1307 } 1308 conditionalOrExpression_AST = currentAST.root; 1309 returnAST = conditionalOrExpression_AST; 1310 } 1311 1312 public final void dummyExpressionUsage() throws RecognitionException, TokenStreamException { 1313 1314 returnAST = null; 1315 ASTPair currentAST = new ASTPair(); 1316 AST dummyExpressionUsage_AST = null; 1317 1318 expression(); 1319 astFactory.addASTChild(currentAST, returnAST); 1320 dummyExpressionUsage_AST = currentAST.root; 1321 returnAST = dummyExpressionUsage_AST; 1322 } 1323 1324 public final void primitiveType() throws RecognitionException, TokenStreamException { 1325 1326 returnAST = null; 1327 ASTPair currentAST = new ASTPair(); 1328 AST primitiveType_AST = null; 1329 1330 { 1331 switch ( LA(1)) { 1332 case LITERAL_BOOLEAN: 1333 { 1334 AST tmp47_AST = null; 1335 tmp47_AST = astFactory.create(LT(1)); 1336 astFactory.addASTChild(currentAST, tmp47_AST); 1337 match(LITERAL_BOOLEAN); 1338 break; 1339 } 1340 case LITERAL_BYTE: 1341 { 1342 AST tmp48_AST = null; 1343 tmp48_AST = astFactory.create(LT(1)); 1344 astFactory.addASTChild(currentAST, tmp48_AST); 1345 match(LITERAL_BYTE); 1346 break; 1347 } 1348 case LITERAL_SHORT: 1349 { 1350 AST tmp49_AST = null; 1351 tmp49_AST = astFactory.create(LT(1)); 1352 astFactory.addASTChild(currentAST, tmp49_AST); 1353 match(LITERAL_SHORT); 1354 break; 1355 } 1356 case LITERAL_INT: 1357 { 1358 AST tmp50_AST = null; 1359 tmp50_AST = astFactory.create(LT(1)); 1360 astFactory.addASTChild(currentAST, tmp50_AST); 1361 match(LITERAL_INT); 1362 break; 1363 } 1364 case LITERAL_LONG: 1365 { 1366 AST tmp51_AST = null; 1367 tmp51_AST = astFactory.create(LT(1)); 1368 astFactory.addASTChild(currentAST, tmp51_AST); 1369 match(LITERAL_LONG); 1370 break; 1371 } 1372 case LITERAL_CHAR: 1373 { 1374 AST tmp52_AST = null; 1375 tmp52_AST = astFactory.create(LT(1)); 1376 astFactory.addASTChild(currentAST, tmp52_AST); 1377 match(LITERAL_CHAR); 1378 break; 1379 } 1380 case LITERAL_FLOAT: 1381 { 1382 AST tmp53_AST = null; 1383 tmp53_AST = astFactory.create(LT(1)); 1384 astFactory.addASTChild(currentAST, tmp53_AST); 1385 match(LITERAL_FLOAT); 1386 break; 1387 } 1388 case LITERAL_DOUBLE: 1389 { 1390 AST tmp54_AST = null; 1391 tmp54_AST = astFactory.create(LT(1)); 1392 astFactory.addASTChild(currentAST, tmp54_AST); 1393 match(LITERAL_DOUBLE); 1394 break; 1395 } 1396 default: 1397 { 1398 throw new NoViableAltException(LT(1), getFilename()); 1399 } 1400 } 1401 } 1402 if ( inputState.guessing==0 ) { 1403 primitiveType_AST = currentAST.root; 1404 primitiveType_AST.setType(PRIMITIVE_TYPE); 1405 } 1406 primitiveType_AST = currentAST.root; 1407 returnAST = primitiveType_AST; 1408 } 1409 1410 1411 public static final String [] _tokenNames = { 1412 "<0>", 1413 "EOF", 1414 "<2>", 1415 "NULL_TREE_LOOKAHEAD", 1416 "PARAMETERS", 1417 "PARAMETER", 1418 "VARIABLES", 1419 "VARIABLE", 1420 "IMPORTS", 1421 "IMPORT", 1422 "ON_DEMAND_IMPORT", 1423 "ORDERSPECS", 1424 "ORDERSPEC", 1425 "EXPR", 1426 "CAST", 1427 "METHOD_INVOCATION", 1428 "ARG_LIST", 1429 "NAME_EXPRESSION", 1430 "PRIMITIVE_TYPE", 1431 "NAME", 1432 "\"import\"", 1433 "\"ascending\"", 1434 "\"descending\"", 1435 "\"true\"", 1436 "\"false\"", 1437 "\"null\"", 1438 "\"this\"", 1439 "\"boolean\"", 1440 "\"byte\"", 1441 "\"short\"", 1442 "\"int\"", 1443 "\"long\"", 1444 "\"char\"", 1445 "\"float\"", 1446 "\"double\"", 1447 "OP_GREATER_OR_EQUAL", 1448 "OP_LOWER_OR_EQUAL", 1449 "OP_NOT_EQUAL", 1450 "OP_AND", 1451 "OP_OR", 1452 "OP_UNARY_MINUS", 1453 "OP_UNARY_PLUS", 1454 "SEP_DOT", 1455 "FLOATING_POINT_LITERAL", 1456 "INTEGER_LITERAL", 1457 "SEP_OPENING_PARENTHESIS", 1458 "SEP_CLOSING_PARENTHESIS", 1459 "SEP_SEMICOLON", 1460 "SEP_COMMA", 1461 "OP_EQUAL", 1462 "OP_GREATER", 1463 "OP_LOWER", 1464 "OP_NOT", 1465 "OP_BITWISE_COMPLEMENT", 1466 "OP_BITWISE_AND", 1467 "OP_BITWISE_OR", 1468 "OP_BITWISE_XOR", 1469 "OP_BINARY_PLUS", 1470 "OP_BINARY_MINUS", 1471 "OP_MULTIPLY", 1472 "OP_DIVIDE", 1473 "WHITESPACE", 1474 "IDENTIFIER", 1475 "CHARACTER_LITERAL", 1476 "STRING_LITERAL", 1477 "INT_OR_FLOAT_LITERAL_OR_DOT", 1478 "LINE_TERMINATOR", 1479 "ESCAPE_SEQUENCE", 1480 "UNICODE_ESCAPE", 1481 "OCTAL_ESCAPE", 1482 "OCTAL_DIGIT", 1483 "DIGIT", 1484 "HEX_DIGIT", 1485 "EXPONENT_PART", 1486 "INTEGER_TYPE_SUFFIX", 1487 "FLOAT_TYPE_SUFFIX", 1488 "IDENTIFIER_START", 1489 "IDENTIFIER_PART" 1490 }; 1491 1492 protected void buildTokenTypeASTClassMap() { 1493 tokenTypeToASTClassMap=null; 1494 }; 1495 1496 private static final long[] mk_tokenSet_0() { 1497 long[] data = { 4611686052652908544L, 0L}; 1498 return data; 1499 } 1500 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); 1501 private static final long[] mk_tokenSet_1() { 1502 long[] data = { -4165768082540724224L, 1L, 0L, 0L}; 1503 return data; 1504 } 1505 public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1()); 1506 private static final long[] mk_tokenSet_2() { 1507 long[] data = { -4611624445650403328L, 1L, 0L, 0L}; 1508 return data; 1509 } 1510 public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2()); 1511 private static final long[] mk_tokenSet_3() { 1512 long[] data = { -2305987079464550398L, 1L, 0L, 0L}; 1513 return data; 1514 } 1515 public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3()); 1516 private static final long[] mk_tokenSet_4() { 1517 long[] data = { 3377802799742976L, 0L}; 1518 return data; 1519 } 1520 public static final BitSet _tokenSet_4 = new BitSet(mk_tokenSet_4()); 1521 1522 } 1523 | Popular Tags |