001 // $ANTLR 2.7.7 (2006-11-01): "CExpr.g" -> "CExprParser.java"$ 002 003 // This file is part of the program FRYSK. 004 // 005 // Copyright 2005, 2007 Red Hat Inc. 006 // 007 // FRYSK is free software; you can redistribute it and/or modify it 008 // under the terms of the GNU General Public License as published by 009 // the Free Software Foundation; version 2 of the License. 010 // 011 // FRYSK is distributed in the hope that it will be useful, but 012 // WITHOUT ANY WARRANTY; without even the implied warranty of 013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 // General Public License for more details. 015 // 016 // You should have received a copy of the GNU General Public License 017 // along with FRYSK; if not, write to the Free Software Foundation, 018 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 019 // 020 // In addition, as a special exception, Red Hat, Inc. gives You the 021 // additional right to link the code of FRYSK with code not covered 022 // under the GNU General Public License ("Non-GPL Code") and to 023 // distribute linked combinations including the two, subject to the 024 // limitations in this paragraph. Non-GPL Code permitted under this 025 // exception must only link to the code of FRYSK through those well 026 // defined interfaces identified in the file named EXCEPTION found in 027 // the source code files (the "Approved Interfaces"). The files of 028 // Non-GPL Code may instantiate templates or use macros or inline 029 // functions from the Approved Interfaces without causing the 030 // resulting work to be covered by the GNU General Public 031 // License. Only Red Hat, Inc. may make changes or additions to the 032 // list of Approved Interfaces. You must obey the GNU General Public 033 // License in all respects for all of the FRYSK code and other code 034 // used in conjunction with FRYSK except the Non-GPL Code covered by 035 // this exception. If you modify this file, you may extend this 036 // exception to your version of the file, but you are not obligated to 037 // do so. If you do not wish to provide this exception without 038 // modification, you must delete this exception statement from your 039 // version and license this file solely under the GPL without 040 // exception. 041 package frysk.expr; 042 043 import antlr.TokenBuffer; 044 import antlr.TokenStreamException; 045 // import antlr.TokenStreamIOException; 046 // import antlr.ANTLRException; 047 // import antlr.LLkParser; 048 import antlr.Token; 049 import antlr.TokenStream; 050 import antlr.RecognitionException; 051 import antlr.NoViableAltException; 052 // import antlr.MismatchedTokenException; 053 // import antlr.SemanticException; 054 import antlr.ParserSharedInputState; 055 import antlr.collections.impl.BitSet; 056 import antlr.collections.AST; 057 // import java.util.Hashtable; 058 import antlr.ASTFactory; 059 import antlr.ASTPair; 060 import antlr.collections.impl.ASTArray; 061 062 public class CExprParser extends antlr.LLkParser implements CExprParserTokenTypes 063 { 064 065 private int assign_stmt_RHS_found; 066 //private String sInputExpression; 067 068 protected CExprParser(TokenStream lexer, String sInput) 069 { 070 this(lexer); 071 } 072 073 protected CExprParser(TokenBuffer tokenBuf, int k) { 074 super(tokenBuf,k); 075 tokenNames = _tokenNames; 076 buildTokenTypeASTClassMap(); 077 astFactory = new ASTFactory(getTokenTypeToASTClassMap()); 078 } 079 080 public CExprParser(TokenBuffer tokenBuf) { 081 this(tokenBuf,2); 082 } 083 084 protected CExprParser(TokenStream lexer, int k) { 085 super(lexer,k); 086 tokenNames = _tokenNames; 087 buildTokenTypeASTClassMap(); 088 astFactory = new ASTFactory(getTokenTypeToASTClassMap()); 089 } 090 091 public CExprParser(TokenStream lexer) { 092 this(lexer,2); 093 } 094 095 public CExprParser(ParserSharedInputState state) { 096 super(state,2); 097 tokenNames = _tokenNames; 098 buildTokenTypeASTClassMap(); 099 astFactory = new ASTFactory(getTokenTypeToASTClassMap()); 100 } 101 102 /** 103 * These tokens are never returned by the Lexer. These are imaginary 104 * tokens used as root nodes in the generated Abstract Syntax Tree. 105 */ 106 public final void imaginaryTokenDefinitions() throws RecognitionException, TokenStreamException { 107 108 returnAST = null; 109 ASTPair currentAST = new ASTPair(); 110 AST imaginaryTokenDefinitions_AST = null; 111 112 AST tmp1_AST = null; 113 tmp1_AST = astFactory.create(LT(1)); 114 astFactory.addASTChild(currentAST, tmp1_AST); 115 match(ADDRESS_OF); 116 AST tmp2_AST = null; 117 tmp2_AST = astFactory.create(LT(1)); 118 astFactory.addASTChild(currentAST, tmp2_AST); 119 match(ARG_LIST); 120 AST tmp3_AST = null; 121 tmp3_AST = astFactory.create(LT(1)); 122 astFactory.addASTChild(currentAST, tmp3_AST); 123 match(CAST); 124 AST tmp4_AST = null; 125 tmp4_AST = astFactory.create(LT(1)); 126 astFactory.addASTChild(currentAST, tmp4_AST); 127 match(COND_EXPR); 128 AST tmp5_AST = null; 129 tmp5_AST = astFactory.create(LT(1)); 130 astFactory.addASTChild(currentAST, tmp5_AST); 131 match(EXPR_LIST); 132 AST tmp6_AST = null; 133 tmp6_AST = astFactory.create(LT(1)); 134 astFactory.addASTChild(currentAST, tmp6_AST); 135 match(FUNC_CALL); 136 AST tmp7_AST = null; 137 tmp7_AST = astFactory.create(LT(1)); 138 astFactory.addASTChild(currentAST, tmp7_AST); 139 match(MEMORY); 140 AST tmp8_AST = null; 141 tmp8_AST = astFactory.create(LT(1)); 142 astFactory.addASTChild(currentAST, tmp8_AST); 143 match(MEMBER); 144 AST tmp9_AST = null; 145 tmp9_AST = astFactory.create(LT(1)); 146 astFactory.addASTChild(currentAST, tmp9_AST); 147 match(SIZEOF); 148 AST tmp10_AST = null; 149 tmp10_AST = astFactory.create(LT(1)); 150 astFactory.addASTChild(currentAST, tmp10_AST); 151 match(INDEX); 152 AST tmp11_AST = null; 153 tmp11_AST = astFactory.create(LT(1)); 154 astFactory.addASTChild(currentAST, tmp11_AST); 155 match(SLICE); 156 AST tmp12_AST = null; 157 tmp12_AST = astFactory.create(LT(1)); 158 astFactory.addASTChild(currentAST, tmp12_AST); 159 match(ARITHMETIC_PLUS); 160 AST tmp13_AST = null; 161 tmp13_AST = astFactory.create(LT(1)); 162 astFactory.addASTChild(currentAST, tmp13_AST); 163 match(ARITHMETIC_MINUS); 164 AST tmp14_AST = null; 165 tmp14_AST = astFactory.create(LT(1)); 166 astFactory.addASTChild(currentAST, tmp14_AST); 167 match(PREINCREMENT); 168 AST tmp15_AST = null; 169 tmp15_AST = astFactory.create(LT(1)); 170 astFactory.addASTChild(currentAST, tmp15_AST); 171 match(PREDECREMENT); 172 AST tmp16_AST = null; 173 tmp16_AST = astFactory.create(LT(1)); 174 astFactory.addASTChild(currentAST, tmp16_AST); 175 match(POSTINCREMENT); 176 AST tmp17_AST = null; 177 tmp17_AST = astFactory.create(LT(1)); 178 astFactory.addASTChild(currentAST, tmp17_AST); 179 match(POSTDECREMENT); 180 imaginaryTokenDefinitions_AST = (AST)currentAST.root; 181 returnAST = imaginaryTokenDefinitions_AST; 182 } 183 184 /** 185 * The TabException propagates all the way up, to the start rule, 186 * which then propagates it up to the calling program. 187 */ 188 public final void start() throws RecognitionException, TokenStreamException { 189 190 returnAST = null; 191 ASTPair currentAST = new ASTPair(); 192 AST start_AST = null; 193 194 expressionList(); 195 astFactory.addASTChild(currentAST, returnAST); 196 AST tmp18_AST = null; 197 tmp18_AST = astFactory.create(LT(1)); 198 astFactory.addASTChild(currentAST, tmp18_AST); 199 match(Token.EOF_TYPE); 200 start_AST = (AST)currentAST.root; 201 returnAST = start_AST; 202 } 203 204 /** 205 * This rule looks for comma separated expressions. 206 */ 207 public final void expressionList() throws RecognitionException, TokenStreamException { 208 209 returnAST = null; 210 ASTPair currentAST = new ASTPair(); 211 AST expressionList_AST = null; 212 213 expression(); 214 astFactory.addASTChild(currentAST, returnAST); 215 { 216 _loop5: 217 do { 218 if ((LA(1)==COMMA)) { 219 match(COMMA); 220 expression(); 221 astFactory.addASTChild(currentAST, returnAST); 222 } 223 else { 224 break _loop5; 225 } 226 227 } while (true); 228 } 229 if ( inputState.guessing==0 ) { 230 expressionList_AST = (AST)currentAST.root; 231 expressionList_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(EXPR_LIST,"Expr list")).add(expressionList_AST)); 232 currentAST.root = expressionList_AST; 233 currentAST.child = expressionList_AST!=null &&expressionList_AST.getFirstChild()!=null ? 234 expressionList_AST.getFirstChild() : expressionList_AST; 235 currentAST.advanceChildToEnd(); 236 } 237 expressionList_AST = (AST)currentAST.root; 238 returnAST = expressionList_AST; 239 } 240 241 public final void expression() throws RecognitionException, TokenStreamException { 242 243 returnAST = null; 244 ASTPair currentAST = new ASTPair(); 245 AST expression_AST = null; 246 AST assign_expr1_AST = null; 247 248 assignment_expression(); 249 assign_expr1_AST = (AST)returnAST; 250 if ( inputState.guessing==0 ) { 251 expression_AST = (AST)currentAST.root; 252 253 /** 254 * The following syntax is used for generation of ASTs. 255 * The # before a symbol refers to the AST for that symbol. 256 * ## refers to the AST returned by this rule (expression) 257 */ 258 259 expression_AST = assign_expr1_AST; 260 261 currentAST.root = expression_AST; 262 currentAST.child = expression_AST!=null &&expression_AST.getFirstChild()!=null ? 263 expression_AST.getFirstChild() : expression_AST; 264 currentAST.advanceChildToEnd(); 265 } 266 returnAST = expression_AST; 267 } 268 269 /** 270 * Assignment expressions of the form "expr1 = expr2 = expr3". 271 * Notice that the operator can by any assignment operator. 272 */ 273 public final void assignment_expression() throws RecognitionException, TokenStreamException { 274 275 returnAST = null; 276 ASTPair currentAST = new ASTPair(); 277 AST assignment_expression_AST = null; 278 AST c_AST = null; 279 AST a_AST = null; 280 AST r_AST = null; 281 282 { 283 conditional_expression(); 284 c_AST = (AST)returnAST; 285 { 286 switch ( LA(1)) { 287 case ASSIGNEQUAL: 288 case TIMESEQUAL: 289 case DIVIDEEQUAL: 290 case MINUSEQUAL: 291 case PLUSEQUAL: 292 case MODEQUAL: 293 case SHIFTLEFTEQUAL: 294 case SHIFTRIGHTEQUAL: 295 case BITWISEANDEQUAL: 296 case BITWISEXOREQUAL: 297 case BITWISEOREQUAL: 298 { 299 assign_op(); 300 a_AST = (AST)returnAST; 301 remainder_expression(); 302 r_AST = (AST)returnAST; 303 break; 304 } 305 case EOF: 306 case COMMA: 307 case RPAREN: 308 case COLON: 309 case RSQUARE: 310 { 311 break; 312 } 313 default: 314 { 315 throw new NoViableAltException(LT(1), getFilename()); 316 } 317 } 318 } 319 } 320 if ( inputState.guessing==0 ) { 321 assignment_expression_AST = (AST)currentAST.root; 322 323 if (a_AST != null) 324 assignment_expression_AST = (AST)astFactory.make( (new ASTArray(3)).add(a_AST).add(c_AST).add(r_AST)); 325 else 326 assignment_expression_AST = c_AST; 327 328 currentAST.root = assignment_expression_AST; 329 currentAST.child = assignment_expression_AST!=null &&assignment_expression_AST.getFirstChild()!=null ? 330 assignment_expression_AST.getFirstChild() : assignment_expression_AST; 331 currentAST.advanceChildToEnd(); 332 } 333 returnAST = assignment_expression_AST; 334 } 335 336 /** 337 * Various types of assignment operators like +=, *=, /= etc. 338 */ 339 public final void assign_op() throws RecognitionException, TokenStreamException { 340 341 returnAST = null; 342 ASTPair currentAST = new ASTPair(); 343 AST assign_op_AST = null; 344 345 switch ( LA(1)) { 346 case ASSIGNEQUAL: 347 { 348 AST tmp20_AST = null; 349 tmp20_AST = astFactory.create(LT(1)); 350 astFactory.makeASTRoot(currentAST, tmp20_AST); 351 match(ASSIGNEQUAL); 352 assign_op_AST = (AST)currentAST.root; 353 break; 354 } 355 case TIMESEQUAL: 356 { 357 AST tmp21_AST = null; 358 tmp21_AST = astFactory.create(LT(1)); 359 astFactory.makeASTRoot(currentAST, tmp21_AST); 360 match(TIMESEQUAL); 361 assign_op_AST = (AST)currentAST.root; 362 break; 363 } 364 case DIVIDEEQUAL: 365 { 366 AST tmp22_AST = null; 367 tmp22_AST = astFactory.create(LT(1)); 368 astFactory.makeASTRoot(currentAST, tmp22_AST); 369 match(DIVIDEEQUAL); 370 assign_op_AST = (AST)currentAST.root; 371 break; 372 } 373 case MINUSEQUAL: 374 { 375 AST tmp23_AST = null; 376 tmp23_AST = astFactory.create(LT(1)); 377 astFactory.makeASTRoot(currentAST, tmp23_AST); 378 match(MINUSEQUAL); 379 assign_op_AST = (AST)currentAST.root; 380 break; 381 } 382 case PLUSEQUAL: 383 { 384 AST tmp24_AST = null; 385 tmp24_AST = astFactory.create(LT(1)); 386 astFactory.makeASTRoot(currentAST, tmp24_AST); 387 match(PLUSEQUAL); 388 assign_op_AST = (AST)currentAST.root; 389 break; 390 } 391 case MODEQUAL: 392 { 393 AST tmp25_AST = null; 394 tmp25_AST = astFactory.create(LT(1)); 395 astFactory.makeASTRoot(currentAST, tmp25_AST); 396 match(MODEQUAL); 397 assign_op_AST = (AST)currentAST.root; 398 break; 399 } 400 case SHIFTLEFTEQUAL: 401 { 402 AST tmp26_AST = null; 403 tmp26_AST = astFactory.create(LT(1)); 404 astFactory.makeASTRoot(currentAST, tmp26_AST); 405 match(SHIFTLEFTEQUAL); 406 assign_op_AST = (AST)currentAST.root; 407 break; 408 } 409 case SHIFTRIGHTEQUAL: 410 { 411 AST tmp27_AST = null; 412 tmp27_AST = astFactory.create(LT(1)); 413 astFactory.makeASTRoot(currentAST, tmp27_AST); 414 match(SHIFTRIGHTEQUAL); 415 assign_op_AST = (AST)currentAST.root; 416 break; 417 } 418 case BITWISEANDEQUAL: 419 { 420 AST tmp28_AST = null; 421 tmp28_AST = astFactory.create(LT(1)); 422 astFactory.makeASTRoot(currentAST, tmp28_AST); 423 match(BITWISEANDEQUAL); 424 assign_op_AST = (AST)currentAST.root; 425 break; 426 } 427 case BITWISEXOREQUAL: 428 { 429 AST tmp29_AST = null; 430 tmp29_AST = astFactory.create(LT(1)); 431 astFactory.makeASTRoot(currentAST, tmp29_AST); 432 match(BITWISEXOREQUAL); 433 assign_op_AST = (AST)currentAST.root; 434 break; 435 } 436 case BITWISEOREQUAL: 437 { 438 AST tmp30_AST = null; 439 tmp30_AST = astFactory.create(LT(1)); 440 astFactory.makeASTRoot(currentAST, tmp30_AST); 441 match(BITWISEOREQUAL); 442 assign_op_AST = (AST)currentAST.root; 443 break; 444 } 445 default: 446 { 447 throw new NoViableAltException(LT(1), getFilename()); 448 } 449 } 450 returnAST = assign_op_AST; 451 } 452 453 /** 454 * Conditional expressions of the form 455 * (logical_expr)?expr:expr 456 */ 457 public final void conditional_expression() throws RecognitionException, TokenStreamException { 458 459 returnAST = null; 460 ASTPair currentAST = new ASTPair(); 461 AST conditional_expression_AST = null; 462 AST log_or_expr_AST = null; 463 Token ques = null; 464 // AST ques_AST = null; 465 AST expr_AST = null; 466 // Token colon = null; 467 // AST colon_AST = null; 468 AST cond_expr_AST = null; 469 470 logical_or_expression(); 471 log_or_expr_AST = (AST)returnAST; 472 { 473 switch ( LA(1)) { 474 case QUESTIONMARK: 475 { 476 ques = LT(1); 477 // ques_AST = astFactory.create(ques); 478 match(QUESTIONMARK); 479 expression(); 480 expr_AST = (AST)returnAST; 481 // colon = LT(1); 482 // colon_AST = astFactory.create(colon); 483 match(COLON); 484 conditional_expression(); 485 cond_expr_AST = (AST)returnAST; 486 break; 487 } 488 case EOF: 489 case COMMA: 490 case ASSIGNEQUAL: 491 case TIMESEQUAL: 492 case DIVIDEEQUAL: 493 case MINUSEQUAL: 494 case PLUSEQUAL: 495 case MODEQUAL: 496 case SHIFTLEFTEQUAL: 497 case SHIFTRIGHTEQUAL: 498 case BITWISEANDEQUAL: 499 case BITWISEXOREQUAL: 500 case BITWISEOREQUAL: 501 case RPAREN: 502 case COLON: 503 case RSQUARE: 504 { 505 break; 506 } 507 default: 508 { 509 throw new NoViableAltException(LT(1), getFilename()); 510 } 511 } 512 } 513 if ( inputState.guessing==0 ) { 514 conditional_expression_AST = (AST)currentAST.root; 515 516 if (ques != null) 517 conditional_expression_AST = (AST)astFactory.make( (new ASTArray(4)).add(astFactory.create(COND_EXPR,"ConditionalExpression")).add(log_or_expr_AST).add(expr_AST).add(cond_expr_AST)); 518 else 519 conditional_expression_AST = log_or_expr_AST; 520 521 currentAST.root = conditional_expression_AST; 522 currentAST.child = conditional_expression_AST!=null &&conditional_expression_AST.getFirstChild()!=null ? 523 conditional_expression_AST.getFirstChild() : conditional_expression_AST; 524 currentAST.advanceChildToEnd(); 525 } 526 returnAST = conditional_expression_AST; 527 } 528 529 public final void remainder_expression() throws RecognitionException, TokenStreamException { 530 531 returnAST = null; 532 ASTPair currentAST = new ASTPair(); 533 AST remainder_expression_AST = null; 534 535 { 536 boolean synPredMatched15 = false; 537 if (((_tokenSet_0.member(LA(1))) && (_tokenSet_1.member(LA(2))))) { 538 int _m15 = mark(); 539 synPredMatched15 = true; 540 inputState.guessing++; 541 try { 542 { 543 conditional_expression(); 544 { 545 switch ( LA(1)) { 546 case COMMA: 547 { 548 match(COMMA); 549 break; 550 } 551 case SEMICOLON: 552 { 553 match(SEMICOLON); 554 break; 555 } 556 case RPAREN: 557 { 558 match(RPAREN); 559 break; 560 } 561 default: 562 { 563 throw new NoViableAltException(LT(1), getFilename()); 564 } 565 } 566 } 567 } 568 } 569 catch (RecognitionException pe) { 570 synPredMatched15 = false; 571 } 572 rewind(_m15); 573 inputState.guessing--; 574 } 575 if ( synPredMatched15 ) { 576 if ( inputState.guessing==0 ) { 577 assign_stmt_RHS_found += 1; 578 } 579 assignment_expression(); 580 astFactory.addASTChild(currentAST, returnAST); 581 if ( inputState.guessing==0 ) { 582 583 if (assign_stmt_RHS_found > 0) 584 assign_stmt_RHS_found -= 1; 585 else { 586 System.out.println(LT(1).getLine() + 587 "warning Error in assign_stmt_RHS_found = " + 588 assign_stmt_RHS_found + "\n"); 589 System.out.println("Press return to continue\n"); 590 } 591 592 } 593 } 594 else if ((_tokenSet_0.member(LA(1))) && (_tokenSet_1.member(LA(2)))) { 595 assignment_expression(); 596 astFactory.addASTChild(currentAST, returnAST); 597 } 598 else { 599 throw new NoViableAltException(LT(1), getFilename()); 600 } 601 602 } 603 remainder_expression_AST = (AST)currentAST.root; 604 returnAST = remainder_expression_AST; 605 } 606 607 public final void logical_or_expression() throws RecognitionException, TokenStreamException { 608 609 returnAST = null; 610 ASTPair currentAST = new ASTPair(); 611 AST logical_or_expression_AST = null; 612 613 logical_and_expression(); 614 astFactory.addASTChild(currentAST, returnAST); 615 { 616 _loop20: 617 do { 618 if ((LA(1)==OR)) { 619 AST tmp31_AST = null; 620 tmp31_AST = astFactory.create(LT(1)); 621 astFactory.makeASTRoot(currentAST, tmp31_AST); 622 match(OR); 623 logical_and_expression(); 624 astFactory.addASTChild(currentAST, returnAST); 625 } 626 else { 627 break _loop20; 628 } 629 630 } while (true); 631 } 632 logical_or_expression_AST = (AST)currentAST.root; 633 returnAST = logical_or_expression_AST; 634 } 635 636 public final void logical_and_expression() throws RecognitionException, TokenStreamException { 637 638 returnAST = null; 639 ASTPair currentAST = new ASTPair(); 640 AST logical_and_expression_AST = null; 641 642 bitwise_inclusive_or_expression(); 643 astFactory.addASTChild(currentAST, returnAST); 644 { 645 _loop23: 646 do { 647 if ((LA(1)==AND)) { 648 AST tmp32_AST = null; 649 tmp32_AST = astFactory.create(LT(1)); 650 astFactory.makeASTRoot(currentAST, tmp32_AST); 651 match(AND); 652 bitwise_inclusive_or_expression(); 653 astFactory.addASTChild(currentAST, returnAST); 654 } 655 else { 656 break _loop23; 657 } 658 659 } while (true); 660 } 661 logical_and_expression_AST = (AST)currentAST.root; 662 returnAST = logical_and_expression_AST; 663 } 664 665 public final void bitwise_inclusive_or_expression() throws RecognitionException, TokenStreamException { 666 667 returnAST = null; 668 ASTPair currentAST = new ASTPair(); 669 AST bitwise_inclusive_or_expression_AST = null; 670 671 bitwise_exclusive_or_expression(); 672 astFactory.addASTChild(currentAST, returnAST); 673 { 674 _loop26: 675 do { 676 if ((LA(1)==BITWISEOR)) { 677 AST tmp33_AST = null; 678 tmp33_AST = astFactory.create(LT(1)); 679 astFactory.makeASTRoot(currentAST, tmp33_AST); 680 match(BITWISEOR); 681 bitwise_exclusive_or_expression(); 682 astFactory.addASTChild(currentAST, returnAST); 683 } 684 else { 685 break _loop26; 686 } 687 688 } while (true); 689 } 690 bitwise_inclusive_or_expression_AST = (AST)currentAST.root; 691 returnAST = bitwise_inclusive_or_expression_AST; 692 } 693 694 public final void bitwise_exclusive_or_expression() throws RecognitionException, TokenStreamException { 695 696 returnAST = null; 697 ASTPair currentAST = new ASTPair(); 698 AST bitwise_exclusive_or_expression_AST = null; 699 700 bitwise_and_expression(); 701 astFactory.addASTChild(currentAST, returnAST); 702 { 703 _loop29: 704 do { 705 if ((LA(1)==BITWISEXOR)) { 706 AST tmp34_AST = null; 707 tmp34_AST = astFactory.create(LT(1)); 708 astFactory.makeASTRoot(currentAST, tmp34_AST); 709 match(BITWISEXOR); 710 bitwise_and_expression(); 711 astFactory.addASTChild(currentAST, returnAST); 712 } 713 else { 714 break _loop29; 715 } 716 717 } while (true); 718 } 719 bitwise_exclusive_or_expression_AST = (AST)currentAST.root; 720 returnAST = bitwise_exclusive_or_expression_AST; 721 } 722 723 public final void bitwise_and_expression() throws RecognitionException, TokenStreamException { 724 725 returnAST = null; 726 ASTPair currentAST = new ASTPair(); 727 AST bitwise_and_expression_AST = null; 728 729 equality_expression(); 730 astFactory.addASTChild(currentAST, returnAST); 731 { 732 _loop32: 733 do { 734 if ((LA(1)==AMPERSAND)) { 735 AST tmp35_AST = null; 736 tmp35_AST = astFactory.create(LT(1)); 737 astFactory.makeASTRoot(currentAST, tmp35_AST); 738 match(AMPERSAND); 739 equality_expression(); 740 astFactory.addASTChild(currentAST, returnAST); 741 } 742 else { 743 break _loop32; 744 } 745 746 } while (true); 747 } 748 bitwise_and_expression_AST = (AST)currentAST.root; 749 returnAST = bitwise_and_expression_AST; 750 } 751 752 public final void equality_expression() throws RecognitionException, TokenStreamException { 753 754 returnAST = null; 755 ASTPair currentAST = new ASTPair(); 756 AST equality_expression_AST = null; 757 758 relational_expression(); 759 astFactory.addASTChild(currentAST, returnAST); 760 { 761 _loop36: 762 do { 763 if ((LA(1)==NOTEQUAL||LA(1)==EQUAL)) { 764 { 765 switch ( LA(1)) { 766 case NOTEQUAL: 767 { 768 AST tmp36_AST = null; 769 tmp36_AST = astFactory.create(LT(1)); 770 astFactory.makeASTRoot(currentAST, tmp36_AST); 771 match(NOTEQUAL); 772 break; 773 } 774 case EQUAL: 775 { 776 AST tmp37_AST = null; 777 tmp37_AST = astFactory.create(LT(1)); 778 astFactory.makeASTRoot(currentAST, tmp37_AST); 779 match(EQUAL); 780 break; 781 } 782 default: 783 { 784 throw new NoViableAltException(LT(1), getFilename()); 785 } 786 } 787 } 788 relational_expression(); 789 astFactory.addASTChild(currentAST, returnAST); 790 } 791 else { 792 break _loop36; 793 } 794 795 } while (true); 796 } 797 equality_expression_AST = (AST)currentAST.root; 798 returnAST = equality_expression_AST; 799 } 800 801 public final void relational_expression() throws RecognitionException, TokenStreamException { 802 803 returnAST = null; 804 ASTPair currentAST = new ASTPair(); 805 AST relational_expression_AST = null; 806 807 shift_expression(); 808 astFactory.addASTChild(currentAST, returnAST); 809 { 810 _loop40: 811 do { 812 if (((LA(1) >= LESSTHAN && LA(1) <= GREATERTHANOREQUALTO))) { 813 { 814 switch ( LA(1)) { 815 case LESSTHAN: 816 { 817 AST tmp38_AST = null; 818 tmp38_AST = astFactory.create(LT(1)); 819 astFactory.makeASTRoot(currentAST, tmp38_AST); 820 match(LESSTHAN); 821 break; 822 } 823 case GREATERTHAN: 824 { 825 AST tmp39_AST = null; 826 tmp39_AST = astFactory.create(LT(1)); 827 astFactory.makeASTRoot(currentAST, tmp39_AST); 828 match(GREATERTHAN); 829 break; 830 } 831 case LESSTHANOREQUALTO: 832 { 833 AST tmp40_AST = null; 834 tmp40_AST = astFactory.create(LT(1)); 835 astFactory.makeASTRoot(currentAST, tmp40_AST); 836 match(LESSTHANOREQUALTO); 837 break; 838 } 839 case GREATERTHANOREQUALTO: 840 { 841 AST tmp41_AST = null; 842 tmp41_AST = astFactory.create(LT(1)); 843 astFactory.makeASTRoot(currentAST, tmp41_AST); 844 match(GREATERTHANOREQUALTO); 845 break; 846 } 847 default: 848 { 849 throw new NoViableAltException(LT(1), getFilename()); 850 } 851 } 852 } 853 shift_expression(); 854 astFactory.addASTChild(currentAST, returnAST); 855 } 856 else { 857 break _loop40; 858 } 859 860 } while (true); 861 } 862 relational_expression_AST = (AST)currentAST.root; 863 returnAST = relational_expression_AST; 864 } 865 866 public final void shift_expression() throws RecognitionException, TokenStreamException { 867 868 returnAST = null; 869 ASTPair currentAST = new ASTPair(); 870 AST shift_expression_AST = null; 871 872 additive_expression(); 873 astFactory.addASTChild(currentAST, returnAST); 874 { 875 _loop44: 876 do { 877 if ((LA(1)==SHIFTLEFT||LA(1)==SHIFTRIGHT)) { 878 { 879 switch ( LA(1)) { 880 case SHIFTLEFT: 881 { 882 AST tmp42_AST = null; 883 tmp42_AST = astFactory.create(LT(1)); 884 astFactory.makeASTRoot(currentAST, tmp42_AST); 885 match(SHIFTLEFT); 886 break; 887 } 888 case SHIFTRIGHT: 889 { 890 AST tmp43_AST = null; 891 tmp43_AST = astFactory.create(LT(1)); 892 astFactory.makeASTRoot(currentAST, tmp43_AST); 893 match(SHIFTRIGHT); 894 break; 895 } 896 default: 897 { 898 throw new NoViableAltException(LT(1), getFilename()); 899 } 900 } 901 } 902 additive_expression(); 903 astFactory.addASTChild(currentAST, returnAST); 904 } 905 else { 906 break _loop44; 907 } 908 909 } while (true); 910 } 911 shift_expression_AST = (AST)currentAST.root; 912 returnAST = shift_expression_AST; 913 } 914 915 public final void additive_expression() throws RecognitionException, TokenStreamException { 916 917 returnAST = null; 918 ASTPair currentAST = new ASTPair(); 919 AST additive_expression_AST = null; 920 921 multiplicative_expression(); 922 astFactory.addASTChild(currentAST, returnAST); 923 { 924 _loop48: 925 do { 926 if ((LA(1)==PLUS||LA(1)==MINUS)) { 927 { 928 switch ( LA(1)) { 929 case PLUS: 930 { 931 AST tmp44_AST = null; 932 tmp44_AST = astFactory.create(LT(1)); 933 astFactory.makeASTRoot(currentAST, tmp44_AST); 934 match(PLUS); 935 break; 936 } 937 case MINUS: 938 { 939 AST tmp45_AST = null; 940 tmp45_AST = astFactory.create(LT(1)); 941 astFactory.makeASTRoot(currentAST, tmp45_AST); 942 match(MINUS); 943 break; 944 } 945 default: 946 { 947 throw new NoViableAltException(LT(1), getFilename()); 948 } 949 } 950 } 951 multiplicative_expression(); 952 astFactory.addASTChild(currentAST, returnAST); 953 } 954 else { 955 break _loop48; 956 } 957 958 } while (true); 959 } 960 additive_expression_AST = (AST)currentAST.root; 961 returnAST = additive_expression_AST; 962 } 963 964 public final void multiplicative_expression() throws RecognitionException, TokenStreamException { 965 966 returnAST = null; 967 ASTPair currentAST = new ASTPair(); 968 AST multiplicative_expression_AST = null; 969 970 member_selection_expression(); 971 astFactory.addASTChild(currentAST, returnAST); 972 { 973 _loop52: 974 do { 975 if (((LA(1) >= STAR && LA(1) <= MOD))) { 976 { 977 switch ( LA(1)) { 978 case STAR: 979 { 980 AST tmp46_AST = null; 981 tmp46_AST = astFactory.create(LT(1)); 982 astFactory.makeASTRoot(currentAST, tmp46_AST); 983 match(STAR); 984 break; 985 } 986 case DIVIDE: 987 { 988 AST tmp47_AST = null; 989 tmp47_AST = astFactory.create(LT(1)); 990 astFactory.makeASTRoot(currentAST, tmp47_AST); 991 match(DIVIDE); 992 break; 993 } 994 case MOD: 995 { 996 AST tmp48_AST = null; 997 tmp48_AST = astFactory.create(LT(1)); 998 astFactory.makeASTRoot(currentAST, tmp48_AST); 999 match(MOD); 1000 break; 1001 } 1002 default: 1003 { 1004 throw new NoViableAltException(LT(1), getFilename()); 1005 } 1006 } 1007 } 1008 member_selection_expression(); 1009 astFactory.addASTChild(currentAST, returnAST); 1010 } 1011 else { 1012 break _loop52; 1013 } 1014 1015 } while (true); 1016 } 1017 multiplicative_expression_AST = (AST)currentAST.root; 1018 returnAST = multiplicative_expression_AST; 1019 } 1020 1021 public final void member_selection_expression() throws RecognitionException, TokenStreamException { 1022 1023 returnAST = null; 1024 ASTPair currentAST = new ASTPair(); 1025 AST member_selection_expression_AST = null; 1026 1027 prefix_expression(); 1028 astFactory.addASTChild(currentAST, returnAST); 1029 { 1030 _loop56: 1031 do { 1032 if ((LA(1)==DOTSTAR||LA(1)==POINTERSTAR)) { 1033 { 1034 switch ( LA(1)) { 1035 case DOTSTAR: 1036 { 1037 AST tmp49_AST = null; 1038 tmp49_AST = astFactory.create(LT(1)); 1039 astFactory.makeASTRoot(currentAST, tmp49_AST); 1040 match(DOTSTAR); 1041 break; 1042 } 1043 case POINTERSTAR: 1044 { 1045 AST tmp50_AST = null; 1046 tmp50_AST = astFactory.create(LT(1)); 1047 astFactory.makeASTRoot(currentAST, tmp50_AST); 1048 match(POINTERSTAR); 1049 break; 1050 } 1051 default: 1052 { 1053 throw new NoViableAltException(LT(1), getFilename()); 1054 } 1055 } 1056 } 1057 prefix_expression(); 1058 astFactory.addASTChild(currentAST, returnAST); 1059 } 1060 else { 1061 break _loop56; 1062 } 1063 1064 } while (true); 1065 } 1066 member_selection_expression_AST = (AST)currentAST.root; 1067 returnAST = member_selection_expression_AST; 1068 } 1069 1070 public final void prefix_expression() throws RecognitionException, TokenStreamException { 1071 1072 returnAST = null; 1073 ASTPair currentAST = new ASTPair(); 1074 AST prefix_expression_AST = null; 1075 AST expr_AST = null; 1076 AST pp_expr_AST = null; 1077 AST mm_expr_AST = null; 1078 AST n_expr_AST = null; 1079 AST p_expr_AST = null; 1080 AST addr_expr_AST = null; 1081 AST dref_expr_AST = null; 1082 1083 switch ( LA(1)) { 1084 case LITERAL_sizeof: 1085 { 1086 match(LITERAL_sizeof); 1087 prefix_expression(); 1088 expr_AST = (AST)returnAST; 1089 astFactory.addASTChild(currentAST, returnAST); 1090 if ( inputState.guessing==0 ) { 1091 prefix_expression_AST = (AST)currentAST.root; 1092 prefix_expression_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(SIZEOF,"Size_Of")).add(expr_AST)); 1093 1094 currentAST.root = prefix_expression_AST; 1095 currentAST.child = prefix_expression_AST!=null &&prefix_expression_AST.getFirstChild()!=null ? 1096 prefix_expression_AST.getFirstChild() : prefix_expression_AST; 1097 currentAST.advanceChildToEnd(); 1098 } 1099 prefix_expression_AST = (AST)currentAST.root; 1100 break; 1101 } 1102 case PLUSPLUS: 1103 { 1104 AST tmp52_AST = null; 1105 tmp52_AST = astFactory.create(LT(1)); 1106 astFactory.makeASTRoot(currentAST, tmp52_AST); 1107 match(PLUSPLUS); 1108 prefix_expression(); 1109 pp_expr_AST = (AST)returnAST; 1110 astFactory.addASTChild(currentAST, returnAST); 1111 if ( inputState.guessing==0 ) { 1112 prefix_expression_AST = (AST)currentAST.root; 1113 prefix_expression_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(PREINCREMENT,"Preincrement")).add(pp_expr_AST)); 1114 1115 currentAST.root = prefix_expression_AST; 1116 currentAST.child = prefix_expression_AST!=null &&prefix_expression_AST.getFirstChild()!=null ? 1117 prefix_expression_AST.getFirstChild() : prefix_expression_AST; 1118 currentAST.advanceChildToEnd(); 1119 } 1120 prefix_expression_AST = (AST)currentAST.root; 1121 break; 1122 } 1123 case MINUSMINUS: 1124 { 1125 AST tmp53_AST = null; 1126 tmp53_AST = astFactory.create(LT(1)); 1127 astFactory.makeASTRoot(currentAST, tmp53_AST); 1128 match(MINUSMINUS); 1129 prefix_expression(); 1130 mm_expr_AST = (AST)returnAST; 1131 astFactory.addASTChild(currentAST, returnAST); 1132 if ( inputState.guessing==0 ) { 1133 prefix_expression_AST = (AST)currentAST.root; 1134 prefix_expression_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(PREDECREMENT,"Preincrement")).add(mm_expr_AST)); 1135 1136 currentAST.root = prefix_expression_AST; 1137 currentAST.child = prefix_expression_AST!=null &&prefix_expression_AST.getFirstChild()!=null ? 1138 prefix_expression_AST.getFirstChild() : prefix_expression_AST; 1139 currentAST.advanceChildToEnd(); 1140 } 1141 prefix_expression_AST = (AST)currentAST.root; 1142 break; 1143 } 1144 case TILDE: 1145 { 1146 AST tmp54_AST = null; 1147 tmp54_AST = astFactory.create(LT(1)); 1148 astFactory.makeASTRoot(currentAST, tmp54_AST); 1149 match(TILDE); 1150 prefix_expression(); 1151 astFactory.addASTChild(currentAST, returnAST); 1152 prefix_expression_AST = (AST)currentAST.root; 1153 break; 1154 } 1155 case NOT: 1156 { 1157 AST tmp55_AST = null; 1158 tmp55_AST = astFactory.create(LT(1)); 1159 astFactory.makeASTRoot(currentAST, tmp55_AST); 1160 match(NOT); 1161 prefix_expression(); 1162 astFactory.addASTChild(currentAST, returnAST); 1163 prefix_expression_AST = (AST)currentAST.root; 1164 break; 1165 } 1166 case MINUS: 1167 { 1168 AST tmp56_AST = null; 1169 tmp56_AST = astFactory.create(LT(1)); 1170 astFactory.makeASTRoot(currentAST, tmp56_AST); 1171 match(MINUS); 1172 prefix_expression(); 1173 n_expr_AST = (AST)returnAST; 1174 astFactory.addASTChild(currentAST, returnAST); 1175 if ( inputState.guessing==0 ) { 1176 prefix_expression_AST = (AST)currentAST.root; 1177 prefix_expression_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(ARITHMETIC_MINUS,"Arithmetic_minus")).add(n_expr_AST)); 1178 1179 currentAST.root = prefix_expression_AST; 1180 currentAST.child = prefix_expression_AST!=null &&prefix_expression_AST.getFirstChild()!=null ? 1181 prefix_expression_AST.getFirstChild() : prefix_expression_AST; 1182 currentAST.advanceChildToEnd(); 1183 } 1184 prefix_expression_AST = (AST)currentAST.root; 1185 break; 1186 } 1187 case PLUS: 1188 { 1189 AST tmp57_AST = null; 1190 tmp57_AST = astFactory.create(LT(1)); 1191 astFactory.makeASTRoot(currentAST, tmp57_AST); 1192 match(PLUS); 1193 prefix_expression(); 1194 p_expr_AST = (AST)returnAST; 1195 astFactory.addASTChild(currentAST, returnAST); 1196 if ( inputState.guessing==0 ) { 1197 prefix_expression_AST = (AST)currentAST.root; 1198 prefix_expression_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(ARITHMETIC_PLUS,"Arithmetic_plus")).add(p_expr_AST)); 1199 1200 currentAST.root = prefix_expression_AST; 1201 currentAST.child = prefix_expression_AST!=null &&prefix_expression_AST.getFirstChild()!=null ? 1202 prefix_expression_AST.getFirstChild() : prefix_expression_AST; 1203 currentAST.advanceChildToEnd(); 1204 } 1205 prefix_expression_AST = (AST)currentAST.root; 1206 break; 1207 } 1208 case AMPERSAND: 1209 { 1210 AST tmp58_AST = null; 1211 tmp58_AST = astFactory.create(LT(1)); 1212 astFactory.addASTChild(currentAST, tmp58_AST); 1213 match(AMPERSAND); 1214 prefix_expression(); 1215 addr_expr_AST = (AST)returnAST; 1216 astFactory.addASTChild(currentAST, returnAST); 1217 if ( inputState.guessing==0 ) { 1218 prefix_expression_AST = (AST)currentAST.root; 1219 prefix_expression_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(ADDRESS_OF,"Address_Of")).add(addr_expr_AST)); 1220 1221 currentAST.root = prefix_expression_AST; 1222 currentAST.child = prefix_expression_AST!=null &&prefix_expression_AST.getFirstChild()!=null ? 1223 prefix_expression_AST.getFirstChild() : prefix_expression_AST; 1224 currentAST.advanceChildToEnd(); 1225 } 1226 prefix_expression_AST = (AST)currentAST.root; 1227 break; 1228 } 1229 case STAR: 1230 { 1231 AST tmp59_AST = null; 1232 tmp59_AST = astFactory.create(LT(1)); 1233 astFactory.addASTChild(currentAST, tmp59_AST); 1234 match(STAR); 1235 postfix_expression(); 1236 dref_expr_AST = (AST)returnAST; 1237 astFactory.addASTChild(currentAST, returnAST); 1238 if ( inputState.guessing==0 ) { 1239 prefix_expression_AST = (AST)currentAST.root; 1240 prefix_expression_AST = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(MEMORY,"Memory")).add(dref_expr_AST)); 1241 1242 currentAST.root = prefix_expression_AST; 1243 currentAST.child = prefix_expression_AST!=null &&prefix_expression_AST.getFirstChild()!=null ? 1244 prefix_expression_AST.getFirstChild() : prefix_expression_AST; 1245 currentAST.advanceChildToEnd(); 1246 } 1247 prefix_expression_AST = (AST)currentAST.root; 1248 break; 1249 } 1250 default: 1251 if ((LA(1)==LPAREN) && ((LA(2) >= LITERAL_boolean && LA(2) <= LITERAL_double))) { 1252 cast_expression(); 1253 astFactory.addASTChild(currentAST, returnAST); 1254 prefix_expression_AST = (AST)currentAST.root; 1255 } 1256 else if ((_tokenSet_2.member(LA(1))) && (_tokenSet_3.member(LA(2)))) { 1257 postfix_expression(); 1258 astFactory.addASTChild(currentAST, returnAST); 1259 prefix_expression_AST = (AST)currentAST.root; 1260 } 1261 else { 1262 throw new NoViableAltException(LT(1), getFilename()); 1263 } 1264 } 1265 returnAST = prefix_expression_AST; 1266 } 1267 1268 public final void postfix_expression() throws RecognitionException, TokenStreamException { 1269 1270 returnAST = null; 1271 ASTPair currentAST = new ASTPair(); 1272 AST postfix_expression_AST = null; 1273 AST sc_expr_AST = null; 1274 Token id_expr1 = null; 1275 AST id_expr1_AST = null; 1276 Token id_expr2 = null; 1277 AST id_expr2_AST = null; 1278 AST arrExpr1_AST = null; 1279 AST arrExpr2_AST = null; 1280 AST astPostExpr = null; 1281 1282 { 1283 scope_expression(); 1284 sc_expr_AST = (AST)returnAST; 1285 if ( inputState.guessing==0 ) { 1286 astPostExpr = sc_expr_AST; 1287 } 1288 { 1289 _loop66: 1290 do { 1291 switch ( LA(1)) { 1292 case DOT: 1293 { 1294 // AST tmp60_AST = null; 1295 // tmp60_AST = astFactory.create(LT(1)); 1296 match(DOT); 1297 { 1298 switch ( LA(1)) { 1299 case IDENT_TAB: 1300 { 1301 AST tmp61_AST = null; 1302 tmp61_AST = astFactory.create(LT(1)); 1303 match(IDENT_TAB); 1304 if ( inputState.guessing==0 ) { 1305 throw new IncompleteMemberException(astPostExpr, 1306 tmp61_AST); 1307 } 1308 break; 1309 } 1310 case IDENT: 1311 { 1312 id_expr1 = LT(1); 1313 id_expr1_AST = astFactory.create(id_expr1); 1314 match(IDENT); 1315 if ( inputState.guessing==0 ) { 1316 astPostExpr = (AST)astFactory.make( (new ASTArray(3)).add(astFactory.create(MEMBER,"Member")).add(astPostExpr).add(id_expr1_AST)); 1317 } 1318 break; 1319 } 1320 default: 1321 { 1322 throw new NoViableAltException(LT(1), getFilename()); 1323 } 1324 } 1325 } 1326 break; 1327 } 1328 case POINTERTO: 1329 { 1330 // AST tmp62_AST = null; 1331 // tmp62_AST = astFactory.create(LT(1)); 1332 match(POINTERTO); 1333 { 1334 switch ( LA(1)) { 1335 case IDENT_TAB: 1336 { 1337 AST tmp63_AST = null; 1338 tmp63_AST = astFactory.create(LT(1)); 1339 match(IDENT_TAB); 1340 if ( inputState.guessing==0 ) { 1341 throw new IncompleteMemberException(astPostExpr, 1342 tmp63_AST); 1343 } 1344 break; 1345 } 1346 case IDENT: 1347 { 1348 id_expr2 = LT(1); 1349 id_expr2_AST = astFactory.create(id_expr2); 1350 match(IDENT); 1351 if ( inputState.guessing==0 ) { 1352 astPostExpr = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(MEMORY,"Memory")).add(astPostExpr)); 1353 astPostExpr = (AST)astFactory.make( (new ASTArray(3)).add(astFactory.create(MEMBER,"Member")).add(astPostExpr).add(id_expr2_AST)); 1354 } 1355 break; 1356 } 1357 default: 1358 { 1359 throw new NoViableAltException(LT(1), getFilename()); 1360 } 1361 } 1362 } 1363 break; 1364 } 1365 case LSQUARE: 1366 { 1367 // AST tmp64_AST = null; 1368 // tmp64_AST = astFactory.create(LT(1)); 1369 match(LSQUARE); 1370 expressionList(); 1371 arrExpr1_AST = (AST)returnAST; 1372 { 1373 switch ( LA(1)) { 1374 case RSQUARE: 1375 { 1376 // AST tmp65_AST = null; 1377 // tmp65_AST = astFactory.create(LT(1)); 1378 match(RSQUARE); 1379 if ( inputState.guessing==0 ) { 1380 astPostExpr = (AST)astFactory.make( (new ASTArray(3)).add(astFactory.create(INDEX,"Index")).add(astPostExpr).add(arrExpr1_AST)); 1381 } 1382 break; 1383 } 1384 case COLON: 1385 { 1386 // AST tmp66_AST = null; 1387 // tmp66_AST = astFactory.create(LT(1)); 1388 match(COLON); 1389 expressionList(); 1390 arrExpr2_AST = (AST)returnAST; 1391 // AST tmp67_AST = null; 1392 // tmp67_AST = astFactory.create(LT(1)); 1393 match(RSQUARE); 1394 if ( inputState.guessing==0 ) { 1395 astPostExpr = (AST)astFactory.make( (new ASTArray(4)).add(astFactory.create(SLICE,"Slice")).add(astPostExpr).add(arrExpr1_AST).add(arrExpr2_AST)); 1396 } 1397 break; 1398 } 1399 default: 1400 { 1401 throw new NoViableAltException(LT(1), getFilename()); 1402 } 1403 } 1404 } 1405 break; 1406 } 1407 case LPAREN: 1408 { 1409 match(LPAREN); 1410 expressionList(); 1411 match(RPAREN); 1412 break; 1413 } 1414 case PLUSPLUS: 1415 { 1416 // AST tmp70_AST = null; 1417 // tmp70_AST = astFactory.create(LT(1)); 1418 match(PLUSPLUS); 1419 if ( inputState.guessing==0 ) { 1420 astPostExpr = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(POSTINCREMENT,"Postincrement")).add(astPostExpr)); 1421 1422 } 1423 break; 1424 } 1425 case MINUSMINUS: 1426 { 1427 // AST tmp71_AST = null; 1428 // tmp71_AST = astFactory.create(LT(1)); 1429 match(MINUSMINUS); 1430 if ( inputState.guessing==0 ) { 1431 astPostExpr = (AST)astFactory.make( (new ASTArray(2)).add(astFactory.create(POSTDECREMENT,"Postdecrement")).add(astPostExpr)); 1432 1433 } 1434 break; 1435 } 1436 default: 1437 { 1438 break _loop66; 1439 } 1440 } 1441 } while (true); 1442 } 1443 } 1444 if ( inputState.guessing==0 ) { 1445 postfix_expression_AST = (AST)currentAST.root; 1446 postfix_expression_AST = astPostExpr; 1447 currentAST.root = postfix_expression_AST; 1448 currentAST.child = postfix_expression_AST!=null &&postfix_expression_AST.getFirstChild()!=null ? 1449 postfix_expression_AST.getFirstChild() : postfix_expression_AST; 1450 currentAST.advanceChildToEnd(); 1451 } 1452 returnAST = postfix_expression_AST; 1453 } 1454 1455 public final void cast_expression() throws RecognitionException, TokenStreamException { 1456 1457 returnAST = null; 1458 ASTPair currentAST = new ASTPair(); 1459 AST cast_expression_AST = null; 1460 AST tc_AST = null; 1461 AST expr_AST = null; 1462 1463 // AST tmp72_AST = null; 1464 // tmp72_AST = astFactory.create(LT(1)); 1465 match(LPAREN); 1466 primitiveType(); 1467 tc_AST = (AST)returnAST; 1468 { 1469 switch ( LA(1)) { 1470 case STAR: 1471 { 1472 // AST tmp73_AST = null; 1473 // tmp73_AST = astFactory.create(LT(1)); 1474 match(STAR); 1475 break; 1476 } 1477 case RPAREN: 1478 { 1479 break; 1480 } 1481 default: 1482 { 1483 throw new NoViableAltException(LT(1), getFilename()); 1484 } 1485 } 1486 } 1487 // AST tmp74_AST = null; 1488 // tmp74_AST = astFactory.create(LT(1)); 1489 match(RPAREN); 1490 prefix_expression(); 1491 expr_AST = (AST)returnAST; 1492 if ( inputState.guessing==0 ) { 1493 cast_expression_AST = (AST)currentAST.root; 1494 cast_expression_AST = (AST)astFactory.make( (new ASTArray(3)).add(astFactory.create(CAST,"Cast")).add(tc_AST).add(expr_AST)); 1495 currentAST.root = cast_expression_AST; 1496 currentAST.child = cast_expression_AST!=null &&cast_expression_AST.getFirstChild()!=null ? 1497 cast_expression_AST.getFirstChild() : cast_expression_AST; 1498 currentAST.advanceChildToEnd(); 1499 } 1500 returnAST = cast_expression_AST; 1501 } 1502 1503 public final void primitiveType() throws RecognitionException, TokenStreamException { 1504 1505 returnAST = null; 1506 ASTPair currentAST = new ASTPair(); 1507 AST primitiveType_AST = null; 1508 1509 switch ( LA(1)) { 1510 case LITERAL_boolean: 1511 { 1512 AST tmp75_AST = null; 1513 tmp75_AST = astFactory.create(LT(1)); 1514 astFactory.addASTChild(currentAST, tmp75_AST); 1515 match(LITERAL_boolean); 1516 primitiveType_AST = (AST)currentAST.root; 1517 break; 1518 } 1519 case LITERAL_char: 1520 { 1521 AST tmp76_AST = null; 1522 tmp76_AST = astFactory.create(LT(1)); 1523 astFactory.addASTChild(currentAST, tmp76_AST); 1524 match(LITERAL_char); 1525 primitiveType_AST = (AST)currentAST.root; 1526 break; 1527 } 1528 case LITERAL_byte: 1529 { 1530 AST tmp77_AST = null; 1531 tmp77_AST = astFactory.create(LT(1)); 1532 astFactory.addASTChild(currentAST, tmp77_AST); 1533 match(LITERAL_byte); 1534 primitiveType_AST = (AST)currentAST.root; 1535 break; 1536 } 1537 case LITERAL_short: 1538 { 1539 AST tmp78_AST = null; 1540 tmp78_AST = astFactory.create(LT(1)); 1541 astFactory.addASTChild(currentAST, tmp78_AST); 1542 match(LITERAL_short); 1543 primitiveType_AST = (AST)currentAST.root; 1544 break; 1545 } 1546 case LITERAL_int: 1547 { 1548 AST tmp79_AST = null; 1549 tmp79_AST = astFactory.create(LT(1)); 1550 astFactory.addASTChild(currentAST, tmp79_AST); 1551 match(LITERAL_int); 1552 primitiveType_AST = (AST)currentAST.root; 1553 break; 1554 } 1555 case LITERAL_long: 1556 { 1557 AST tmp80_AST = null; 1558 tmp80_AST = astFactory.create(LT(1)); 1559 astFactory.addASTChild(currentAST, tmp80_AST); 1560 match(LITERAL_long); 1561 primitiveType_AST = (AST)currentAST.root; 1562 break; 1563 } 1564 case LITERAL_float: 1565 { 1566 AST tmp81_AST = null; 1567 tmp81_AST = astFactory.create(LT(1)); 1568 astFactory.addASTChild(currentAST, tmp81_AST); 1569 match(LITERAL_float); 1570 primitiveType_AST = (AST)currentAST.root; 1571 break; 1572 } 1573 case LITERAL_double: 1574 { 1575 AST tmp82_AST = null; 1576 tmp82_AST = astFactory.create(LT(1)); 1577 astFactory.addASTChild(currentAST, tmp82_AST); 1578 match(LITERAL_double); 1579 primitiveType_AST = (AST)currentAST.root; 1580 break; 1581 } 1582 default: 1583 { 1584 throw new NoViableAltException(LT(1), getFilename()); 1585 } 1586 } 1587 returnAST = primitiveType_AST; 1588 } 1589 1590 /** 1591 * The TAB over here is not part of the C++ grammar. 1592 * This enables auto-completion by allowing the user 1593 * to press TAB whenever auto-completion is required 1594 */ 1595 public final void scope_expression() throws RecognitionException, TokenStreamException { 1596 1597 returnAST = null; 1598 ASTPair currentAST = new ASTPair(); 1599 AST scope_expression_AST = null; 1600 1601 switch ( LA(1)) { 1602 case IDENT: 1603 { 1604 AST tmp83_AST = null; 1605 tmp83_AST = astFactory.create(LT(1)); 1606 astFactory.addASTChild(currentAST, tmp83_AST); 1607 match(IDENT); 1608 { 1609 _loop70: 1610 do { 1611 if ((LA(1)==SCOPE)) { 1612 AST tmp84_AST = null; 1613 tmp84_AST = astFactory.create(LT(1)); 1614 astFactory.addASTChild(currentAST, tmp84_AST); 1615 match(SCOPE); 1616 { 1617 switch ( LA(1)) { 1618 case IDENT: 1619 { 1620 AST tmp85_AST = null; 1621 tmp85_AST = astFactory.create(LT(1)); 1622 astFactory.addASTChild(currentAST, tmp85_AST); 1623 match(IDENT); 1624 break; 1625 } 1626 case IDENT_TAB: 1627 { 1628 AST tmp86_AST = null; 1629 tmp86_AST = astFactory.create(LT(1)); 1630 astFactory.addASTChild(currentAST, tmp86_AST); 1631 match(IDENT_TAB); 1632 if ( inputState.guessing==0 ) { 1633 throw new IncompleteScopeException(tmp86_AST); 1634 } 1635 break; 1636 } 1637 default: 1638 { 1639 throw new NoViableAltException(LT(1), getFilename()); 1640 } 1641 } 1642 } 1643 } 1644 else { 1645 break _loop70; 1646 } 1647 1648 } while (true); 1649 } 1650 scope_expression_AST = (AST)currentAST.root; 1651 break; 1652 } 1653 case IDENT_TAB: 1654 { 1655 AST tmp87_AST = null; 1656 tmp87_AST = astFactory.create(LT(1)); 1657 astFactory.addASTChild(currentAST, tmp87_AST); 1658 match(IDENT_TAB); 1659 if ( inputState.guessing==0 ) { 1660 throw new IncompleteIdentifierException(tmp87_AST); 1661 } 1662 scope_expression_AST = (AST)currentAST.root; 1663 break; 1664 } 1665 case SCOPE: 1666 { 1667 AST tmp88_AST = null; 1668 tmp88_AST = astFactory.create(LT(1)); 1669 astFactory.addASTChild(currentAST, tmp88_AST); 1670 match(SCOPE); 1671 { 1672 switch ( LA(1)) { 1673 case IDENT: 1674 { 1675 AST tmp89_AST = null; 1676 tmp89_AST = astFactory.create(LT(1)); 1677 astFactory.addASTChild(currentAST, tmp89_AST); 1678 match(IDENT); 1679 break; 1680 } 1681 case IDENT_TAB: 1682 { 1683 AST tmp90_AST = null; 1684 tmp90_AST = astFactory.create(LT(1)); 1685 astFactory.addASTChild(currentAST, tmp90_AST); 1686 match(IDENT_TAB); 1687 if ( inputState.guessing==0 ) { 1688 throw new IncompleteScopeException(tmp90_AST); 1689 } 1690 break; 1691 } 1692 default: 1693 { 1694 throw new NoViableAltException(LT(1), getFilename()); 1695 } 1696 } 1697 } 1698 scope_expression_AST = (AST)currentAST.root; 1699 break; 1700 } 1701 case LPAREN: 1702 { 1703 match(LPAREN); 1704 expressionList(); 1705 astFactory.addASTChild(currentAST, returnAST); 1706 match(RPAREN); 1707 scope_expression_AST = (AST)currentAST.root; 1708 break; 1709 } 1710 case OCTALINT: 1711 case DECIMALINT: 1712 case HEXADECIMALINT: 1713 case CharLiteral: 1714 case StringLiteral: 1715 case FLOAT: 1716 case DOUBLE: 1717 case LITERAL_true: 1718 case LITERAL_false: 1719 { 1720 constant(); 1721 astFactory.addASTChild(currentAST, returnAST); 1722 scope_expression_AST = (AST)currentAST.root; 1723 break; 1724 } 1725 case LITERAL_this: 1726 { 1727 AST tmp93_AST = null; 1728 tmp93_AST = astFactory.create(LT(1)); 1729 astFactory.addASTChild(currentAST, tmp93_AST); 1730 match(LITERAL_this); 1731 scope_expression_AST = (AST)currentAST.root; 1732 break; 1733 } 1734 default: 1735 { 1736 throw new NoViableAltException(LT(1), getFilename()); 1737 } 1738 } 1739 returnAST = scope_expression_AST; 1740 } 1741 1742 public final void constant() throws RecognitionException, TokenStreamException { 1743 1744 returnAST = null; 1745 ASTPair currentAST = new ASTPair(); 1746 AST constant_AST = null; 1747 1748 switch ( LA(1)) { 1749 case OCTALINT: 1750 { 1751 AST tmp94_AST = null; 1752 tmp94_AST = astFactory.create(LT(1)); 1753 astFactory.addASTChild(currentAST, tmp94_AST); 1754 match(OCTALINT); 1755 constant_AST = (AST)currentAST.root; 1756 break; 1757 } 1758 case DECIMALINT: 1759 { 1760 AST tmp95_AST = null; 1761 tmp95_AST = astFactory.create(LT(1)); 1762 astFactory.addASTChild(currentAST, tmp95_AST); 1763 match(DECIMALINT); 1764 constant_AST = (AST)currentAST.root; 1765 break; 1766 } 1767 case HEXADECIMALINT: 1768 { 1769 AST tmp96_AST = null; 1770 tmp96_AST = astFactory.create(LT(1)); 1771 astFactory.addASTChild(currentAST, tmp96_AST); 1772 match(HEXADECIMALINT); 1773 constant_AST = (AST)currentAST.root; 1774 break; 1775 } 1776 case CharLiteral: 1777 { 1778 AST tmp97_AST = null; 1779 tmp97_AST = astFactory.create(LT(1)); 1780 astFactory.addASTChild(currentAST, tmp97_AST); 1781 match(CharLiteral); 1782 constant_AST = (AST)currentAST.root; 1783 break; 1784 } 1785 case StringLiteral: 1786 { 1787 { 1788 int _cnt75=0; 1789 _loop75: 1790 do { 1791 if ((LA(1)==StringLiteral)) { 1792 AST tmp98_AST = null; 1793 tmp98_AST = astFactory.create(LT(1)); 1794 astFactory.addASTChild(currentAST, tmp98_AST); 1795 match(StringLiteral); 1796 } 1797 else { 1798 if ( _cnt75>=1 ) { break _loop75; } else {throw new NoViableAltException(LT(1), getFilename());} 1799 } 1800 1801 _cnt75++; 1802 } while (true); 1803 } 1804 constant_AST = (AST)currentAST.root; 1805 break; 1806 } 1807 case FLOAT: 1808 { 1809 AST tmp99_AST = null; 1810 tmp99_AST = astFactory.create(LT(1)); 1811 astFactory.addASTChild(currentAST, tmp99_AST); 1812 match(FLOAT); 1813 constant_AST = (AST)currentAST.root; 1814 break; 1815 } 1816 case DOUBLE: 1817 { 1818 AST tmp100_AST = null; 1819 tmp100_AST = astFactory.create(LT(1)); 1820 astFactory.addASTChild(currentAST, tmp100_AST); 1821 match(DOUBLE); 1822 constant_AST = (AST)currentAST.root; 1823 break; 1824 } 1825 case LITERAL_true: 1826 { 1827 AST tmp101_AST = null; 1828 tmp101_AST = astFactory.create(LT(1)); 1829 astFactory.addASTChild(currentAST, tmp101_AST); 1830 match(LITERAL_true); 1831 constant_AST = (AST)currentAST.root; 1832 break; 1833 } 1834 case LITERAL_false: 1835 { 1836 AST tmp102_AST = null; 1837 tmp102_AST = astFactory.create(LT(1)); 1838 astFactory.addASTChild(currentAST, tmp102_AST); 1839 match(LITERAL_false); 1840 constant_AST = (AST)currentAST.root; 1841 break; 1842 } 1843 default: 1844 { 1845 throw new NoViableAltException(LT(1), getFilename()); 1846 } 1847 } 1848 returnAST = constant_AST; 1849 } 1850 1851 1852 public static final String[] _tokenNames = { 1853 "<0>", 1854 "EOF", 1855 "<2>", 1856 "NULL_TREE_LOOKAHEAD", 1857 "ADDRESS_OF", 1858 "ARG_LIST", 1859 "CAST", 1860 "COND_EXPR", 1861 "EXPR_LIST", 1862 "FUNC_CALL", 1863 "MEMORY", 1864 "MEMBER", 1865 "SIZEOF", 1866 "INDEX", 1867 "SLICE", 1868 "ARITHMETIC_PLUS", 1869 "ARITHMETIC_MINUS", 1870 "PREINCREMENT", 1871 "PREDECREMENT", 1872 "POSTINCREMENT", 1873 "POSTDECREMENT", 1874 "COMMA", 1875 "ASSIGNEQUAL", 1876 "TIMESEQUAL", 1877 "DIVIDEEQUAL", 1878 "MINUSEQUAL", 1879 "PLUSEQUAL", 1880 "MODEQUAL", 1881 "SHIFTLEFTEQUAL", 1882 "SHIFTRIGHTEQUAL", 1883 "BITWISEANDEQUAL", 1884 "BITWISEXOREQUAL", 1885 "BITWISEOREQUAL", 1886 "SEMICOLON", 1887 "RPAREN", 1888 "QUESTIONMARK", 1889 "COLON", 1890 "OR", 1891 "AND", 1892 "BITWISEOR", 1893 "BITWISEXOR", 1894 "AMPERSAND", 1895 "NOTEQUAL", 1896 "EQUAL", 1897 "LESSTHAN", 1898 "GREATERTHAN", 1899 "LESSTHANOREQUALTO", 1900 "GREATERTHANOREQUALTO", 1901 "SHIFTLEFT", 1902 "SHIFTRIGHT", 1903 "PLUS", 1904 "MINUS", 1905 "STAR", 1906 "DIVIDE", 1907 "MOD", 1908 "DOTSTAR", 1909 "POINTERSTAR", 1910 "\"sizeof\"", 1911 "PLUSPLUS", 1912 "MINUSMINUS", 1913 "TILDE", 1914 "NOT", 1915 "LPAREN", 1916 "DOT", 1917 "IDENT_TAB", 1918 "IDENT", 1919 "POINTERTO", 1920 "LSQUARE", 1921 "RSQUARE", 1922 "SCOPE", 1923 "\"this\"", 1924 "\"boolean\"", 1925 "\"char\"", 1926 "\"byte\"", 1927 "\"short\"", 1928 "\"int\"", 1929 "\"long\"", 1930 "\"float\"", 1931 "\"double\"", 1932 "OCTALINT", 1933 "DECIMALINT", 1934 "HEXADECIMALINT", 1935 "CharLiteral", 1936 "StringLiteral", 1937 "FLOAT", 1938 "DOUBLE", 1939 "\"true\"", 1940 "\"false\"", 1941 "\"operator\"", 1942 "AT", 1943 "ETX", 1944 "LCURLY", 1945 "RCURLY", 1946 "ELLIPSIS", 1947 "NL", 1948 "WS", 1949 "Escape", 1950 "Digit", 1951 "Decimal", 1952 "LongSuffix", 1953 "UnsignedSuffix", 1954 "FloatSuffix", 1955 "Exponent", 1956 "Vocabulary", 1957 "NUM", 1958 "HEX_DIGIT", 1959 "EXPONENT", 1960 "FLOAT_SUFFIX" 1961 }; 1962 1963 protected void buildTokenTypeASTClassMap() { 1964 tokenTypeToASTClassMap=null; 1965 } // ; 1966 1967 private static final long[] mk_tokenSet_0() { 1968 long[] data = { 9087140347150073856L, 16744547L, 0L, 0L}; 1969 return data; 1970 } 1971 public static final BitSet _tokenSet_0 = new BitSet(mk_tokenSet_0()); 1972 private static final long[] mk_tokenSet_1() { 1973 long[] data = { -8592031742L, 16777215L, 0L, 0L}; 1974 return data; 1975 } 1976 public static final BitSet _tokenSet_1 = new BitSet(mk_tokenSet_1()); 1977 private static final long[] mk_tokenSet_2() { 1978 long[] data = { 4611686018427387904L, 16744547L, 0L, 0L}; 1979 return data; 1980 } 1981 public static final BitSet _tokenSet_2 = new BitSet(mk_tokenSet_2()); 1982 private static final long[] mk_tokenSet_3() { 1983 long[] data = { -8592031742L, 16744575L, 0L, 0L}; 1984 return data; 1985 } 1986 public static final BitSet _tokenSet_3 = new BitSet(mk_tokenSet_3()); 1987 1988 }