Home | History | Annotate | Download | only in simplecTreeParser
      1 // $ANTLR 3.2 Aug 13, 2010 14:19:31 SimpleC.g 2010-08-13 14:29:19
      2 
      3 import org.antlr.runtime.*;
      4 import java.util.Stack;
      5 import java.util.List;
      6 import java.util.ArrayList;
      7 
      8 
      9 import org.antlr.runtime.tree.*;
     10 
     11 public class SimpleCParser extends Parser {
     12     public static final String[] tokenNames = new String[] {
     13         "<invalid>", "<EOR>", "<DOWN>", "<UP>", "VAR_DEF", "ARG_DEF", "FUNC_HDR", "FUNC_DECL", "FUNC_DEF", "BLOCK", "ID", "EQ", "INT", "FOR", "INT_TYPE", "CHAR", "VOID", "EQEQ", "LT", "PLUS", "WS", "';'", "'('", "','", "')'", "'{'", "'}'"
     14     };
     15     public static final int LT=18;
     16     public static final int T__26=26;
     17     public static final int T__25=25;
     18     public static final int T__24=24;
     19     public static final int T__23=23;
     20     public static final int T__22=22;
     21     public static final int T__21=21;
     22     public static final int CHAR=15;
     23     public static final int FOR=13;
     24     public static final int FUNC_HDR=6;
     25     public static final int INT=12;
     26     public static final int FUNC_DEF=8;
     27     public static final int INT_TYPE=14;
     28     public static final int ID=10;
     29     public static final int EOF=-1;
     30     public static final int FUNC_DECL=7;
     31     public static final int ARG_DEF=5;
     32     public static final int WS=20;
     33     public static final int BLOCK=9;
     34     public static final int PLUS=19;
     35     public static final int VOID=16;
     36     public static final int EQ=11;
     37     public static final int VAR_DEF=4;
     38     public static final int EQEQ=17;
     39 
     40     // delegates
     41     // delegators
     42 
     43 
     44         public SimpleCParser(TokenStream input) {
     45             this(input, new RecognizerSharedState());
     46         }
     47         public SimpleCParser(TokenStream input, RecognizerSharedState state) {
     48             super(input, state);
     49 
     50         }
     51 
     52     protected TreeAdaptor adaptor = new CommonTreeAdaptor();
     53 
     54     public void setTreeAdaptor(TreeAdaptor adaptor) {
     55         this.adaptor = adaptor;
     56     }
     57     public TreeAdaptor getTreeAdaptor() {
     58         return adaptor;
     59     }
     60 
     61     public String[] getTokenNames() { return SimpleCParser.tokenNames; }
     62     public String getGrammarFileName() { return "SimpleC.g"; }
     63 
     64 
     65     public static class program_return extends ParserRuleReturnScope {
     66         Object tree;
     67         public Object getTree() { return tree; }
     68     };
     69 
     70     // $ANTLR start "program"
     71     // SimpleC.g:16:1: program : ( declaration )+ ;
     72     public final SimpleCParser.program_return program() throws RecognitionException {
     73         SimpleCParser.program_return retval = new SimpleCParser.program_return();
     74         retval.start = input.LT(1);
     75 
     76         Object root_0 = null;
     77 
     78         SimpleCParser.declaration_return declaration1 = null;
     79 
     80 
     81 
     82         try {
     83             // SimpleC.g:17:5: ( ( declaration )+ )
     84             // SimpleC.g:17:9: ( declaration )+
     85             {
     86             root_0 = (Object)adaptor.nil();
     87 
     88             // SimpleC.g:17:9: ( declaration )+
     89             int cnt1=0;
     90             loop1:
     91             do {
     92                 int alt1=2;
     93                 int LA1_0 = input.LA(1);
     94 
     95                 if ( (LA1_0==ID||(LA1_0>=INT_TYPE && LA1_0<=VOID)) ) {
     96                     alt1=1;
     97                 }
     98 
     99 
    100                 switch (alt1) {
    101             	case 1 :
    102             	    // SimpleC.g:17:9: declaration
    103             	    {
    104             	    pushFollow(FOLLOW_declaration_in_program85);
    105             	    declaration1=declaration();
    106 
    107             	    state._fsp--;
    108 
    109             	    adaptor.addChild(root_0, declaration1.getTree());
    110 
    111             	    }
    112             	    break;
    113 
    114             	default :
    115             	    if ( cnt1 >= 1 ) break loop1;
    116                         EarlyExitException eee =
    117                             new EarlyExitException(1, input);
    118                         throw eee;
    119                 }
    120                 cnt1++;
    121             } while (true);
    122 
    123 
    124             }
    125 
    126             retval.stop = input.LT(-1);
    127 
    128             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
    129             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    130 
    131         }
    132         catch (RecognitionException re) {
    133             reportError(re);
    134             recover(input,re);
    135     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
    136 
    137         }
    138         finally {
    139         }
    140         return retval;
    141     }
    142     // $ANTLR end "program"
    143 
    144     public static class declaration_return extends ParserRuleReturnScope {
    145         Object tree;
    146         public Object getTree() { return tree; }
    147     };
    148 
    149     // $ANTLR start "declaration"
    150     // SimpleC.g:20:1: declaration : ( variable | functionHeader ';' -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) );
    151     public final SimpleCParser.declaration_return declaration() throws RecognitionException {
    152         SimpleCParser.declaration_return retval = new SimpleCParser.declaration_return();
    153         retval.start = input.LT(1);
    154 
    155         Object root_0 = null;
    156 
    157         Token char_literal4=null;
    158         SimpleCParser.variable_return variable2 = null;
    159 
    160         SimpleCParser.functionHeader_return functionHeader3 = null;
    161 
    162         SimpleCParser.functionHeader_return functionHeader5 = null;
    163 
    164         SimpleCParser.block_return block6 = null;
    165 
    166 
    167         Object char_literal4_tree=null;
    168         RewriteRuleTokenStream stream_21=new RewriteRuleTokenStream(adaptor,"token 21");
    169         RewriteRuleSubtreeStream stream_functionHeader=new RewriteRuleSubtreeStream(adaptor,"rule functionHeader");
    170         RewriteRuleSubtreeStream stream_block=new RewriteRuleSubtreeStream(adaptor,"rule block");
    171         try {
    172             // SimpleC.g:21:5: ( variable | functionHeader ';' -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) )
    173             int alt2=3;
    174             alt2 = dfa2.predict(input);
    175             switch (alt2) {
    176                 case 1 :
    177                     // SimpleC.g:21:9: variable
    178                     {
    179                     root_0 = (Object)adaptor.nil();
    180 
    181                     pushFollow(FOLLOW_variable_in_declaration105);
    182                     variable2=variable();
    183 
    184                     state._fsp--;
    185 
    186                     adaptor.addChild(root_0, variable2.getTree());
    187 
    188                     }
    189                     break;
    190                 case 2 :
    191                     // SimpleC.g:22:9: functionHeader ';'
    192                     {
    193                     pushFollow(FOLLOW_functionHeader_in_declaration115);
    194                     functionHeader3=functionHeader();
    195 
    196                     state._fsp--;
    197 
    198                     stream_functionHeader.add(functionHeader3.getTree());
    199                     char_literal4=(Token)match(input,21,FOLLOW_21_in_declaration117);
    200                     stream_21.add(char_literal4);
    201 
    202 
    203 
    204                     // AST REWRITE
    205                     // elements: functionHeader
    206                     // token labels:
    207                     // rule labels: retval
    208                     // token list labels:
    209                     // rule list labels:
    210                     // wildcard labels:
    211                     retval.tree = root_0;
    212                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
    213 
    214                     root_0 = (Object)adaptor.nil();
    215                     // 22:28: -> ^( FUNC_DECL functionHeader )
    216                     {
    217                         // SimpleC.g:22:31: ^( FUNC_DECL functionHeader )
    218                         {
    219                         Object root_1 = (Object)adaptor.nil();
    220                         root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNC_DECL, "FUNC_DECL"), root_1);
    221 
    222                         adaptor.addChild(root_1, stream_functionHeader.nextTree());
    223 
    224                         adaptor.addChild(root_0, root_1);
    225                         }
    226 
    227                     }
    228 
    229                     retval.tree = root_0;
    230                     }
    231                     break;
    232                 case 3 :
    233                     // SimpleC.g:23:9: functionHeader block
    234                     {
    235                     pushFollow(FOLLOW_functionHeader_in_declaration135);
    236                     functionHeader5=functionHeader();
    237 
    238                     state._fsp--;
    239 
    240                     stream_functionHeader.add(functionHeader5.getTree());
    241                     pushFollow(FOLLOW_block_in_declaration137);
    242                     block6=block();
    243 
    244                     state._fsp--;
    245 
    246                     stream_block.add(block6.getTree());
    247 
    248 
    249                     // AST REWRITE
    250                     // elements: block, functionHeader
    251                     // token labels:
    252                     // rule labels: retval
    253                     // token list labels:
    254                     // rule list labels:
    255                     // wildcard labels:
    256                     retval.tree = root_0;
    257                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
    258 
    259                     root_0 = (Object)adaptor.nil();
    260                     // 23:30: -> ^( FUNC_DEF functionHeader block )
    261                     {
    262                         // SimpleC.g:23:33: ^( FUNC_DEF functionHeader block )
    263                         {
    264                         Object root_1 = (Object)adaptor.nil();
    265                         root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNC_DEF, "FUNC_DEF"), root_1);
    266 
    267                         adaptor.addChild(root_1, stream_functionHeader.nextTree());
    268                         adaptor.addChild(root_1, stream_block.nextTree());
    269 
    270                         adaptor.addChild(root_0, root_1);
    271                         }
    272 
    273                     }
    274 
    275                     retval.tree = root_0;
    276                     }
    277                     break;
    278 
    279             }
    280             retval.stop = input.LT(-1);
    281 
    282             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
    283             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    284 
    285         }
    286         catch (RecognitionException re) {
    287             reportError(re);
    288             recover(input,re);
    289     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
    290 
    291         }
    292         finally {
    293         }
    294         return retval;
    295     }
    296     // $ANTLR end "declaration"
    297 
    298     public static class variable_return extends ParserRuleReturnScope {
    299         Object tree;
    300         public Object getTree() { return tree; }
    301     };
    302 
    303     // $ANTLR start "variable"
    304     // SimpleC.g:26:1: variable : type declarator ';' -> ^( VAR_DEF type declarator ) ;
    305     public final SimpleCParser.variable_return variable() throws RecognitionException {
    306         SimpleCParser.variable_return retval = new SimpleCParser.variable_return();
    307         retval.start = input.LT(1);
    308 
    309         Object root_0 = null;
    310 
    311         Token char_literal9=null;
    312         SimpleCParser.type_return type7 = null;
    313 
    314         SimpleCParser.declarator_return declarator8 = null;
    315 
    316 
    317         Object char_literal9_tree=null;
    318         RewriteRuleTokenStream stream_21=new RewriteRuleTokenStream(adaptor,"token 21");
    319         RewriteRuleSubtreeStream stream_declarator=new RewriteRuleSubtreeStream(adaptor,"rule declarator");
    320         RewriteRuleSubtreeStream stream_type=new RewriteRuleSubtreeStream(adaptor,"rule type");
    321         try {
    322             // SimpleC.g:27:5: ( type declarator ';' -> ^( VAR_DEF type declarator ) )
    323             // SimpleC.g:27:9: type declarator ';'
    324             {
    325             pushFollow(FOLLOW_type_in_variable166);
    326             type7=type();
    327 
    328             state._fsp--;
    329 
    330             stream_type.add(type7.getTree());
    331             pushFollow(FOLLOW_declarator_in_variable168);
    332             declarator8=declarator();
    333 
    334             state._fsp--;
    335 
    336             stream_declarator.add(declarator8.getTree());
    337             char_literal9=(Token)match(input,21,FOLLOW_21_in_variable170);
    338             stream_21.add(char_literal9);
    339 
    340 
    341 
    342             // AST REWRITE
    343             // elements: declarator, type
    344             // token labels:
    345             // rule labels: retval
    346             // token list labels:
    347             // rule list labels:
    348             // wildcard labels:
    349             retval.tree = root_0;
    350             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
    351 
    352             root_0 = (Object)adaptor.nil();
    353             // 27:29: -> ^( VAR_DEF type declarator )
    354             {
    355                 // SimpleC.g:27:32: ^( VAR_DEF type declarator )
    356                 {
    357                 Object root_1 = (Object)adaptor.nil();
    358                 root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(VAR_DEF, "VAR_DEF"), root_1);
    359 
    360                 adaptor.addChild(root_1, stream_type.nextTree());
    361                 adaptor.addChild(root_1, stream_declarator.nextTree());
    362 
    363                 adaptor.addChild(root_0, root_1);
    364                 }
    365 
    366             }
    367 
    368             retval.tree = root_0;
    369             }
    370 
    371             retval.stop = input.LT(-1);
    372 
    373             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
    374             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    375 
    376         }
    377         catch (RecognitionException re) {
    378             reportError(re);
    379             recover(input,re);
    380     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
    381 
    382         }
    383         finally {
    384         }
    385         return retval;
    386     }
    387     // $ANTLR end "variable"
    388 
    389     public static class declarator_return extends ParserRuleReturnScope {
    390         Object tree;
    391         public Object getTree() { return tree; }
    392     };
    393 
    394     // $ANTLR start "declarator"
    395     // SimpleC.g:30:1: declarator : ID ;
    396     public final SimpleCParser.declarator_return declarator() throws RecognitionException {
    397         SimpleCParser.declarator_return retval = new SimpleCParser.declarator_return();
    398         retval.start = input.LT(1);
    399 
    400         Object root_0 = null;
    401 
    402         Token ID10=null;
    403 
    404         Object ID10_tree=null;
    405 
    406         try {
    407             // SimpleC.g:31:5: ( ID )
    408             // SimpleC.g:31:9: ID
    409             {
    410             root_0 = (Object)adaptor.nil();
    411 
    412             ID10=(Token)match(input,ID,FOLLOW_ID_in_declarator199);
    413             ID10_tree = (Object)adaptor.create(ID10);
    414             adaptor.addChild(root_0, ID10_tree);
    415 
    416 
    417             }
    418 
    419             retval.stop = input.LT(-1);
    420 
    421             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
    422             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    423 
    424         }
    425         catch (RecognitionException re) {
    426             reportError(re);
    427             recover(input,re);
    428     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
    429 
    430         }
    431         finally {
    432         }
    433         return retval;
    434     }
    435     // $ANTLR end "declarator"
    436 
    437     public static class functionHeader_return extends ParserRuleReturnScope {
    438         Object tree;
    439         public Object getTree() { return tree; }
    440     };
    441 
    442     // $ANTLR start "functionHeader"
    443     // SimpleC.g:34:1: functionHeader : type ID '(' ( formalParameter ( ',' formalParameter )* )? ')' -> ^( FUNC_HDR type ID ( formalParameter )+ ) ;
    444     public final SimpleCParser.functionHeader_return functionHeader() throws RecognitionException {
    445         SimpleCParser.functionHeader_return retval = new SimpleCParser.functionHeader_return();
    446         retval.start = input.LT(1);
    447 
    448         Object root_0 = null;
    449 
    450         Token ID12=null;
    451         Token char_literal13=null;
    452         Token char_literal15=null;
    453         Token char_literal17=null;
    454         SimpleCParser.type_return type11 = null;
    455 
    456         SimpleCParser.formalParameter_return formalParameter14 = null;
    457 
    458         SimpleCParser.formalParameter_return formalParameter16 = null;
    459 
    460 
    461         Object ID12_tree=null;
    462         Object char_literal13_tree=null;
    463         Object char_literal15_tree=null;
    464         Object char_literal17_tree=null;
    465         RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
    466         RewriteRuleTokenStream stream_22=new RewriteRuleTokenStream(adaptor,"token 22");
    467         RewriteRuleTokenStream stream_23=new RewriteRuleTokenStream(adaptor,"token 23");
    468         RewriteRuleTokenStream stream_24=new RewriteRuleTokenStream(adaptor,"token 24");
    469         RewriteRuleSubtreeStream stream_formalParameter=new RewriteRuleSubtreeStream(adaptor,"rule formalParameter");
    470         RewriteRuleSubtreeStream stream_type=new RewriteRuleSubtreeStream(adaptor,"rule type");
    471         try {
    472             // SimpleC.g:35:5: ( type ID '(' ( formalParameter ( ',' formalParameter )* )? ')' -> ^( FUNC_HDR type ID ( formalParameter )+ ) )
    473             // SimpleC.g:35:9: type ID '(' ( formalParameter ( ',' formalParameter )* )? ')'
    474             {
    475             pushFollow(FOLLOW_type_in_functionHeader219);
    476             type11=type();
    477 
    478             state._fsp--;
    479 
    480             stream_type.add(type11.getTree());
    481             ID12=(Token)match(input,ID,FOLLOW_ID_in_functionHeader221);
    482             stream_ID.add(ID12);
    483 
    484             char_literal13=(Token)match(input,22,FOLLOW_22_in_functionHeader223);
    485             stream_22.add(char_literal13);
    486 
    487             // SimpleC.g:35:21: ( formalParameter ( ',' formalParameter )* )?
    488             int alt4=2;
    489             int LA4_0 = input.LA(1);
    490 
    491             if ( (LA4_0==ID||(LA4_0>=INT_TYPE && LA4_0<=VOID)) ) {
    492                 alt4=1;
    493             }
    494             switch (alt4) {
    495                 case 1 :
    496                     // SimpleC.g:35:23: formalParameter ( ',' formalParameter )*
    497                     {
    498                     pushFollow(FOLLOW_formalParameter_in_functionHeader227);
    499                     formalParameter14=formalParameter();
    500 
    501                     state._fsp--;
    502 
    503                     stream_formalParameter.add(formalParameter14.getTree());
    504                     // SimpleC.g:35:39: ( ',' formalParameter )*
    505                     loop3:
    506                     do {
    507                         int alt3=2;
    508                         int LA3_0 = input.LA(1);
    509 
    510                         if ( (LA3_0==23) ) {
    511                             alt3=1;
    512                         }
    513 
    514 
    515                         switch (alt3) {
    516                     	case 1 :
    517                     	    // SimpleC.g:35:41: ',' formalParameter
    518                     	    {
    519                     	    char_literal15=(Token)match(input,23,FOLLOW_23_in_functionHeader231);
    520                     	    stream_23.add(char_literal15);
    521 
    522                     	    pushFollow(FOLLOW_formalParameter_in_functionHeader233);
    523                     	    formalParameter16=formalParameter();
    524 
    525                     	    state._fsp--;
    526 
    527                     	    stream_formalParameter.add(formalParameter16.getTree());
    528 
    529                     	    }
    530                     	    break;
    531 
    532                     	default :
    533                     	    break loop3;
    534                         }
    535                     } while (true);
    536 
    537 
    538                     }
    539                     break;
    540 
    541             }
    542 
    543             char_literal17=(Token)match(input,24,FOLLOW_24_in_functionHeader241);
    544             stream_24.add(char_literal17);
    545 
    546 
    547 
    548             // AST REWRITE
    549             // elements: ID, formalParameter, type
    550             // token labels:
    551             // rule labels: retval
    552             // token list labels:
    553             // rule list labels:
    554             // wildcard labels:
    555             retval.tree = root_0;
    556             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
    557 
    558             root_0 = (Object)adaptor.nil();
    559             // 36:9: -> ^( FUNC_HDR type ID ( formalParameter )+ )
    560             {
    561                 // SimpleC.g:36:12: ^( FUNC_HDR type ID ( formalParameter )+ )
    562                 {
    563                 Object root_1 = (Object)adaptor.nil();
    564                 root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(FUNC_HDR, "FUNC_HDR"), root_1);
    565 
    566                 adaptor.addChild(root_1, stream_type.nextTree());
    567                 adaptor.addChild(root_1, stream_ID.nextNode());
    568                 if ( !(stream_formalParameter.hasNext()) ) {
    569                     throw new RewriteEarlyExitException();
    570                 }
    571                 while ( stream_formalParameter.hasNext() ) {
    572                     adaptor.addChild(root_1, stream_formalParameter.nextTree());
    573 
    574                 }
    575                 stream_formalParameter.reset();
    576 
    577                 adaptor.addChild(root_0, root_1);
    578                 }
    579 
    580             }
    581 
    582             retval.tree = root_0;
    583             }
    584 
    585             retval.stop = input.LT(-1);
    586 
    587             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
    588             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    589 
    590         }
    591         catch (RecognitionException re) {
    592             reportError(re);
    593             recover(input,re);
    594     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
    595 
    596         }
    597         finally {
    598         }
    599         return retval;
    600     }
    601     // $ANTLR end "functionHeader"
    602 
    603     public static class formalParameter_return extends ParserRuleReturnScope {
    604         Object tree;
    605         public Object getTree() { return tree; }
    606     };
    607 
    608     // $ANTLR start "formalParameter"
    609     // SimpleC.g:39:1: formalParameter : type declarator -> ^( ARG_DEF type declarator ) ;
    610     public final SimpleCParser.formalParameter_return formalParameter() throws RecognitionException {
    611         SimpleCParser.formalParameter_return retval = new SimpleCParser.formalParameter_return();
    612         retval.start = input.LT(1);
    613 
    614         Object root_0 = null;
    615 
    616         SimpleCParser.type_return type18 = null;
    617 
    618         SimpleCParser.declarator_return declarator19 = null;
    619 
    620 
    621         RewriteRuleSubtreeStream stream_declarator=new RewriteRuleSubtreeStream(adaptor,"rule declarator");
    622         RewriteRuleSubtreeStream stream_type=new RewriteRuleSubtreeStream(adaptor,"rule type");
    623         try {
    624             // SimpleC.g:40:5: ( type declarator -> ^( ARG_DEF type declarator ) )
    625             // SimpleC.g:40:9: type declarator
    626             {
    627             pushFollow(FOLLOW_type_in_formalParameter281);
    628             type18=type();
    629 
    630             state._fsp--;
    631 
    632             stream_type.add(type18.getTree());
    633             pushFollow(FOLLOW_declarator_in_formalParameter283);
    634             declarator19=declarator();
    635 
    636             state._fsp--;
    637 
    638             stream_declarator.add(declarator19.getTree());
    639 
    640 
    641             // AST REWRITE
    642             // elements: declarator, type
    643             // token labels:
    644             // rule labels: retval
    645             // token list labels:
    646             // rule list labels:
    647             // wildcard labels:
    648             retval.tree = root_0;
    649             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
    650 
    651             root_0 = (Object)adaptor.nil();
    652             // 40:25: -> ^( ARG_DEF type declarator )
    653             {
    654                 // SimpleC.g:40:28: ^( ARG_DEF type declarator )
    655                 {
    656                 Object root_1 = (Object)adaptor.nil();
    657                 root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(ARG_DEF, "ARG_DEF"), root_1);
    658 
    659                 adaptor.addChild(root_1, stream_type.nextTree());
    660                 adaptor.addChild(root_1, stream_declarator.nextTree());
    661 
    662                 adaptor.addChild(root_0, root_1);
    663                 }
    664 
    665             }
    666 
    667             retval.tree = root_0;
    668             }
    669 
    670             retval.stop = input.LT(-1);
    671 
    672             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
    673             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    674 
    675         }
    676         catch (RecognitionException re) {
    677             reportError(re);
    678             recover(input,re);
    679     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
    680 
    681         }
    682         finally {
    683         }
    684         return retval;
    685     }
    686     // $ANTLR end "formalParameter"
    687 
    688     public static class type_return extends ParserRuleReturnScope {
    689         Object tree;
    690         public Object getTree() { return tree; }
    691     };
    692 
    693     // $ANTLR start "type"
    694     // SimpleC.g:43:1: type : ( 'int' | 'char' | 'void' | ID );
    695     public final SimpleCParser.type_return type() throws RecognitionException {
    696         SimpleCParser.type_return retval = new SimpleCParser.type_return();
    697         retval.start = input.LT(1);
    698 
    699         Object root_0 = null;
    700 
    701         Token set20=null;
    702 
    703         Object set20_tree=null;
    704 
    705         try {
    706             // SimpleC.g:44:5: ( 'int' | 'char' | 'void' | ID )
    707             // SimpleC.g:
    708             {
    709             root_0 = (Object)adaptor.nil();
    710 
    711             set20=(Token)input.LT(1);
    712             if ( input.LA(1)==ID||(input.LA(1)>=INT_TYPE && input.LA(1)<=VOID) ) {
    713                 input.consume();
    714                 adaptor.addChild(root_0, (Object)adaptor.create(set20));
    715                 state.errorRecovery=false;
    716             }
    717             else {
    718                 MismatchedSetException mse = new MismatchedSetException(null,input);
    719                 throw mse;
    720             }
    721 
    722 
    723             }
    724 
    725             retval.stop = input.LT(-1);
    726 
    727             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
    728             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    729 
    730         }
    731         catch (RecognitionException re) {
    732             reportError(re);
    733             recover(input,re);
    734     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
    735 
    736         }
    737         finally {
    738         }
    739         return retval;
    740     }
    741     // $ANTLR end "type"
    742 
    743     public static class block_return extends ParserRuleReturnScope {
    744         Object tree;
    745         public Object getTree() { return tree; }
    746     };
    747 
    748     // $ANTLR start "block"
    749     // SimpleC.g:50:1: block : lc= '{' ( variable )* ( stat )* '}' -> ^( BLOCK[$lc,@\"BLOCK\"] ( variable )* ( stat )* ) ;
    750     public final SimpleCParser.block_return block() throws RecognitionException {
    751         SimpleCParser.block_return retval = new SimpleCParser.block_return();
    752         retval.start = input.LT(1);
    753 
    754         Object root_0 = null;
    755 
    756         Token lc=null;
    757         Token char_literal23=null;
    758         SimpleCParser.variable_return variable21 = null;
    759 
    760         SimpleCParser.stat_return stat22 = null;
    761 
    762 
    763         Object lc_tree=null;
    764         Object char_literal23_tree=null;
    765         RewriteRuleTokenStream stream_25=new RewriteRuleTokenStream(adaptor,"token 25");
    766         RewriteRuleTokenStream stream_26=new RewriteRuleTokenStream(adaptor,"token 26");
    767         RewriteRuleSubtreeStream stream_variable=new RewriteRuleSubtreeStream(adaptor,"rule variable");
    768         RewriteRuleSubtreeStream stream_stat=new RewriteRuleSubtreeStream(adaptor,"rule stat");
    769         try {
    770             // SimpleC.g:51:5: (lc= '{' ( variable )* ( stat )* '}' -> ^( BLOCK[$lc,@\"BLOCK\"] ( variable )* ( stat )* ) )
    771             // SimpleC.g:51:9: lc= '{' ( variable )* ( stat )* '}'
    772             {
    773             lc=(Token)match(input,25,FOLLOW_25_in_block376);
    774             stream_25.add(lc);
    775 
    776             // SimpleC.g:52:13: ( variable )*
    777             loop5:
    778             do {
    779                 int alt5=2;
    780                 int LA5_0 = input.LA(1);
    781 
    782                 if ( (LA5_0==ID) ) {
    783                     int LA5_2 = input.LA(2);
    784 
    785                     if ( (LA5_2==ID) ) {
    786                         alt5=1;
    787                     }
    788 
    789 
    790                 }
    791                 else if ( ((LA5_0>=INT_TYPE && LA5_0<=VOID)) ) {
    792                     alt5=1;
    793                 }
    794 
    795 
    796                 switch (alt5) {
    797             	case 1 :
    798             	    // SimpleC.g:52:13: variable
    799             	    {
    800             	    pushFollow(FOLLOW_variable_in_block390);
    801             	    variable21=variable();
    802 
    803             	    state._fsp--;
    804 
    805             	    stream_variable.add(variable21.getTree());
    806 
    807             	    }
    808             	    break;
    809 
    810             	default :
    811             	    break loop5;
    812                 }
    813             } while (true);
    814 
    815             // SimpleC.g:53:13: ( stat )*
    816             loop6:
    817             do {
    818                 int alt6=2;
    819                 int LA6_0 = input.LA(1);
    820 
    821                 if ( (LA6_0==ID||(LA6_0>=INT && LA6_0<=FOR)||(LA6_0>=21 && LA6_0<=22)||LA6_0==25) ) {
    822                     alt6=1;
    823                 }
    824 
    825 
    826                 switch (alt6) {
    827             	case 1 :
    828             	    // SimpleC.g:53:13: stat
    829             	    {
    830             	    pushFollow(FOLLOW_stat_in_block405);
    831             	    stat22=stat();
    832 
    833             	    state._fsp--;
    834 
    835             	    stream_stat.add(stat22.getTree());
    836 
    837             	    }
    838             	    break;
    839 
    840             	default :
    841             	    break loop6;
    842                 }
    843             } while (true);
    844 
    845             char_literal23=(Token)match(input,26,FOLLOW_26_in_block416);
    846             stream_26.add(char_literal23);
    847 
    848 
    849 
    850             // AST REWRITE
    851             // elements: stat, variable
    852             // token labels:
    853             // rule labels: retval
    854             // token list labels:
    855             // rule list labels:
    856             // wildcard labels:
    857             retval.tree = root_0;
    858             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
    859 
    860             root_0 = (Object)adaptor.nil();
    861             // 55:9: -> ^( BLOCK[$lc,@\"BLOCK\"] ( variable )* ( stat )* )
    862             {
    863                 // SimpleC.g:55:12: ^( BLOCK[$lc,@\"BLOCK\"] ( variable )* ( stat )* )
    864                 {
    865                 Object root_1 = (Object)adaptor.nil();
    866                 root_1 = (Object)adaptor.becomeRoot((Object)adaptor.create(BLOCK, lc, @"BLOCK"), root_1);
    867 
    868                 // SimpleC.g:55:34: ( variable )*
    869                 while ( stream_variable.hasNext() ) {
    870                     adaptor.addChild(root_1, stream_variable.nextTree());
    871 
    872                 }
    873                 stream_variable.reset();
    874                 // SimpleC.g:55:44: ( stat )*
    875                 while ( stream_stat.hasNext() ) {
    876                     adaptor.addChild(root_1, stream_stat.nextTree());
    877 
    878                 }
    879                 stream_stat.reset();
    880 
    881                 adaptor.addChild(root_0, root_1);
    882                 }
    883 
    884             }
    885 
    886             retval.tree = root_0;
    887             }
    888 
    889             retval.stop = input.LT(-1);
    890 
    891             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
    892             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
    893 
    894         }
    895         catch (RecognitionException re) {
    896             reportError(re);
    897             recover(input,re);
    898     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
    899 
    900         }
    901         finally {
    902         }
    903         return retval;
    904     }
    905     // $ANTLR end "block"
    906 
    907     public static class stat_return extends ParserRuleReturnScope {
    908         Object tree;
    909         public Object getTree() { return tree; }
    910     };
    911 
    912     // $ANTLR start "stat"
    913     // SimpleC.g:58:1: stat : ( forStat | expr ';' | block | assignStat ';' | ';' );
    914     public final SimpleCParser.stat_return stat() throws RecognitionException {
    915         SimpleCParser.stat_return retval = new SimpleCParser.stat_return();
    916         retval.start = input.LT(1);
    917 
    918         Object root_0 = null;
    919 
    920         Token char_literal26=null;
    921         Token char_literal29=null;
    922         Token char_literal30=null;
    923         SimpleCParser.forStat_return forStat24 = null;
    924 
    925         SimpleCParser.expr_return expr25 = null;
    926 
    927         SimpleCParser.block_return block27 = null;
    928 
    929         SimpleCParser.assignStat_return assignStat28 = null;
    930 
    931 
    932         Object char_literal26_tree=null;
    933         Object char_literal29_tree=null;
    934         Object char_literal30_tree=null;
    935 
    936         try {
    937             // SimpleC.g:58:5: ( forStat | expr ';' | block | assignStat ';' | ';' )
    938             int alt7=5;
    939             switch ( input.LA(1) ) {
    940             case FOR:
    941                 {
    942                 alt7=1;
    943                 }
    944                 break;
    945             case ID:
    946                 {
    947                 int LA7_2 = input.LA(2);
    948 
    949                 if ( (LA7_2==EQ) ) {
    950                     alt7=4;
    951                 }
    952                 else if ( ((LA7_2>=EQEQ && LA7_2<=PLUS)||LA7_2==21) ) {
    953                     alt7=2;
    954                 }
    955                 else {
    956                     NoViableAltException nvae =
    957                         new NoViableAltException("", 7, 2, input);
    958 
    959                     throw nvae;
    960                 }
    961                 }
    962                 break;
    963             case INT:
    964             case 22:
    965                 {
    966                 alt7=2;
    967                 }
    968                 break;
    969             case 25:
    970                 {
    971                 alt7=3;
    972                 }
    973                 break;
    974             case 21:
    975                 {
    976                 alt7=5;
    977                 }
    978                 break;
    979             default:
    980                 NoViableAltException nvae =
    981                     new NoViableAltException("", 7, 0, input);
    982 
    983                 throw nvae;
    984             }
    985 
    986             switch (alt7) {
    987                 case 1 :
    988                     // SimpleC.g:58:7: forStat
    989                     {
    990                     root_0 = (Object)adaptor.nil();
    991 
    992                     pushFollow(FOLLOW_forStat_in_stat449);
    993                     forStat24=forStat();
    994 
    995                     state._fsp--;
    996 
    997                     adaptor.addChild(root_0, forStat24.getTree());
    998 
    999                     }
   1000                     break;
   1001                 case 2 :
   1002                     // SimpleC.g:59:7: expr ';'
   1003                     {
   1004                     root_0 = (Object)adaptor.nil();
   1005 
   1006                     pushFollow(FOLLOW_expr_in_stat457);
   1007                     expr25=expr();
   1008 
   1009                     state._fsp--;
   1010 
   1011                     adaptor.addChild(root_0, expr25.getTree());
   1012                     char_literal26=(Token)match(input,21,FOLLOW_21_in_stat459);
   1013 
   1014                     }
   1015                     break;
   1016                 case 3 :
   1017                     // SimpleC.g:60:7: block
   1018                     {
   1019                     root_0 = (Object)adaptor.nil();
   1020 
   1021                     pushFollow(FOLLOW_block_in_stat468);
   1022                     block27=block();
   1023 
   1024                     state._fsp--;
   1025 
   1026                     adaptor.addChild(root_0, block27.getTree());
   1027 
   1028                     }
   1029                     break;
   1030                 case 4 :
   1031                     // SimpleC.g:61:7: assignStat ';'
   1032                     {
   1033                     root_0 = (Object)adaptor.nil();
   1034 
   1035                     pushFollow(FOLLOW_assignStat_in_stat476);
   1036                     assignStat28=assignStat();
   1037 
   1038                     state._fsp--;
   1039 
   1040                     adaptor.addChild(root_0, assignStat28.getTree());
   1041                     char_literal29=(Token)match(input,21,FOLLOW_21_in_stat478);
   1042 
   1043                     }
   1044                     break;
   1045                 case 5 :
   1046                     // SimpleC.g:62:7: ';'
   1047                     {
   1048                     root_0 = (Object)adaptor.nil();
   1049 
   1050                     char_literal30=(Token)match(input,21,FOLLOW_21_in_stat487);
   1051 
   1052                     }
   1053                     break;
   1054 
   1055             }
   1056             retval.stop = input.LT(-1);
   1057 
   1058             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
   1059             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
   1060 
   1061         }
   1062         catch (RecognitionException re) {
   1063             reportError(re);
   1064             recover(input,re);
   1065     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
   1066 
   1067         }
   1068         finally {
   1069         }
   1070         return retval;
   1071     }
   1072     // $ANTLR end "stat"
   1073 
   1074     public static class forStat_return extends ParserRuleReturnScope {
   1075         Object tree;
   1076         public Object getTree() { return tree; }
   1077     };
   1078 
   1079     // $ANTLR start "forStat"
   1080     // SimpleC.g:65:1: forStat : 'for' '(' start= assignStat ';' expr ';' next= assignStat ')' block -> ^( 'for' $start expr $next block ) ;
   1081     public final SimpleCParser.forStat_return forStat() throws RecognitionException {
   1082         SimpleCParser.forStat_return retval = new SimpleCParser.forStat_return();
   1083         retval.start = input.LT(1);
   1084 
   1085         Object root_0 = null;
   1086 
   1087         Token string_literal31=null;
   1088         Token char_literal32=null;
   1089         Token char_literal33=null;
   1090         Token char_literal35=null;
   1091         Token char_literal36=null;
   1092         SimpleCParser.assignStat_return start = null;
   1093 
   1094         SimpleCParser.assignStat_return next = null;
   1095 
   1096         SimpleCParser.expr_return expr34 = null;
   1097 
   1098         SimpleCParser.block_return block37 = null;
   1099 
   1100 
   1101         Object string_literal31_tree=null;
   1102         Object char_literal32_tree=null;
   1103         Object char_literal33_tree=null;
   1104         Object char_literal35_tree=null;
   1105         Object char_literal36_tree=null;
   1106         RewriteRuleTokenStream stream_21=new RewriteRuleTokenStream(adaptor,"token 21");
   1107         RewriteRuleTokenStream stream_FOR=new RewriteRuleTokenStream(adaptor,"token FOR");
   1108         RewriteRuleTokenStream stream_22=new RewriteRuleTokenStream(adaptor,"token 22");
   1109         RewriteRuleTokenStream stream_24=new RewriteRuleTokenStream(adaptor,"token 24");
   1110         RewriteRuleSubtreeStream stream_assignStat=new RewriteRuleSubtreeStream(adaptor,"rule assignStat");
   1111         RewriteRuleSubtreeStream stream_block=new RewriteRuleSubtreeStream(adaptor,"rule block");
   1112         RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
   1113         try {
   1114             // SimpleC.g:66:5: ( 'for' '(' start= assignStat ';' expr ';' next= assignStat ')' block -> ^( 'for' $start expr $next block ) )
   1115             // SimpleC.g:66:9: 'for' '(' start= assignStat ';' expr ';' next= assignStat ')' block
   1116             {
   1117             string_literal31=(Token)match(input,FOR,FOLLOW_FOR_in_forStat507);
   1118             stream_FOR.add(string_literal31);
   1119 
   1120             char_literal32=(Token)match(input,22,FOLLOW_22_in_forStat509);
   1121             stream_22.add(char_literal32);
   1122 
   1123             pushFollow(FOLLOW_assignStat_in_forStat513);
   1124             start=assignStat();
   1125 
   1126             state._fsp--;
   1127 
   1128             stream_assignStat.add(start.getTree());
   1129             char_literal33=(Token)match(input,21,FOLLOW_21_in_forStat515);
   1130             stream_21.add(char_literal33);
   1131 
   1132             pushFollow(FOLLOW_expr_in_forStat517);
   1133             expr34=expr();
   1134 
   1135             state._fsp--;
   1136 
   1137             stream_expr.add(expr34.getTree());
   1138             char_literal35=(Token)match(input,21,FOLLOW_21_in_forStat519);
   1139             stream_21.add(char_literal35);
   1140 
   1141             pushFollow(FOLLOW_assignStat_in_forStat523);
   1142             next=assignStat();
   1143 
   1144             state._fsp--;
   1145 
   1146             stream_assignStat.add(next.getTree());
   1147             char_literal36=(Token)match(input,24,FOLLOW_24_in_forStat525);
   1148             stream_24.add(char_literal36);
   1149 
   1150             pushFollow(FOLLOW_block_in_forStat527);
   1151             block37=block();
   1152 
   1153             state._fsp--;
   1154 
   1155             stream_block.add(block37.getTree());
   1156 
   1157 
   1158             // AST REWRITE
   1159             // elements: next, start, FOR, block, expr
   1160             // token labels:
   1161             // rule labels: retval, start, next
   1162             // token list labels:
   1163             // rule list labels:
   1164             // wildcard labels:
   1165             retval.tree = root_0;
   1166             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
   1167             RewriteRuleSubtreeStream stream_start=new RewriteRuleSubtreeStream(adaptor,"rule start",start!=null?start.tree:null);
   1168             RewriteRuleSubtreeStream stream_next=new RewriteRuleSubtreeStream(adaptor,"rule next",next!=null?next.tree:null);
   1169 
   1170             root_0 = (Object)adaptor.nil();
   1171             // 67:9: -> ^( 'for' $start expr $next block )
   1172             {
   1173                 // SimpleC.g:67:12: ^( 'for' $start expr $next block )
   1174                 {
   1175                 Object root_1 = (Object)adaptor.nil();
   1176                 root_1 = (Object)adaptor.becomeRoot(stream_FOR.nextNode(), root_1);
   1177 
   1178                 adaptor.addChild(root_1, stream_start.nextTree());
   1179                 adaptor.addChild(root_1, stream_expr.nextTree());
   1180                 adaptor.addChild(root_1, stream_next.nextTree());
   1181                 adaptor.addChild(root_1, stream_block.nextTree());
   1182 
   1183                 adaptor.addChild(root_0, root_1);
   1184                 }
   1185 
   1186             }
   1187 
   1188             retval.tree = root_0;
   1189             }
   1190 
   1191             retval.stop = input.LT(-1);
   1192 
   1193             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
   1194             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
   1195 
   1196         }
   1197         catch (RecognitionException re) {
   1198             reportError(re);
   1199             recover(input,re);
   1200     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
   1201 
   1202         }
   1203         finally {
   1204         }
   1205         return retval;
   1206     }
   1207     // $ANTLR end "forStat"
   1208 
   1209     public static class assignStat_return extends ParserRuleReturnScope {
   1210         Object tree;
   1211         public Object getTree() { return tree; }
   1212     };
   1213 
   1214     // $ANTLR start "assignStat"
   1215     // SimpleC.g:70:1: assignStat : ID EQ expr -> ^( EQ ID expr ) ;
   1216     public final SimpleCParser.assignStat_return assignStat() throws RecognitionException {
   1217         SimpleCParser.assignStat_return retval = new SimpleCParser.assignStat_return();
   1218         retval.start = input.LT(1);
   1219 
   1220         Object root_0 = null;
   1221 
   1222         Token ID38=null;
   1223         Token EQ39=null;
   1224         SimpleCParser.expr_return expr40 = null;
   1225 
   1226 
   1227         Object ID38_tree=null;
   1228         Object EQ39_tree=null;
   1229         RewriteRuleTokenStream stream_EQ=new RewriteRuleTokenStream(adaptor,"token EQ");
   1230         RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");
   1231         RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
   1232         try {
   1233             // SimpleC.g:71:5: ( ID EQ expr -> ^( EQ ID expr ) )
   1234             // SimpleC.g:71:9: ID EQ expr
   1235             {
   1236             ID38=(Token)match(input,ID,FOLLOW_ID_in_assignStat570);
   1237             stream_ID.add(ID38);
   1238 
   1239             EQ39=(Token)match(input,EQ,FOLLOW_EQ_in_assignStat572);
   1240             stream_EQ.add(EQ39);
   1241 
   1242             pushFollow(FOLLOW_expr_in_assignStat574);
   1243             expr40=expr();
   1244 
   1245             state._fsp--;
   1246 
   1247             stream_expr.add(expr40.getTree());
   1248 
   1249 
   1250             // AST REWRITE
   1251             // elements: EQ, ID, expr
   1252             // token labels:
   1253             // rule labels: retval
   1254             // token list labels:
   1255             // rule list labels:
   1256             // wildcard labels:
   1257             retval.tree = root_0;
   1258             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
   1259 
   1260             root_0 = (Object)adaptor.nil();
   1261             // 71:20: -> ^( EQ ID expr )
   1262             {
   1263                 // SimpleC.g:71:23: ^( EQ ID expr )
   1264                 {
   1265                 Object root_1 = (Object)adaptor.nil();
   1266                 root_1 = (Object)adaptor.becomeRoot(stream_EQ.nextNode(), root_1);
   1267 
   1268                 adaptor.addChild(root_1, stream_ID.nextNode());
   1269                 adaptor.addChild(root_1, stream_expr.nextTree());
   1270 
   1271                 adaptor.addChild(root_0, root_1);
   1272                 }
   1273 
   1274             }
   1275 
   1276             retval.tree = root_0;
   1277             }
   1278 
   1279             retval.stop = input.LT(-1);
   1280 
   1281             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
   1282             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
   1283 
   1284         }
   1285         catch (RecognitionException re) {
   1286             reportError(re);
   1287             recover(input,re);
   1288     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
   1289 
   1290         }
   1291         finally {
   1292         }
   1293         return retval;
   1294     }
   1295     // $ANTLR end "assignStat"
   1296 
   1297     public static class expr_return extends ParserRuleReturnScope {
   1298         Object tree;
   1299         public Object getTree() { return tree; }
   1300     };
   1301 
   1302     // $ANTLR start "expr"
   1303     // SimpleC.g:74:1: expr : condExpr ;
   1304     public final SimpleCParser.expr_return expr() throws RecognitionException {
   1305         SimpleCParser.expr_return retval = new SimpleCParser.expr_return();
   1306         retval.start = input.LT(1);
   1307 
   1308         Object root_0 = null;
   1309 
   1310         SimpleCParser.condExpr_return condExpr41 = null;
   1311 
   1312 
   1313 
   1314         try {
   1315             // SimpleC.g:74:5: ( condExpr )
   1316             // SimpleC.g:74:9: condExpr
   1317             {
   1318             root_0 = (Object)adaptor.nil();
   1319 
   1320             pushFollow(FOLLOW_condExpr_in_expr598);
   1321             condExpr41=condExpr();
   1322 
   1323             state._fsp--;
   1324 
   1325             adaptor.addChild(root_0, condExpr41.getTree());
   1326 
   1327             }
   1328 
   1329             retval.stop = input.LT(-1);
   1330 
   1331             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
   1332             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
   1333 
   1334         }
   1335         catch (RecognitionException re) {
   1336             reportError(re);
   1337             recover(input,re);
   1338     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
   1339 
   1340         }
   1341         finally {
   1342         }
   1343         return retval;
   1344     }
   1345     // $ANTLR end "expr"
   1346 
   1347     public static class condExpr_return extends ParserRuleReturnScope {
   1348         Object tree;
   1349         public Object getTree() { return tree; }
   1350     };
   1351 
   1352     // $ANTLR start "condExpr"
   1353     // SimpleC.g:77:1: condExpr : aexpr ( ( '==' | '<' ) aexpr )? ;
   1354     public final SimpleCParser.condExpr_return condExpr() throws RecognitionException {
   1355         SimpleCParser.condExpr_return retval = new SimpleCParser.condExpr_return();
   1356         retval.start = input.LT(1);
   1357 
   1358         Object root_0 = null;
   1359 
   1360         Token string_literal43=null;
   1361         Token char_literal44=null;
   1362         SimpleCParser.aexpr_return aexpr42 = null;
   1363 
   1364         SimpleCParser.aexpr_return aexpr45 = null;
   1365 
   1366 
   1367         Object string_literal43_tree=null;
   1368         Object char_literal44_tree=null;
   1369 
   1370         try {
   1371             // SimpleC.g:78:5: ( aexpr ( ( '==' | '<' ) aexpr )? )
   1372             // SimpleC.g:78:9: aexpr ( ( '==' | '<' ) aexpr )?
   1373             {
   1374             root_0 = (Object)adaptor.nil();
   1375 
   1376             pushFollow(FOLLOW_aexpr_in_condExpr617);
   1377             aexpr42=aexpr();
   1378 
   1379             state._fsp--;
   1380 
   1381             adaptor.addChild(root_0, aexpr42.getTree());
   1382             // SimpleC.g:78:15: ( ( '==' | '<' ) aexpr )?
   1383             int alt9=2;
   1384             int LA9_0 = input.LA(1);
   1385 
   1386             if ( ((LA9_0>=EQEQ && LA9_0<=LT)) ) {
   1387                 alt9=1;
   1388             }
   1389             switch (alt9) {
   1390                 case 1 :
   1391                     // SimpleC.g:78:17: ( '==' | '<' ) aexpr
   1392                     {
   1393                     // SimpleC.g:78:17: ( '==' | '<' )
   1394                     int alt8=2;
   1395                     int LA8_0 = input.LA(1);
   1396 
   1397                     if ( (LA8_0==EQEQ) ) {
   1398                         alt8=1;
   1399                     }
   1400                     else if ( (LA8_0==LT) ) {
   1401                         alt8=2;
   1402                     }
   1403                     else {
   1404                         NoViableAltException nvae =
   1405                             new NoViableAltException("", 8, 0, input);
   1406 
   1407                         throw nvae;
   1408                     }
   1409                     switch (alt8) {
   1410                         case 1 :
   1411                             // SimpleC.g:78:18: '=='
   1412                             {
   1413                             string_literal43=(Token)match(input,EQEQ,FOLLOW_EQEQ_in_condExpr622);
   1414                             string_literal43_tree = (Object)adaptor.create(string_literal43);
   1415                             root_0 = (Object)adaptor.becomeRoot(string_literal43_tree, root_0);
   1416 
   1417 
   1418                             }
   1419                             break;
   1420                         case 2 :
   1421                             // SimpleC.g:78:26: '<'
   1422                             {
   1423                             char_literal44=(Token)match(input,LT,FOLLOW_LT_in_condExpr627);
   1424                             char_literal44_tree = (Object)adaptor.create(char_literal44);
   1425                             root_0 = (Object)adaptor.becomeRoot(char_literal44_tree, root_0);
   1426 
   1427 
   1428                             }
   1429                             break;
   1430 
   1431                     }
   1432 
   1433                     pushFollow(FOLLOW_aexpr_in_condExpr631);
   1434                     aexpr45=aexpr();
   1435 
   1436                     state._fsp--;
   1437 
   1438                     adaptor.addChild(root_0, aexpr45.getTree());
   1439 
   1440                     }
   1441                     break;
   1442 
   1443             }
   1444 
   1445 
   1446             }
   1447 
   1448             retval.stop = input.LT(-1);
   1449 
   1450             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
   1451             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
   1452 
   1453         }
   1454         catch (RecognitionException re) {
   1455             reportError(re);
   1456             recover(input,re);
   1457     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
   1458 
   1459         }
   1460         finally {
   1461         }
   1462         return retval;
   1463     }
   1464     // $ANTLR end "condExpr"
   1465 
   1466     public static class aexpr_return extends ParserRuleReturnScope {
   1467         Object tree;
   1468         public Object getTree() { return tree; }
   1469     };
   1470 
   1471     // $ANTLR start "aexpr"
   1472     // SimpleC.g:81:1: aexpr : atom ( '+' atom )* ;
   1473     public final SimpleCParser.aexpr_return aexpr() throws RecognitionException {
   1474         SimpleCParser.aexpr_return retval = new SimpleCParser.aexpr_return();
   1475         retval.start = input.LT(1);
   1476 
   1477         Object root_0 = null;
   1478 
   1479         Token char_literal47=null;
   1480         SimpleCParser.atom_return atom46 = null;
   1481 
   1482         SimpleCParser.atom_return atom48 = null;
   1483 
   1484 
   1485         Object char_literal47_tree=null;
   1486 
   1487         try {
   1488             // SimpleC.g:82:5: ( atom ( '+' atom )* )
   1489             // SimpleC.g:82:9: atom ( '+' atom )*
   1490             {
   1491             root_0 = (Object)adaptor.nil();
   1492 
   1493             pushFollow(FOLLOW_atom_in_aexpr653);
   1494             atom46=atom();
   1495 
   1496             state._fsp--;
   1497 
   1498             adaptor.addChild(root_0, atom46.getTree());
   1499             // SimpleC.g:82:14: ( '+' atom )*
   1500             loop10:
   1501             do {
   1502                 int alt10=2;
   1503                 int LA10_0 = input.LA(1);
   1504 
   1505                 if ( (LA10_0==PLUS) ) {
   1506                     alt10=1;
   1507                 }
   1508 
   1509 
   1510                 switch (alt10) {
   1511             	case 1 :
   1512             	    // SimpleC.g:82:16: '+' atom
   1513             	    {
   1514             	    char_literal47=(Token)match(input,PLUS,FOLLOW_PLUS_in_aexpr657);
   1515             	    char_literal47_tree = (Object)adaptor.create(char_literal47);
   1516             	    root_0 = (Object)adaptor.becomeRoot(char_literal47_tree, root_0);
   1517 
   1518             	    pushFollow(FOLLOW_atom_in_aexpr660);
   1519             	    atom48=atom();
   1520 
   1521             	    state._fsp--;
   1522 
   1523             	    adaptor.addChild(root_0, atom48.getTree());
   1524 
   1525             	    }
   1526             	    break;
   1527 
   1528             	default :
   1529             	    break loop10;
   1530                 }
   1531             } while (true);
   1532 
   1533 
   1534             }
   1535 
   1536             retval.stop = input.LT(-1);
   1537 
   1538             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
   1539             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
   1540 
   1541         }
   1542         catch (RecognitionException re) {
   1543             reportError(re);
   1544             recover(input,re);
   1545     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
   1546 
   1547         }
   1548         finally {
   1549         }
   1550         return retval;
   1551     }
   1552     // $ANTLR end "aexpr"
   1553 
   1554     public static class atom_return extends ParserRuleReturnScope {
   1555         Object tree;
   1556         public Object getTree() { return tree; }
   1557     };
   1558 
   1559     // $ANTLR start "atom"
   1560     // SimpleC.g:85:1: atom : ( ID | INT | '(' expr ')' -> expr );
   1561     public final SimpleCParser.atom_return atom() throws RecognitionException {
   1562         SimpleCParser.atom_return retval = new SimpleCParser.atom_return();
   1563         retval.start = input.LT(1);
   1564 
   1565         Object root_0 = null;
   1566 
   1567         Token ID49=null;
   1568         Token INT50=null;
   1569         Token char_literal51=null;
   1570         Token char_literal53=null;
   1571         SimpleCParser.expr_return expr52 = null;
   1572 
   1573 
   1574         Object ID49_tree=null;
   1575         Object INT50_tree=null;
   1576         Object char_literal51_tree=null;
   1577         Object char_literal53_tree=null;
   1578         RewriteRuleTokenStream stream_22=new RewriteRuleTokenStream(adaptor,"token 22");
   1579         RewriteRuleTokenStream stream_24=new RewriteRuleTokenStream(adaptor,"token 24");
   1580         RewriteRuleSubtreeStream stream_expr=new RewriteRuleSubtreeStream(adaptor,"rule expr");
   1581         try {
   1582             // SimpleC.g:86:5: ( ID | INT | '(' expr ')' -> expr )
   1583             int alt11=3;
   1584             switch ( input.LA(1) ) {
   1585             case ID:
   1586                 {
   1587                 alt11=1;
   1588                 }
   1589                 break;
   1590             case INT:
   1591                 {
   1592                 alt11=2;
   1593                 }
   1594                 break;
   1595             case 22:
   1596                 {
   1597                 alt11=3;
   1598                 }
   1599                 break;
   1600             default:
   1601                 NoViableAltException nvae =
   1602                     new NoViableAltException("", 11, 0, input);
   1603 
   1604                 throw nvae;
   1605             }
   1606 
   1607             switch (alt11) {
   1608                 case 1 :
   1609                     // SimpleC.g:86:7: ID
   1610                     {
   1611                     root_0 = (Object)adaptor.nil();
   1612 
   1613                     ID49=(Token)match(input,ID,FOLLOW_ID_in_atom680);
   1614                     ID49_tree = (Object)adaptor.create(ID49);
   1615                     adaptor.addChild(root_0, ID49_tree);
   1616 
   1617 
   1618                     }
   1619                     break;
   1620                 case 2 :
   1621                     // SimpleC.g:87:7: INT
   1622                     {
   1623                     root_0 = (Object)adaptor.nil();
   1624 
   1625                     INT50=(Token)match(input,INT,FOLLOW_INT_in_atom694);
   1626                     INT50_tree = (Object)adaptor.create(INT50);
   1627                     adaptor.addChild(root_0, INT50_tree);
   1628 
   1629 
   1630                     }
   1631                     break;
   1632                 case 3 :
   1633                     // SimpleC.g:88:7: '(' expr ')'
   1634                     {
   1635                     char_literal51=(Token)match(input,22,FOLLOW_22_in_atom708);
   1636                     stream_22.add(char_literal51);
   1637 
   1638                     pushFollow(FOLLOW_expr_in_atom710);
   1639                     expr52=expr();
   1640 
   1641                     state._fsp--;
   1642 
   1643                     stream_expr.add(expr52.getTree());
   1644                     char_literal53=(Token)match(input,24,FOLLOW_24_in_atom712);
   1645                     stream_24.add(char_literal53);
   1646 
   1647 
   1648 
   1649                     // AST REWRITE
   1650                     // elements: expr
   1651                     // token labels:
   1652                     // rule labels: retval
   1653                     // token list labels:
   1654                     // rule list labels:
   1655                     // wildcard labels:
   1656                     retval.tree = root_0;
   1657                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);
   1658 
   1659                     root_0 = (Object)adaptor.nil();
   1660                     // 88:20: -> expr
   1661                     {
   1662                         adaptor.addChild(root_0, stream_expr.nextTree());
   1663 
   1664                     }
   1665 
   1666                     retval.tree = root_0;
   1667                     }
   1668                     break;
   1669 
   1670             }
   1671             retval.stop = input.LT(-1);
   1672 
   1673             retval.tree = (Object)adaptor.rulePostProcessing(root_0);
   1674             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);
   1675 
   1676         }
   1677         catch (RecognitionException re) {
   1678             reportError(re);
   1679             recover(input,re);
   1680     	retval.tree = (Object)adaptor.errorNode(input, retval.start, input.LT(-1), re);
   1681 
   1682         }
   1683         finally {
   1684         }
   1685         return retval;
   1686     }
   1687     // $ANTLR end "atom"
   1688 
   1689     // Delegated rules
   1690 
   1691 
   1692     protected DFA2 dfa2 = new DFA2(this);
   1693     static final String DFA2_eotS =
   1694         "\15\uffff";
   1695     static final String DFA2_eofS =
   1696         "\15\uffff";
   1697     static final String DFA2_minS =
   1698         "\2\12\1\25\1\12\1\uffff\1\12\1\25\1\27\2\uffff\2\12\1\27";
   1699     static final String DFA2_maxS =
   1700         "\1\20\1\12\1\26\1\30\1\uffff\1\12\1\31\1\30\2\uffff\1\20\1\12\1"+
   1701         "\30";
   1702     static final String DFA2_acceptS =
   1703         "\4\uffff\1\1\3\uffff\1\3\1\2\3\uffff";
   1704     static final String DFA2_specialS =
   1705         "\15\uffff}>";
   1706     static final String[] DFA2_transitionS = {
   1707             "\1\1\3\uffff\3\1",
   1708             "\1\2",
   1709             "\1\4\1\3",
   1710             "\1\5\3\uffff\3\5\7\uffff\1\6",
   1711             "",
   1712             "\1\7",
   1713             "\1\11\3\uffff\1\10",
   1714             "\1\12\1\6",
   1715             "",
   1716             "",
   1717             "\1\13\3\uffff\3\13",
   1718             "\1\14",
   1719             "\1\12\1\6"
   1720     };
   1721 
   1722     static final short[] DFA2_eot = DFA.unpackEncodedString(DFA2_eotS);
   1723     static final short[] DFA2_eof = DFA.unpackEncodedString(DFA2_eofS);
   1724     static final char[] DFA2_min = DFA.unpackEncodedStringToUnsignedChars(DFA2_minS);
   1725     static final char[] DFA2_max = DFA.unpackEncodedStringToUnsignedChars(DFA2_maxS);
   1726     static final short[] DFA2_accept = DFA.unpackEncodedString(DFA2_acceptS);
   1727     static final short[] DFA2_special = DFA.unpackEncodedString(DFA2_specialS);
   1728     static final short[][] DFA2_transition;
   1729 
   1730     static {
   1731         int numStates = DFA2_transitionS.length;
   1732         DFA2_transition = new short[numStates][];
   1733         for (int i=0; i<numStates; i++) {
   1734             DFA2_transition[i] = DFA.unpackEncodedString(DFA2_transitionS[i]);
   1735         }
   1736     }
   1737 
   1738     class DFA2 extends DFA {
   1739 
   1740         public DFA2(BaseRecognizer recognizer) {
   1741             this.recognizer = recognizer;
   1742             this.decisionNumber = 2;
   1743             this.eot = DFA2_eot;
   1744             this.eof = DFA2_eof;
   1745             this.min = DFA2_min;
   1746             this.max = DFA2_max;
   1747             this.accept = DFA2_accept;
   1748             this.special = DFA2_special;
   1749             this.transition = DFA2_transition;
   1750         }
   1751         public String getDescription() {
   1752             return "20:1: declaration : ( variable | functionHeader ';' -> ^( FUNC_DECL functionHeader ) | functionHeader block -> ^( FUNC_DEF functionHeader block ) );";
   1753         }
   1754     }
   1755 
   1756 
   1757     public static final BitSet FOLLOW_declaration_in_program85 = new BitSet(new long[]{0x000000000001C402L});
   1758     public static final BitSet FOLLOW_variable_in_declaration105 = new BitSet(new long[]{0x0000000000000002L});
   1759     public static final BitSet FOLLOW_functionHeader_in_declaration115 = new BitSet(new long[]{0x0000000000200000L});
   1760     public static final BitSet FOLLOW_21_in_declaration117 = new BitSet(new long[]{0x0000000000000002L});
   1761     public static final BitSet FOLLOW_functionHeader_in_declaration135 = new BitSet(new long[]{0x0000000002000000L});
   1762     public static final BitSet FOLLOW_block_in_declaration137 = new BitSet(new long[]{0x0000000000000002L});
   1763     public static final BitSet FOLLOW_type_in_variable166 = new BitSet(new long[]{0x0000000000000400L});
   1764     public static final BitSet FOLLOW_declarator_in_variable168 = new BitSet(new long[]{0x0000000000200000L});
   1765     public static final BitSet FOLLOW_21_in_variable170 = new BitSet(new long[]{0x0000000000000002L});
   1766     public static final BitSet FOLLOW_ID_in_declarator199 = new BitSet(new long[]{0x0000000000000002L});
   1767     public static final BitSet FOLLOW_type_in_functionHeader219 = new BitSet(new long[]{0x0000000000000400L});
   1768     public static final BitSet FOLLOW_ID_in_functionHeader221 = new BitSet(new long[]{0x0000000000400000L});
   1769     public static final BitSet FOLLOW_22_in_functionHeader223 = new BitSet(new long[]{0x000000000101C400L});
   1770     public static final BitSet FOLLOW_formalParameter_in_functionHeader227 = new BitSet(new long[]{0x0000000001800000L});
   1771     public static final BitSet FOLLOW_23_in_functionHeader231 = new BitSet(new long[]{0x000000000001C400L});
   1772     public static final BitSet FOLLOW_formalParameter_in_functionHeader233 = new BitSet(new long[]{0x0000000001800000L});
   1773     public static final BitSet FOLLOW_24_in_functionHeader241 = new BitSet(new long[]{0x0000000000000002L});
   1774     public static final BitSet FOLLOW_type_in_formalParameter281 = new BitSet(new long[]{0x0000000000000400L});
   1775     public static final BitSet FOLLOW_declarator_in_formalParameter283 = new BitSet(new long[]{0x0000000000000002L});
   1776     public static final BitSet FOLLOW_set_in_type0 = new BitSet(new long[]{0x0000000000000002L});
   1777     public static final BitSet FOLLOW_25_in_block376 = new BitSet(new long[]{0x000000000661F400L});
   1778     public static final BitSet FOLLOW_variable_in_block390 = new BitSet(new long[]{0x000000000661F400L});
   1779     public static final BitSet FOLLOW_stat_in_block405 = new BitSet(new long[]{0x0000000006603400L});
   1780     public static final BitSet FOLLOW_26_in_block416 = new BitSet(new long[]{0x0000000000000002L});
   1781     public static final BitSet FOLLOW_forStat_in_stat449 = new BitSet(new long[]{0x0000000000000002L});
   1782     public static final BitSet FOLLOW_expr_in_stat457 = new BitSet(new long[]{0x0000000000200000L});
   1783     public static final BitSet FOLLOW_21_in_stat459 = new BitSet(new long[]{0x0000000000000002L});
   1784     public static final BitSet FOLLOW_block_in_stat468 = new BitSet(new long[]{0x0000000000000002L});
   1785     public static final BitSet FOLLOW_assignStat_in_stat476 = new BitSet(new long[]{0x0000000000200000L});
   1786     public static final BitSet FOLLOW_21_in_stat478 = new BitSet(new long[]{0x0000000000000002L});
   1787     public static final BitSet FOLLOW_21_in_stat487 = new BitSet(new long[]{0x0000000000000002L});
   1788     public static final BitSet FOLLOW_FOR_in_forStat507 = new BitSet(new long[]{0x0000000000400000L});
   1789     public static final BitSet FOLLOW_22_in_forStat509 = new BitSet(new long[]{0x0000000000000400L});
   1790     public static final BitSet FOLLOW_assignStat_in_forStat513 = new BitSet(new long[]{0x0000000000200000L});
   1791     public static final BitSet FOLLOW_21_in_forStat515 = new BitSet(new long[]{0x0000000000401400L});
   1792     public static final BitSet FOLLOW_expr_in_forStat517 = new BitSet(new long[]{0x0000000000200000L});
   1793     public static final BitSet FOLLOW_21_in_forStat519 = new BitSet(new long[]{0x0000000000000400L});
   1794     public static final BitSet FOLLOW_assignStat_in_forStat523 = new BitSet(new long[]{0x0000000001000000L});
   1795     public static final BitSet FOLLOW_24_in_forStat525 = new BitSet(new long[]{0x0000000002000000L});
   1796     public static final BitSet FOLLOW_block_in_forStat527 = new BitSet(new long[]{0x0000000000000002L});
   1797     public static final BitSet FOLLOW_ID_in_assignStat570 = new BitSet(new long[]{0x0000000000000800L});
   1798     public static final BitSet FOLLOW_EQ_in_assignStat572 = new BitSet(new long[]{0x0000000000401400L});
   1799     public static final BitSet FOLLOW_expr_in_assignStat574 = new BitSet(new long[]{0x0000000000000002L});
   1800     public static final BitSet FOLLOW_condExpr_in_expr598 = new BitSet(new long[]{0x0000000000000002L});
   1801     public static final BitSet FOLLOW_aexpr_in_condExpr617 = new BitSet(new long[]{0x0000000000060002L});
   1802     public static final BitSet FOLLOW_EQEQ_in_condExpr622 = new BitSet(new long[]{0x0000000000401400L});
   1803     public static final BitSet FOLLOW_LT_in_condExpr627 = new BitSet(new long[]{0x0000000000401400L});
   1804     public static final BitSet FOLLOW_aexpr_in_condExpr631 = new BitSet(new long[]{0x0000000000000002L});
   1805     public static final BitSet FOLLOW_atom_in_aexpr653 = new BitSet(new long[]{0x0000000000080002L});
   1806     public static final BitSet FOLLOW_PLUS_in_aexpr657 = new BitSet(new long[]{0x0000000000401400L});
   1807     public static final BitSet FOLLOW_atom_in_aexpr660 = new BitSet(new long[]{0x0000000000080002L});
   1808     public static final BitSet FOLLOW_ID_in_atom680 = new BitSet(new long[]{0x0000000000000002L});
   1809     public static final BitSet FOLLOW_INT_in_atom694 = new BitSet(new long[]{0x0000000000000002L});
   1810     public static final BitSet FOLLOW_22_in_atom708 = new BitSet(new long[]{0x0000000000401400L});
   1811     public static final BitSet FOLLOW_expr_in_atom710 = new BitSet(new long[]{0x0000000001000000L});
   1812     public static final BitSet FOLLOW_24_in_atom712 = new BitSet(new long[]{0x0000000000000002L});
   1813 
   1814 }