1 3 package org.apache.ojb.jdo.jdoql; 4 5 19 20 import java.util.ArrayList ; 21 import java.util.HashMap ; 22 import java.util.List ; 23 import java.util.Map ; 24 25 import antlr.NoViableAltException; 26 import antlr.RecognitionException; 27 import antlr.collections.AST; 28 import antlr.collections.impl.BitSet; 29 30 31 public class JDOQLTreeParser extends antlr.TreeParser implements JDOQLTreeParserTokenTypes 32 { 33 public JDOQLTreeParser() { 34 tokenNames = _tokenNames; 35 } 36 37 public final Map declareParameters(AST _t) throws RecognitionException { 38 Map result; 39 40 AST declareParameters_AST_in = (_t == ASTNULL) ? null : (AST)_t; 41 42 43 LocalVariable varDecl; 44 45 result = new HashMap (); 46 47 AST __t2 = _t; 48 AST tmp1_AST_in = _t; 49 match(_t,PARAMETERS); 50 _t = _t.getFirstChild(); 51 { 52 _loop4: 53 do { 54 if (_t==null) _t=ASTNULL; 55 if ((_t.getType()==PARAMETER)) { 56 varDecl=parameter(_t); 57 _t = _retTree; 58 59 result.put(varDecl.getName(), varDecl); 60 61 } 62 else { 63 break _loop4; 64 } 65 66 } while (true); 67 } 68 _t = __t2; 69 _t = _t.getNextSibling(); 70 _retTree = _t; 71 return result; 72 } 73 74 public final LocalVariable parameter(AST _t) throws RecognitionException { 75 LocalVariable varDecl; 76 77 AST parameter_AST_in = (_t == ASTNULL) ? null : (AST)_t; 78 AST name = null; 79 80 81 Type varType = null; 82 83 AST __t6 = _t; 84 AST tmp2_AST_in = _t; 85 match(_t,PARAMETER); 86 _t = _t.getFirstChild(); 87 varType=type(_t); 88 _t = _retTree; 89 name = _t; 90 match(_t,IDENTIFIER); 91 _t = _t.getNextSibling(); 92 _t = __t6; 93 _t = _t.getNextSibling(); 94 95 varDecl = new LocalVariable(varType, name.getText()); 96 varDecl.setPosition(varType.getLine(), varType.getColumn()); 97 98 _retTree = _t; 99 return varDecl; 100 } 101 102 public final Type type(AST _t) throws RecognitionException { 103 Type result; 104 105 AST type_AST_in = (_t == ASTNULL) ? null : (AST)_t; 106 AST primitiveTypeName = null; 107 AST typeName = null; 108 109 { 110 if (_t==null) _t=ASTNULL; 111 switch ( _t.getType()) { 112 case PRIMITIVE_TYPE: 113 { 114 primitiveTypeName = _t; 115 match(_t,PRIMITIVE_TYPE); 116 _t = _t.getNextSibling(); 117 118 result = new Type(primitiveTypeName.getText(), true); 119 result.setPosition(primitiveTypeName.getLine(), primitiveTypeName.getColumn()); 120 121 break; 122 } 123 case NAME: 124 { 125 typeName = _t; 126 match(_t,NAME); 127 _t = _t.getNextSibling(); 128 129 result = new Type(typeName.getText(), false); 130 result.setPosition(typeName.getLine(), typeName.getColumn()); 131 132 break; 133 } 134 default: 135 { 136 throw new NoViableAltException(_t); 137 } 138 } 139 } 140 _retTree = _t; 141 return result; 142 } 143 144 public final Map declareVariables(AST _t) throws RecognitionException { 145 Map result; 146 147 AST declareVariables_AST_in = (_t == ASTNULL) ? null : (AST)_t; 148 149 150 LocalVariable varDecl; 151 152 result = new HashMap (); 153 154 AST __t8 = _t; 155 AST tmp3_AST_in = _t; 156 match(_t,VARIABLES); 157 _t = _t.getFirstChild(); 158 { 159 _loop10: 160 do { 161 if (_t==null) _t=ASTNULL; 162 if ((_t.getType()==VARIABLE)) { 163 varDecl=variable(_t); 164 _t = _retTree; 165 166 result.put(varDecl.getName(), varDecl); 167 168 } 169 else { 170 break _loop10; 171 } 172 173 } while (true); 174 } 175 _t = __t8; 176 _t = _t.getNextSibling(); 177 _retTree = _t; 178 return result; 179 } 180 181 public final LocalVariable variable(AST _t) throws RecognitionException { 182 LocalVariable varDecl; 183 184 AST variable_AST_in = (_t == ASTNULL) ? null : (AST)_t; 185 AST name = null; 186 187 188 Type varType = null; 189 190 AST __t12 = _t; 191 AST tmp4_AST_in = _t; 192 match(_t,VARIABLE); 193 _t = _t.getFirstChild(); 194 varType=type(_t); 195 _t = _retTree; 196 name = _t; 197 match(_t,IDENTIFIER); 198 _t = _t.getNextSibling(); 199 _t = __t12; 200 _t = _t.getNextSibling(); 201 202 varDecl = new LocalVariable(varType, name.getText()); 203 varDecl.setPosition(varType.getLine(), varType.getColumn()); 204 205 _retTree = _t; 206 return varDecl; 207 } 208 209 public final List declareImports(AST _t) throws RecognitionException { 210 List result; 211 212 AST declareImports_AST_in = (_t == ASTNULL) ? null : (AST)_t; 213 214 215 Import importDecl; 216 217 result = new ArrayList (); 218 219 AST __t14 = _t; 220 AST tmp5_AST_in = _t; 221 match(_t,IMPORTS); 222 _t = _t.getFirstChild(); 223 { 224 _loop16: 225 do { 226 if (_t==null) _t=ASTNULL; 227 if ((_t.getType()==IMPORT||_t.getType()==ON_DEMAND_IMPORT)) { 228 importDecl=importDeclaration(_t); 229 _t = _retTree; 230 231 result.add(importDecl); 232 233 } 234 else { 235 break _loop16; 236 } 237 238 } while (true); 239 } 240 _t = __t14; 241 _t = _t.getNextSibling(); 242 _retTree = _t; 243 return result; 244 } 245 246 public final Import importDeclaration(AST _t) throws RecognitionException { 247 Import importDecl; 248 249 AST importDeclaration_AST_in = (_t == ASTNULL) ? null : (AST)_t; 250 AST i1 = null; 251 AST name1 = null; 252 AST i2 = null; 253 AST name2 = null; 254 255 { 256 if (_t==null) _t=ASTNULL; 257 switch ( _t.getType()) { 258 case IMPORT: 259 { 260 AST __t19 = _t; 261 i1 = _t==ASTNULL ? null :(AST)_t; 262 match(_t,IMPORT); 263 _t = _t.getFirstChild(); 264 name1 = _t; 265 match(_t,NAME); 266 _t = _t.getNextSibling(); 267 _t = __t19; 268 _t = _t.getNextSibling(); 269 270 importDecl = new Import(name1.getText(), false); 271 importDecl.setPosition(i1.getLine(), i1.getColumn()); 272 273 break; 274 } 275 case ON_DEMAND_IMPORT: 276 { 277 AST __t20 = _t; 278 i2 = _t==ASTNULL ? null :(AST)_t; 279 match(_t,ON_DEMAND_IMPORT); 280 _t = _t.getFirstChild(); 281 name2 = _t; 282 match(_t,NAME); 283 _t = _t.getNextSibling(); 284 _t = __t20; 285 _t = _t.getNextSibling(); 286 287 importDecl = new Import(name2.getText(), true); 288 importDecl.setPosition(i2.getLine(), i2.getColumn()); 289 290 break; 291 } 292 default: 293 { 294 throw new NoViableAltException(_t); 295 } 296 } 297 } 298 _retTree = _t; 299 return importDecl; 300 } 301 302 public final List setOrdering(AST _t) throws RecognitionException { 303 List result; 304 305 AST setOrdering_AST_in = (_t == ASTNULL) ? null : (AST)_t; 306 307 308 Ordering orderingDecl; 309 310 result = new ArrayList (); 311 312 AST __t22 = _t; 313 AST tmp6_AST_in = _t; 314 match(_t,ORDERSPECS); 315 _t = _t.getFirstChild(); 316 { 317 _loop24: 318 do { 319 if (_t==null) _t=ASTNULL; 320 if ((_t.getType()==ORDERSPEC)) { 321 orderingDecl=orderSpecification(_t); 322 _t = _retTree; 323 324 result.add(orderingDecl); 325 326 } 327 else { 328 break _loop24; 329 } 330 331 } while (true); 332 } 333 _t = __t22; 334 _t = _t.getNextSibling(); 335 _retTree = _t; 336 return result; 337 } 338 339 public final Ordering orderSpecification(AST _t) throws RecognitionException { 340 Ordering orderingDecl; 341 342 AST orderSpecification_AST_in = (_t == ASTNULL) ? null : (AST)_t; 343 AST o = null; 344 345 346 Expression expr = null; 347 boolean isAscending; 348 349 AST __t26 = _t; 350 o = _t==ASTNULL ? null :(AST)_t; 351 match(_t,ORDERSPEC); 352 _t = _t.getFirstChild(); 353 expr=expression(_t); 354 _t = _retTree; 355 { 356 if (_t==null) _t=ASTNULL; 357 switch ( _t.getType()) { 358 case LITERAL_ASCENDING: 359 { 360 AST tmp7_AST_in = _t; 361 match(_t,LITERAL_ASCENDING); 362 _t = _t.getNextSibling(); 363 364 isAscending = true; 365 366 break; 367 } 368 case LITERAL_DESCENDING: 369 { 370 AST tmp8_AST_in = _t; 371 match(_t,LITERAL_DESCENDING); 372 _t = _t.getNextSibling(); 373 374 isAscending = false; 375 376 break; 377 } 378 default: 379 { 380 throw new NoViableAltException(_t); 381 } 382 } 383 } 384 _t = __t26; 385 _t = _t.getNextSibling(); 386 387 orderingDecl = new Ordering(expr, isAscending); 388 orderingDecl.setPosition(o.getLine(), o.getColumn()); 389 390 _retTree = _t; 391 return orderingDecl; 392 } 393 394 public final Expression expression(AST _t) throws RecognitionException { 395 Expression expr; 396 397 AST expression_AST_in = (_t == ASTNULL) ? null : (AST)_t; 398 399 { 400 if (_t==null) _t=ASTNULL; 401 switch ( _t.getType()) { 402 case LITERAL_TRUE: 403 case LITERAL_FALSE: 404 case FLOATING_POINT_LITERAL: 405 case INTEGER_LITERAL: 406 case CHARACTER_LITERAL: 407 case STRING_LITERAL: 408 { 409 expr=literal(_t); 410 _t = _retTree; 411 break; 412 } 413 case LITERAL_NULL: 414 { 415 expr=nullLiteral(_t); 416 _t = _retTree; 417 break; 418 } 419 case LITERAL_THIS: 420 { 421 expr=thisExpression(_t); 422 _t = _retTree; 423 break; 424 } 425 case OP_GREATER_OR_EQUAL: 426 case OP_LOWER_OR_EQUAL: 427 case OP_NOT_EQUAL: 428 case OP_AND: 429 case OP_OR: 430 case OP_EQUAL: 431 case OP_GREATER: 432 case OP_LOWER: 433 case OP_BITWISE_AND: 434 case OP_BITWISE_OR: 435 case OP_BITWISE_XOR: 436 case OP_BINARY_PLUS: 437 case OP_BINARY_MINUS: 438 case OP_MULTIPLY: 439 case OP_DIVIDE: 440 { 441 expr=binaryExpression(_t); 442 _t = _retTree; 443 break; 444 } 445 case CAST: 446 case OP_UNARY_MINUS: 447 case OP_UNARY_PLUS: 448 case OP_NOT: 449 case OP_BITWISE_COMPLEMENT: 450 { 451 expr=unaryExpression(_t); 452 _t = _retTree; 453 break; 454 } 455 case METHOD_INVOCATION: 456 { 457 expr=methodInvocation(_t); 458 _t = _retTree; 459 break; 460 } 461 case NAME_EXPRESSION: 462 { 463 expr=nameExpression(_t); 464 _t = _retTree; 465 break; 466 } 467 case SEP_DOT: 468 { 469 expr=postfixExpression(_t); 470 _t = _retTree; 471 break; 472 } 473 default: 474 { 475 throw new NoViableAltException(_t); 476 } 477 } 478 } 479 _retTree = _t; 480 return expr; 481 } 482 483 public final Literal literal(AST _t) throws RecognitionException { 484 Literal literal; 485 486 AST literal_AST_in = (_t == ASTNULL) ? null : (AST)_t; 487 AST l1 = null; 488 AST l2 = null; 489 AST l3 = null; 490 AST l4 = null; 491 AST l5 = null; 492 AST l6 = null; 493 494 { 495 if (_t==null) _t=ASTNULL; 496 switch ( _t.getType()) { 497 case LITERAL_TRUE: 498 { 499 l1 = _t; 500 match(_t,LITERAL_TRUE); 501 _t = _t.getNextSibling(); 502 503 literal = new Literal(boolean.class, l1.getText()); 504 literal.setPosition(l1.getLine(), l2.getColumn()); 505 506 break; 507 } 508 case LITERAL_FALSE: 509 { 510 l2 = _t; 511 match(_t,LITERAL_FALSE); 512 _t = _t.getNextSibling(); 513 514 literal = new Literal(boolean.class, l2.getText()); 515 literal.setPosition(l2.getLine(), l2.getColumn()); 516 517 break; 518 } 519 case INTEGER_LITERAL: 520 { 521 l3 = _t; 522 match(_t,INTEGER_LITERAL); 523 _t = _t.getNextSibling(); 524 525 literal = new Literal(long.class, l3.getText()); 526 literal.setPosition(l3.getLine(), l3.getColumn()); 527 528 break; 529 } 530 case FLOATING_POINT_LITERAL: 531 { 532 l4 = _t; 533 match(_t,FLOATING_POINT_LITERAL); 534 _t = _t.getNextSibling(); 535 536 literal = new Literal(double.class, l4.getText()); 537 literal.setPosition(l4.getLine(), l4.getColumn()); 538 539 break; 540 } 541 case CHARACTER_LITERAL: 542 { 543 l5 = _t; 544 match(_t,CHARACTER_LITERAL); 545 _t = _t.getNextSibling(); 546 547 literal = new Literal(char.class, l5.getText()); 548 literal.setPosition(l5.getLine(), l5.getColumn()); 549 550 break; 551 } 552 case STRING_LITERAL: 553 { 554 l6 = _t; 555 match(_t,STRING_LITERAL); 556 _t = _t.getNextSibling(); 557 558 literal = new Literal(String .class, l6.getText()); 559 literal.setPosition(l6.getLine(), l6.getColumn()); 560 561 break; 562 } 563 default: 564 { 565 throw new NoViableAltException(_t); 566 } 567 } 568 } 569 _retTree = _t; 570 return literal; 571 } 572 573 public final NullLiteral nullLiteral(AST _t) throws RecognitionException { 574 NullLiteral literal; 575 576 AST nullLiteral_AST_in = (_t == ASTNULL) ? null : (AST)_t; 577 AST l = null; 578 579 l = _t; 580 match(_t,LITERAL_NULL); 581 _t = _t.getNextSibling(); 582 583 literal = new NullLiteral(); 584 literal.setPosition(l.getLine(), l.getColumn()); 585 586 _retTree = _t; 587 return literal; 588 } 589 590 public final ThisExpression thisExpression(AST _t) throws RecognitionException { 591 ThisExpression expr; 592 593 AST thisExpression_AST_in = (_t == ASTNULL) ? null : (AST)_t; 594 AST l = null; 595 596 l = _t; 597 match(_t,LITERAL_THIS); 598 _t = _t.getNextSibling(); 599 600 expr = new ThisExpression(); 601 expr.setPosition(l.getLine(), l.getColumn()); 602 603 _retTree = _t; 604 return expr; 605 } 606 607 public final BinaryExpression binaryExpression(AST _t) throws RecognitionException { 608 BinaryExpression expr; 609 610 AST binaryExpression_AST_in = (_t == ASTNULL) ? null : (AST)_t; 611 AST o1 = null; 612 AST o2 = null; 613 AST o3 = null; 614 AST o4 = null; 615 AST o5 = null; 616 AST o6 = null; 617 AST o7 = null; 618 AST o8 = null; 619 AST o9 = null; 620 AST o10 = null; 621 AST o11 = null; 622 AST o12 = null; 623 AST o13 = null; 624 AST o14 = null; 625 AST o15 = null; 626 627 628 Expression left = null; 629 Expression right = null; 630 631 { 632 if (_t==null) _t=ASTNULL; 633 switch ( _t.getType()) { 634 case OP_MULTIPLY: 635 { 636 AST __t53 = _t; 637 o1 = _t==ASTNULL ? null :(AST)_t; 638 match(_t,OP_MULTIPLY); 639 _t = _t.getFirstChild(); 640 left=expression(_t); 641 _t = _retTree; 642 right=expression(_t); 643 _t = _retTree; 644 _t = __t53; 645 _t = _t.getNextSibling(); 646 647 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_MULTIPLY, right); 648 expr.setPosition(o1.getLine(), o1.getColumn()); 649 650 break; 651 } 652 case OP_DIVIDE: 653 { 654 AST __t54 = _t; 655 o2 = _t==ASTNULL ? null :(AST)_t; 656 match(_t,OP_DIVIDE); 657 _t = _t.getFirstChild(); 658 left=expression(_t); 659 _t = _retTree; 660 right=expression(_t); 661 _t = _retTree; 662 _t = __t54; 663 _t = _t.getNextSibling(); 664 665 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_DIVIDE, right); 666 expr.setPosition(o2.getLine(), o2.getColumn()); 667 668 break; 669 } 670 case OP_BINARY_PLUS: 671 { 672 AST __t55 = _t; 673 o3 = _t==ASTNULL ? null :(AST)_t; 674 match(_t,OP_BINARY_PLUS); 675 _t = _t.getFirstChild(); 676 left=expression(_t); 677 _t = _retTree; 678 right=expression(_t); 679 _t = _retTree; 680 _t = __t55; 681 _t = _t.getNextSibling(); 682 683 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_PLUS, right); 684 expr.setPosition(o3.getLine(), o3.getColumn()); 685 686 break; 687 } 688 case OP_BINARY_MINUS: 689 { 690 AST __t56 = _t; 691 o4 = _t==ASTNULL ? null :(AST)_t; 692 match(_t,OP_BINARY_MINUS); 693 _t = _t.getFirstChild(); 694 left=expression(_t); 695 _t = _retTree; 696 right=expression(_t); 697 _t = _retTree; 698 _t = __t56; 699 _t = _t.getNextSibling(); 700 701 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_MINUS, right); 702 expr.setPosition(o4.getLine(), o4.getColumn()); 703 704 break; 705 } 706 case OP_LOWER: 707 { 708 AST __t57 = _t; 709 o5 = _t==ASTNULL ? null :(AST)_t; 710 match(_t,OP_LOWER); 711 _t = _t.getFirstChild(); 712 left=expression(_t); 713 _t = _retTree; 714 right=expression(_t); 715 _t = _retTree; 716 _t = __t57; 717 _t = _t.getNextSibling(); 718 719 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_LOWER, right); 720 expr.setPosition(o5.getLine(), o5.getColumn()); 721 722 break; 723 } 724 case OP_GREATER: 725 { 726 AST __t58 = _t; 727 o6 = _t==ASTNULL ? null :(AST)_t; 728 match(_t,OP_GREATER); 729 _t = _t.getFirstChild(); 730 left=expression(_t); 731 _t = _retTree; 732 right=expression(_t); 733 _t = _retTree; 734 _t = __t58; 735 _t = _t.getNextSibling(); 736 737 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_GREATER, right); 738 expr.setPosition(o6.getLine(), o6.getColumn()); 739 740 break; 741 } 742 case OP_LOWER_OR_EQUAL: 743 { 744 AST __t59 = _t; 745 o7 = _t==ASTNULL ? null :(AST)_t; 746 match(_t,OP_LOWER_OR_EQUAL); 747 _t = _t.getFirstChild(); 748 left=expression(_t); 749 _t = _retTree; 750 right=expression(_t); 751 _t = _retTree; 752 _t = __t59; 753 _t = _t.getNextSibling(); 754 755 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_LOWER_OR_EQUAL, right); 756 expr.setPosition(o7.getLine(), o7.getColumn()); 757 758 break; 759 } 760 case OP_GREATER_OR_EQUAL: 761 { 762 AST __t60 = _t; 763 o8 = _t==ASTNULL ? null :(AST)_t; 764 match(_t,OP_GREATER_OR_EQUAL); 765 _t = _t.getFirstChild(); 766 left=expression(_t); 767 _t = _retTree; 768 right=expression(_t); 769 _t = _retTree; 770 _t = __t60; 771 _t = _t.getNextSibling(); 772 773 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_GREATER_OR_EQUAL, right); 774 expr.setPosition(o8.getLine(), o8.getColumn()); 775 776 break; 777 } 778 case OP_EQUAL: 779 { 780 AST __t61 = _t; 781 o9 = _t==ASTNULL ? null :(AST)_t; 782 match(_t,OP_EQUAL); 783 _t = _t.getFirstChild(); 784 left=expression(_t); 785 _t = _retTree; 786 right=expression(_t); 787 _t = _retTree; 788 _t = __t61; 789 _t = _t.getNextSibling(); 790 791 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_EQUAL, right); 792 expr.setPosition(o9.getLine(), o9.getColumn()); 793 794 break; 795 } 796 case OP_NOT_EQUAL: 797 { 798 AST __t62 = _t; 799 o10 = _t==ASTNULL ? null :(AST)_t; 800 match(_t,OP_NOT_EQUAL); 801 _t = _t.getFirstChild(); 802 left=expression(_t); 803 _t = _retTree; 804 right=expression(_t); 805 _t = _retTree; 806 _t = __t62; 807 _t = _t.getNextSibling(); 808 809 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_NOT_EQUAL, right); 810 expr.setPosition(o10.getLine(), o10.getColumn()); 811 812 break; 813 } 814 case OP_BITWISE_AND: 815 { 816 AST __t63 = _t; 817 o11 = _t==ASTNULL ? null :(AST)_t; 818 match(_t,OP_BITWISE_AND); 819 _t = _t.getFirstChild(); 820 left=expression(_t); 821 _t = _retTree; 822 right=expression(_t); 823 _t = _retTree; 824 _t = __t63; 825 _t = _t.getNextSibling(); 826 827 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_BITWISE_AND, right); 828 expr.setPosition(o11.getLine(), o11.getColumn()); 829 830 break; 831 } 832 case OP_BITWISE_XOR: 833 { 834 AST __t64 = _t; 835 o12 = _t==ASTNULL ? null :(AST)_t; 836 match(_t,OP_BITWISE_XOR); 837 _t = _t.getFirstChild(); 838 left=expression(_t); 839 _t = _retTree; 840 right=expression(_t); 841 _t = _retTree; 842 _t = __t64; 843 _t = _t.getNextSibling(); 844 845 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_BITWISE_XOR, right); 846 expr.setPosition(o12.getLine(), o12.getColumn()); 847 848 break; 849 } 850 case OP_BITWISE_OR: 851 { 852 AST __t65 = _t; 853 o13 = _t==ASTNULL ? null :(AST)_t; 854 match(_t,OP_BITWISE_OR); 855 _t = _t.getFirstChild(); 856 left=expression(_t); 857 _t = _retTree; 858 right=expression(_t); 859 _t = _retTree; 860 _t = __t65; 861 _t = _t.getNextSibling(); 862 863 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_BITWISE_OR, right); 864 expr.setPosition(o13.getLine(), o13.getColumn()); 865 866 break; 867 } 868 case OP_AND: 869 { 870 AST __t66 = _t; 871 o14 = _t==ASTNULL ? null :(AST)_t; 872 match(_t,OP_AND); 873 _t = _t.getFirstChild(); 874 left=expression(_t); 875 _t = _retTree; 876 right=expression(_t); 877 _t = _retTree; 878 _t = __t66; 879 _t = _t.getNextSibling(); 880 881 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_AND, right); 882 expr.setPosition(o14.getLine(), o14.getColumn()); 883 884 break; 885 } 886 case OP_OR: 887 { 888 AST __t67 = _t; 889 o15 = _t==ASTNULL ? null :(AST)_t; 890 match(_t,OP_OR); 891 _t = _t.getFirstChild(); 892 left=expression(_t); 893 _t = _retTree; 894 right=expression(_t); 895 _t = _retTree; 896 _t = __t67; 897 _t = _t.getNextSibling(); 898 899 expr = new BinaryExpression(left, BinaryExpression.OPERATOR_OR, right); 900 expr.setPosition(o15.getLine(), o15.getColumn()); 901 902 break; 903 } 904 default: 905 { 906 throw new NoViableAltException(_t); 907 } 908 } 909 } 910 _retTree = _t; 911 return expr; 912 } 913 914 public final UnaryExpression unaryExpression(AST _t) throws RecognitionException { 915 UnaryExpression expr; 916 917 AST unaryExpression_AST_in = (_t == ASTNULL) ? null : (AST)_t; 918 AST o1 = null; 919 AST o2 = null; 920 AST o3 = null; 921 AST o4 = null; 922 AST o5 = null; 923 924 925 Expression inner = null; 926 Type castType = null; 927 928 { 929 if (_t==null) _t=ASTNULL; 930 switch ( _t.getType()) { 931 case OP_UNARY_MINUS: 932 { 933 AST __t46 = _t; 934 o1 = _t==ASTNULL ? null :(AST)_t; 935 match(_t,OP_UNARY_MINUS); 936 _t = _t.getFirstChild(); 937 inner=expression(_t); 938 _t = _retTree; 939 _t = __t46; 940 _t = _t.getNextSibling(); 941 942 expr = new UnaryExpression(UnaryExpression.OPERATOR_MINUS, inner); 943 expr.setPosition(o1.getLine(), o1.getColumn()); 944 945 break; 946 } 947 case OP_UNARY_PLUS: 948 { 949 AST __t47 = _t; 950 o2 = _t==ASTNULL ? null :(AST)_t; 951 match(_t,OP_UNARY_PLUS); 952 _t = _t.getFirstChild(); 953 inner=expression(_t); 954 _t = _retTree; 955 _t = __t47; 956 _t = _t.getNextSibling(); 957 958 expr = new UnaryExpression(UnaryExpression.OPERATOR_PLUS, inner); 959 expr.setPosition(o2.getLine(), o2.getColumn()); 960 961 break; 962 } 963 case OP_BITWISE_COMPLEMENT: 964 { 965 AST __t48 = _t; 966 o3 = _t==ASTNULL ? null :(AST)_t; 967 match(_t,OP_BITWISE_COMPLEMENT); 968 _t = _t.getFirstChild(); 969 inner=expression(_t); 970 _t = _retTree; 971 _t = __t48; 972 _t = _t.getNextSibling(); 973 974 expr = new UnaryExpression(UnaryExpression.OPERATOR_BITWISE_COMPLEMENT, inner); 975 expr.setPosition(o3.getLine(), o3.getColumn()); 976 977 break; 978 } 979 case OP_NOT: 980 { 981 AST __t49 = _t; 982 o4 = _t==ASTNULL ? null :(AST)_t; 983 match(_t,OP_NOT); 984 _t = _t.getFirstChild(); 985 inner=expression(_t); 986 _t = _retTree; 987 _t = __t49; 988 _t = _t.getNextSibling(); 989 990 expr = new UnaryExpression(UnaryExpression.OPERATOR_NOT, inner); 991 expr.setPosition(o4.getLine(), o4.getColumn()); 992 993 break; 994 } 995 case CAST: 996 { 997 AST __t50 = _t; 998 o5 = _t==ASTNULL ? null :(AST)_t; 999 match(_t,CAST); 1000 _t = _t.getFirstChild(); 1001 castType=type(_t); 1002 _t = _retTree; 1003 inner=expression(_t); 1004 _t = _retTree; 1005 _t = __t50; 1006 _t = _t.getNextSibling(); 1007 1008 expr = new UnaryExpression(castType, inner); 1009 expr.setPosition(o5.getLine(), o5.getColumn()); 1010 1011 break; 1012 } 1013 default: 1014 { 1015 throw new NoViableAltException(_t); 1016 } 1017 } 1018 } 1019 _retTree = _t; 1020 return expr; 1021 } 1022 1023 public final MethodInvocation methodInvocation(AST _t) throws RecognitionException { 1024 MethodInvocation methodInvoc; 1025 1026 AST methodInvocation_AST_in = (_t == ASTNULL) ? null : (AST)_t; 1027 AST m = null; 1028 1029 1030 List args = null; 1031 1032 AST __t35 = _t; 1033 m = _t==ASTNULL ? null :(AST)_t; 1034 match(_t,METHOD_INVOCATION); 1035 _t = _t.getFirstChild(); 1036 args=argList(_t); 1037 _t = _retTree; 1038 _t = __t35; 1039 _t = _t.getNextSibling(); 1040 1041 methodInvoc = new MethodInvocation(null, m.getText(), args); 1042 methodInvoc.setPosition(m.getLine(), m.getColumn()); 1043 1044 _retTree = _t; 1045 return methodInvoc; 1046 } 1047 1048 public final NameExpression nameExpression(AST _t) throws RecognitionException { 1049 NameExpression nameExpr; 1050 1051 AST nameExpression_AST_in = (_t == ASTNULL) ? null : (AST)_t; 1052 AST expr = null; 1053 1054 expr = _t; 1055 match(_t,NAME_EXPRESSION); 1056 _t = _t.getNextSibling(); 1057 1058 nameExpr = new NameExpression(null, expr.getText()); 1059 nameExpr.setPosition(expr.getLine(), expr.getColumn()); 1060 1061 _retTree = _t; 1062 return nameExpr; 1063 } 1064 1065 public final PostfixExpression postfixExpression(AST _t) throws RecognitionException { 1066 PostfixExpression expr; 1067 1068 AST postfixExpression_AST_in = (_t == ASTNULL) ? null : (AST)_t; 1069 1070 1071 Expression baseExpr = null; 1072 PostfixExpression trailingExpr = null; 1073 1074 AST __t42 = _t; 1075 AST tmp9_AST_in = _t; 1076 match(_t,SEP_DOT); 1077 _t = _t.getFirstChild(); 1078 baseExpr=expression(_t); 1079 _t = _retTree; 1080 { 1081 if (_t==null) _t=ASTNULL; 1082 switch ( _t.getType()) { 1083 case NAME_EXPRESSION: 1084 { 1085 trailingExpr=nameExpression(_t); 1086 _t = _retTree; 1087 break; 1088 } 1089 case METHOD_INVOCATION: 1090 { 1091 trailingExpr=methodInvocation(_t); 1092 _t = _retTree; 1093 break; 1094 } 1095 default: 1096 { 1097 throw new NoViableAltException(_t); 1098 } 1099 } 1100 } 1101 _t = __t42; 1102 _t = _t.getNextSibling(); 1103 1104 expr = trailingExpr; 1105 expr.setBaseExpression(baseExpr); 1106 1107 _retTree = _t; 1108 return expr; 1109 } 1110 1111 public final List argList(AST _t) throws RecognitionException { 1112 List args; 1113 1114 AST argList_AST_in = (_t == ASTNULL) ? null : (AST)_t; 1115 1116 1117 Expression argExpr = null; 1118 1119 args = new ArrayList (); 1120 1121 AST __t37 = _t; 1122 AST tmp10_AST_in = _t; 1123 match(_t,ARG_LIST); 1124 _t = _t.getFirstChild(); 1125 { 1126 _loop39: 1127 do { 1128 if (_t==null) _t=ASTNULL; 1129 if ((_tokenSet_0.member(_t.getType()))) { 1130 argExpr=expression(_t); 1131 _t = _retTree; 1132 1133 args.add(argExpr); 1134 1135 } 1136 else { 1137 break _loop39; 1138 } 1139 1140 } while (true); 1141 } 1142 _t = __t37; 1143 _t = _t.getNextSibling(); 1144 _retTree = _t; 1145 return args; 1146 } 1147 1148 1149 public static final String [] _tokenNames = { 1150 "<0>", 1151 "EOF", 1152 "<2>", 1153 "NULL_TREE_LOOKAHEAD", 1154 "PARAMETERS", 1155 "PARAMETER", 1156 "VARIABLES", 1157 "VARIABLE", 1158 "IMPORTS", 1159 "IMPORT", 1160 "ON_DEMAND_IMPORT", 1161 "ORDERSPECS", 1162 "ORDERSPEC", 1163 "EXPR", 1164 "CAST", 1165 "METHOD_INVOCATION", 1166 "ARG_LIST", 1167 "NAME_EXPRESSION", 1168 "PRIMITIVE_TYPE", 1169 "NAME", 1170 "\"import\"", 1171 "\"ascending\"", 1172 "\"descending\"", 1173 "\"true\"", 1174 "\"false\"", 1175 "\"null\"", 1176 "\"this\"", 1177 "\"boolean\"", 1178 "\"byte\"", 1179 "\"short\"", 1180 "\"int\"", 1181 "\"long\"", 1182 "\"char\"", 1183 "\"float\"", 1184 "\"double\"", 1185 "OP_GREATER_OR_EQUAL", 1186 "OP_LOWER_OR_EQUAL", 1187 "OP_NOT_EQUAL", 1188 "OP_AND", 1189 "OP_OR", 1190 "OP_UNARY_MINUS", 1191 "OP_UNARY_PLUS", 1192 "SEP_DOT", 1193 "FLOATING_POINT_LITERAL", 1194 "INTEGER_LITERAL", 1195 "SEP_OPENING_PARENTHESIS", 1196 "SEP_CLOSING_PARENTHESIS", 1197 "SEP_SEMICOLON", 1198 "SEP_COMMA", 1199 "OP_EQUAL", 1200 "OP_GREATER", 1201 "OP_LOWER", 1202 "OP_NOT", 1203 "OP_BITWISE_COMPLEMENT", 1204 "OP_BITWISE_AND", 1205 "OP_BITWISE_OR", 1206 "OP_BITWISE_XOR", 1207 "OP_BINARY_PLUS", 1208 "OP_BINARY_MINUS", 1209 "OP_MULTIPLY", 1210 "OP_DIVIDE", 1211 "WHITESPACE", 1212 "IDENTIFIER", 1213 "CHARACTER_LITERAL", 1214 "STRING_LITERAL", 1215 "INT_OR_FLOAT_LITERAL_OR_DOT", 1216 "LINE_TERMINATOR", 1217 "ESCAPE_SEQUENCE", 1218 "UNICODE_ESCAPE", 1219 "OCTAL_ESCAPE", 1220 "OCTAL_DIGIT", 1221 "DIGIT", 1222 "HEX_DIGIT", 1223 "EXPONENT_PART", 1224 "INTEGER_TYPE_SUFFIX", 1225 "FLOAT_TYPE_SUFFIX", 1226 "IDENTIFIER_START", 1227 "IDENTIFIER_PART" 1228 }; 1229 1230 private static final long[] mk_tokenSet_0() { 1231 long[] data = { -6918056827456143360L, 1L, 0L, 0L}; 1232 return data; 1233 } 1234 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); 1235 } 1236 1237 | Popular Tags |