Home | History | Annotate | Download | only in Mini
      1 /*
      2  * Licensed to the Apache Software Foundation (ASF) under one or more
      3  * contributor license agreements.  See the NOTICE file distributed with
      4  * this work for additional information regarding copyright ownership.
      5  * The ASF licenses this file to You under the Apache License, Version 2.0
      6  * (the "License"); you may not use this file except in compliance with
      7  * the License.  You may obtain a copy of the License at
      8  *
      9  *      http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  *
     17  */
     18 /* Generated By:JJTree&JavaCC: Do not edit this line. MiniParser.java */
     19 package Mini;
     20 
     21 public class MiniParser/*@bgen(jjtree)*/implements MiniParserTreeConstants, MiniParserConstants {/*@bgen(jjtree)*/
     22   protected static JJTMiniParserState jjtree = new JJTMiniParserState();private static Token expr_token;
     23 
     24   final static void jjtreeOpenNodeScope(Node n) {}
     25   final static void jjtreeCloseNodeScope(Node n) {((SimpleNode)n).closeNode();}
     26 
     27 /* A program consists of a number of function declarations with a
     28  * distinguished function `main' that starts the program.
     29  */
     30   static public void Program() throws ParseException {
     31                   /*@bgen(jjtree) Program */
     32   ASTProgram jjtn000 = new ASTProgram(JJTPROGRAM);
     33   boolean jjtc000 = true;
     34   jjtree.openNodeScope(jjtn000);
     35   jjtreeOpenNodeScope(jjtn000);
     36     try {
     37       label_1:
     38       while (true) {
     39         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
     40         case 9:
     41           break;
     42         default:
     43           jj_la1[0] = jj_gen;
     44           break label_1;
     45         }
     46         FunDecl();
     47       }
     48       jj_consume_token(0);
     49     } catch (Throwable jjte000) {
     50           if (jjtc000) {
     51             jjtree.clearNodeScope(jjtn000);
     52             jjtc000 = false;
     53           } else {
     54             jjtree.popNode();
     55           }
     56           if (jjte000 instanceof ParseException) {
     57             {if (true) {
     58                 throw (ParseException)jjte000;
     59             }}
     60           }
     61           if (jjte000 instanceof RuntimeException) {
     62             {if (true) {
     63                 throw (RuntimeException)jjte000;
     64             }}
     65           }
     66           {if (true) {
     67             throw (Error)jjte000;
     68         }}
     69     } finally {
     70           if (jjtc000) {
     71             jjtree.closeNodeScope(jjtn000, true);
     72             jjtreeCloseNodeScope(jjtn000);
     73           }
     74     }
     75   }
     76 
     77 /* "FUN" Ident() "(" NameList() ")" = Expr()
     78  */
     79   static public void FunDecl() throws ParseException {
     80  /*@bgen(jjtree) FunDecl */
     81   ASTFunDecl jjtn000 = new ASTFunDecl(JJTFUNDECL);
     82   boolean jjtc000 = true;
     83   jjtree.openNodeScope(jjtn000);
     84   jjtreeOpenNodeScope(jjtn000);Token    t;
     85     try {
     86       t = jj_consume_token(9);
     87                      jjtn000.setPosition(t.beginLine, t.beginColumn);
     88       Ident();
     89       jj_consume_token(LPAREN);
     90       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
     91       case FALSE:
     92       case TRUE:
     93       case READ:
     94       case WRITE:
     95       case IDENT:
     96         Ident();
     97         label_2:
     98         while (true) {
     99           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    100           case COMMA:
    101             break;
    102           default:
    103             jj_la1[1] = jj_gen;
    104             break label_2;
    105           }
    106           jj_consume_token(COMMA);
    107           Ident();
    108         }
    109         break;
    110       default:
    111         jj_la1[2] = jj_gen;
    112       }
    113       jj_consume_token(RPAREN);
    114       jj_consume_token(ASSIGN);
    115       Expr();
    116     } catch (Throwable jjte000) {
    117           if (jjtc000) {
    118             jjtree.clearNodeScope(jjtn000);
    119             jjtc000 = false;
    120           } else {
    121             jjtree.popNode();
    122           }
    123           if (jjte000 instanceof ParseException) {
    124             {if (true) {
    125                 throw (ParseException)jjte000;
    126             }}
    127           }
    128           if (jjte000 instanceof RuntimeException) {
    129             {if (true) {
    130                 throw (RuntimeException)jjte000;
    131             }}
    132           }
    133           {if (true) {
    134             throw (Error)jjte000;
    135         }}
    136     } finally {
    137           if (jjtc000) {
    138             jjtree.closeNodeScope(jjtn000, true);
    139             jjtreeCloseNodeScope(jjtn000);
    140           }
    141     }
    142   }
    143 
    144   static public void Expr() throws ParseException {
    145  /*@bgen(jjtree) Expr */
    146   ASTExpr jjtn000 = new ASTExpr(JJTEXPR);
    147   boolean jjtc000 = true;
    148   jjtree.openNodeScope(jjtn000);
    149   jjtreeOpenNodeScope(jjtn000);int kind=-1;
    150   int un_op=-1;
    151     try {
    152       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    153       case 10:
    154         IfExpr();
    155         break;
    156       case 14:
    157         LetExpr();
    158         break;
    159       case FALSE:
    160       case TRUE:
    161       case LPAREN:
    162       case READ:
    163       case WRITE:
    164       case IDENT:
    165       case INTEGER:
    166         Term();
    167         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    168         case OR:
    169         case PLUS:
    170         case MINUS:
    171           kind = AddOp();
    172           Expr();
    173                                         jjtn000.setKind(kind);
    174           break;
    175         default:
    176           jj_la1[3] = jj_gen;
    177         }
    178         break;
    179       case NOT:
    180       case MINUS:
    181         un_op = UnOp();
    182                          jjtn000.setUnOp(un_op);
    183         Expr();
    184         break;
    185       default:
    186         jj_la1[4] = jj_gen;
    187         jj_consume_token(-1);
    188         throw new ParseException();
    189       }
    190     } catch (Throwable jjte000) {
    191           if (jjtc000) {
    192             jjtree.clearNodeScope(jjtn000);
    193             jjtc000 = false;
    194           } else {
    195             jjtree.popNode();
    196           }
    197           if (jjte000 instanceof ParseException) {
    198             {if (true) {
    199                 throw (ParseException)jjte000;
    200             }}
    201           }
    202           if (jjte000 instanceof RuntimeException) {
    203             {if (true) {
    204                 throw (RuntimeException)jjte000;
    205             }}
    206           }
    207           {if (true) {
    208             throw (Error)jjte000;
    209         }}
    210     } finally {
    211           if (jjtc000) {
    212             jjtree.closeNodeScope(jjtn000, true);
    213             jjtreeCloseNodeScope(jjtn000);
    214           }
    215     }
    216   }
    217 
    218 /*
    219  * The disambiguating algorithm of JavaCC automatically binds dangling
    220  * else's to the innermost if statement. The LOOKAHEAD specification
    221  * is to tell JavaCC that we know what we are doing.
    222  */
    223   static public void IfExpr() throws ParseException {
    224  /*@bgen(jjtree) IfExpr */
    225   ASTIfExpr jjtn000 = new ASTIfExpr(JJTIFEXPR);
    226   boolean jjtc000 = true;
    227   jjtree.openNodeScope(jjtn000);
    228   jjtreeOpenNodeScope(jjtn000);Token t=null;
    229     try {
    230       t = jj_consume_token(10);
    231                     jjtn000.setPosition(t.beginLine, t.beginColumn);
    232       Expr();
    233       jj_consume_token(11);
    234       Expr();
    235       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    236       case 12:
    237         jj_consume_token(12);
    238         Expr();
    239         break;
    240       default:
    241         jj_la1[5] = jj_gen;
    242       }
    243       jj_consume_token(13);
    244     } catch (Throwable jjte000) {
    245           if (jjtc000) {
    246             jjtree.clearNodeScope(jjtn000);
    247             jjtc000 = false;
    248           } else {
    249             jjtree.popNode();
    250           }
    251           if (jjte000 instanceof ParseException) {
    252             {if (true) {
    253                 throw (ParseException)jjte000;
    254             }}
    255           }
    256           if (jjte000 instanceof RuntimeException) {
    257             {if (true) {
    258                 throw (RuntimeException)jjte000;
    259             }}
    260           }
    261           {if (true) {
    262             throw (Error)jjte000;
    263         }}
    264     } finally {
    265           if (jjtc000) {
    266             jjtree.closeNodeScope(jjtn000, true);
    267             jjtreeCloseNodeScope(jjtn000);
    268           }
    269     }
    270   }
    271 
    272   static public void LetExpr() throws ParseException {
    273  /*@bgen(jjtree) LetExpr */
    274   ASTLetExpr jjtn000 = new ASTLetExpr(JJTLETEXPR);
    275   boolean jjtc000 = true;
    276   jjtree.openNodeScope(jjtn000);
    277   jjtreeOpenNodeScope(jjtn000);Token t=null;
    278     try {
    279       t = jj_consume_token(14);
    280                     jjtn000.setPosition(t.beginLine, t.beginColumn);
    281       label_3:
    282       while (true) {
    283         Ident();
    284         jj_consume_token(ASSIGN);
    285         Expr();
    286         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    287         case FALSE:
    288         case TRUE:
    289         case READ:
    290         case WRITE:
    291         case IDENT:
    292           break;
    293         default:
    294           jj_la1[6] = jj_gen;
    295           break label_3;
    296         }
    297       }
    298       jj_consume_token(15);
    299       Expr();
    300     } catch (Throwable jjte000) {
    301           if (jjtc000) {
    302             jjtree.clearNodeScope(jjtn000);
    303             jjtc000 = false;
    304           } else {
    305             jjtree.popNode();
    306           }
    307           if (jjte000 instanceof ParseException) {
    308             {if (true) {
    309                 throw (ParseException)jjte000;
    310             }}
    311           }
    312           if (jjte000 instanceof RuntimeException) {
    313             {if (true) {
    314                 throw (RuntimeException)jjte000;
    315             }}
    316           }
    317           {if (true) {
    318             throw (Error)jjte000;
    319         }}
    320     } finally {
    321           if (jjtc000) {
    322             jjtree.closeNodeScope(jjtn000, true);
    323             jjtreeCloseNodeScope(jjtn000);
    324           }
    325     }
    326   }
    327 
    328   static public Token FunAppl() throws ParseException {
    329  /*@bgen(jjtree) FunAppl */
    330   ASTFunAppl jjtn000 = new ASTFunAppl(JJTFUNAPPL);
    331   boolean jjtc000 = true;
    332   jjtree.openNodeScope(jjtn000);
    333   jjtreeOpenNodeScope(jjtn000);Token t=null;
    334     try {
    335       t = Ident();
    336                       jjtn000.setPosition(t.beginLine, t.beginColumn);
    337       jj_consume_token(LPAREN);
    338       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    339       case 10:
    340       case 14:
    341       case NOT:
    342       case FALSE:
    343       case TRUE:
    344       case MINUS:
    345       case LPAREN:
    346       case READ:
    347       case WRITE:
    348       case IDENT:
    349       case INTEGER:
    350         Expr();
    351         label_4:
    352         while (true) {
    353           switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    354           case COMMA:
    355             break;
    356           default:
    357             jj_la1[7] = jj_gen;
    358             break label_4;
    359           }
    360           jj_consume_token(COMMA);
    361           Expr();
    362         }
    363         break;
    364       default:
    365         jj_la1[8] = jj_gen;
    366       }
    367       jj_consume_token(RPAREN);
    368           jjtree.closeNodeScope(jjtn000, true);
    369           jjtc000 = false;
    370           jjtreeCloseNodeScope(jjtn000);
    371           {if (true) {
    372             return t;
    373         }}
    374     } catch (Throwable jjte000) {
    375           if (jjtc000) {
    376             jjtree.clearNodeScope(jjtn000);
    377             jjtc000 = false;
    378           } else {
    379             jjtree.popNode();
    380           }
    381           if (jjte000 instanceof ParseException) {
    382             {if (true) {
    383                 throw (ParseException)jjte000;
    384             }}
    385           }
    386           if (jjte000 instanceof RuntimeException) {
    387             {if (true) {
    388                 throw (RuntimeException)jjte000;
    389             }}
    390           }
    391           {if (true) {
    392             throw (Error)jjte000;
    393         }}
    394     } finally {
    395           if (jjtc000) {
    396             jjtree.closeNodeScope(jjtn000, true);
    397             jjtreeCloseNodeScope(jjtn000);
    398           }
    399     }
    400     throw new Error("Missing return statement in function");
    401   }
    402 
    403   static public void Term() throws ParseException {
    404  /*@bgen(jjtree) Term */
    405   ASTTerm jjtn000 = new ASTTerm(JJTTERM);
    406   boolean jjtc000 = true;
    407   jjtree.openNodeScope(jjtn000);
    408   jjtreeOpenNodeScope(jjtn000);int kind=-1;
    409     try {
    410       Factor();
    411       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    412       case AND:
    413       case MULT:
    414       case MOD:
    415       case DIV:
    416         kind = MultOp();
    417                                     jjtn000.setKind(kind);
    418         Term();
    419         break;
    420       default:
    421         jj_la1[9] = jj_gen;
    422       }
    423           jjtree.closeNodeScope(jjtn000, true);
    424           jjtc000 = false;
    425           jjtreeCloseNodeScope(jjtn000);
    426           jjtn000.setPosition(expr_token.beginLine, expr_token.beginColumn);
    427     } catch (Throwable jjte000) {
    428           if (jjtc000) {
    429             jjtree.clearNodeScope(jjtn000);
    430             jjtc000 = false;
    431           } else {
    432             jjtree.popNode();
    433           }
    434           if (jjte000 instanceof ParseException) {
    435             {if (true) {
    436                 throw (ParseException)jjte000;
    437             }}
    438           }
    439           if (jjte000 instanceof RuntimeException) {
    440             {if (true) {
    441                 throw (RuntimeException)jjte000;
    442             }}
    443           }
    444           {if (true) {
    445             throw (Error)jjte000;
    446         }}
    447     } finally {
    448           if (jjtc000) {
    449             jjtree.closeNodeScope(jjtn000, true);
    450             jjtreeCloseNodeScope(jjtn000);
    451           }
    452     }
    453   }
    454 
    455   static public void Factor() throws ParseException {
    456  /*@bgen(jjtree) Factor */
    457   ASTFactor jjtn000 = new ASTFactor(JJTFACTOR);
    458   boolean jjtc000 = true;
    459   jjtree.openNodeScope(jjtn000);
    460   jjtreeOpenNodeScope(jjtn000);int kind=-1;
    461     try {
    462       Element();
    463       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    464       case GT:
    465       case LT:
    466       case GEQ:
    467       case LEQ:
    468       case EQ:
    469       case NEQ:
    470         kind = CmpOp();
    471                                     jjtn000.setKind(kind);
    472         Factor();
    473         break;
    474       default:
    475         jj_la1[10] = jj_gen;
    476       }
    477           jjtree.closeNodeScope(jjtn000, true);
    478           jjtc000 = false;
    479           jjtreeCloseNodeScope(jjtn000);
    480           jjtn000.setPosition(expr_token.beginLine, expr_token.beginColumn);
    481     } catch (Throwable jjte000) {
    482           if (jjtc000) {
    483             jjtree.clearNodeScope(jjtn000);
    484             jjtc000 = false;
    485           } else {
    486             jjtree.popNode();
    487           }
    488           if (jjte000 instanceof ParseException) {
    489             {if (true) {
    490                 throw (ParseException)jjte000;
    491             }}
    492           }
    493           if (jjte000 instanceof RuntimeException) {
    494             {if (true) {
    495                 throw (RuntimeException)jjte000;
    496             }}
    497           }
    498           {if (true) {
    499             throw (Error)jjte000;
    500         }}
    501     } finally {
    502           if (jjtc000) {
    503             jjtree.closeNodeScope(jjtn000, true);
    504             jjtreeCloseNodeScope(jjtn000);
    505           }
    506     }
    507   }
    508 
    509   static public void Element() throws ParseException {
    510     if (jj_2_1(2)) {
    511       expr_token = FunAppl();
    512     } else {
    513       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    514       case FALSE:
    515       case TRUE:
    516       case READ:
    517       case WRITE:
    518       case IDENT:
    519         expr_token = Ident();
    520         break;
    521       case INTEGER:
    522         expr_token = Integer();
    523         break;
    524       case LPAREN:
    525         expr_token = jj_consume_token(LPAREN);
    526         Expr();
    527         jj_consume_token(RPAREN);
    528         break;
    529       default:
    530         jj_la1[11] = jj_gen;
    531         jj_consume_token(-1);
    532         throw new ParseException();
    533       }
    534     }
    535   }
    536 
    537   static public Token Integer() throws ParseException {
    538  /*@bgen(jjtree) Integer */
    539   ASTInteger jjtn000 = new ASTInteger(JJTINTEGER);
    540   boolean jjtc000 = true;
    541   jjtree.openNodeScope(jjtn000);
    542   jjtreeOpenNodeScope(jjtn000);Token t;
    543     try {
    544       t = jj_consume_token(INTEGER);
    545           jjtree.closeNodeScope(jjtn000, true);
    546           jjtc000 = false;
    547           jjtreeCloseNodeScope(jjtn000);
    548           jjtn000.setValue(Integer.parseInt(t.image));
    549           jjtn000.setPosition(t.beginLine, t.beginColumn);
    550           {if (true) {
    551             return t;
    552         }}
    553     } finally {
    554           if (jjtc000) {
    555             jjtree.closeNodeScope(jjtn000, true);
    556             jjtreeCloseNodeScope(jjtn000);
    557           }
    558     }
    559     throw new Error("Missing return statement in function");
    560   }
    561 
    562   static public Token Ident() throws ParseException {
    563  /*@bgen(jjtree) Ident */
    564   ASTIdent jjtn000 = new ASTIdent(JJTIDENT);
    565   boolean jjtc000 = true;
    566   jjtree.openNodeScope(jjtn000);
    567   jjtreeOpenNodeScope(jjtn000);Token t;
    568     try {
    569       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    570       case TRUE:
    571         t = jj_consume_token(TRUE);
    572         break;
    573       case FALSE:
    574         t = jj_consume_token(FALSE);
    575         break;
    576       case READ:
    577         t = jj_consume_token(READ);
    578         break;
    579       case WRITE:
    580         t = jj_consume_token(WRITE);
    581         break;
    582       case IDENT:
    583         t = jj_consume_token(IDENT);
    584         break;
    585       default:
    586         jj_la1[12] = jj_gen;
    587         jj_consume_token(-1);
    588         throw new ParseException();
    589       }
    590           jjtree.closeNodeScope(jjtn000, true);
    591           jjtc000 = false;
    592           jjtreeCloseNodeScope(jjtn000);
    593           jjtn000.setName(t.image);
    594           jjtn000.setPosition(t.beginLine, t.beginColumn);
    595           {if (true) {
    596             return t;
    597         }}
    598     } finally {
    599           if (jjtc000) {
    600             jjtree.closeNodeScope(jjtn000, true);
    601             jjtreeCloseNodeScope(jjtn000);
    602           }
    603     }
    604     throw new Error("Missing return statement in function");
    605   }
    606 
    607   static public int AddOp() throws ParseException {
    608   Token t=null;
    609     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    610     case PLUS:
    611       t = jj_consume_token(PLUS);
    612       break;
    613     case MINUS:
    614       t = jj_consume_token(MINUS);
    615       break;
    616     case OR:
    617       t = jj_consume_token(OR);
    618       break;
    619     default:
    620       jj_la1[13] = jj_gen;
    621       jj_consume_token(-1);
    622       throw new ParseException();
    623     }
    624     {if (true) {
    625         return t.kind;
    626     }}
    627     throw new Error("Missing return statement in function");
    628   }
    629 
    630   static public int MultOp() throws ParseException {
    631   Token t=null;
    632     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    633     case MULT:
    634       t = jj_consume_token(MULT);
    635       break;
    636     case DIV:
    637       t = jj_consume_token(DIV);
    638       break;
    639     case MOD:
    640       t = jj_consume_token(MOD);
    641       break;
    642     case AND:
    643       t = jj_consume_token(AND);
    644       break;
    645     default:
    646       jj_la1[14] = jj_gen;
    647       jj_consume_token(-1);
    648       throw new ParseException();
    649     }
    650     {if (true) {
    651         return t.kind;
    652     }}
    653     throw new Error("Missing return statement in function");
    654   }
    655 
    656   static public int CmpOp() throws ParseException {
    657   Token t=null;
    658     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    659     case EQ:
    660       t = jj_consume_token(EQ);
    661       break;
    662     case NEQ:
    663       t = jj_consume_token(NEQ);
    664       break;
    665     case LEQ:
    666       t = jj_consume_token(LEQ);
    667       break;
    668     case GEQ:
    669       t = jj_consume_token(GEQ);
    670       break;
    671     case GT:
    672       t = jj_consume_token(GT);
    673       break;
    674     case LT:
    675       t = jj_consume_token(LT);
    676       break;
    677     default:
    678       jj_la1[15] = jj_gen;
    679       jj_consume_token(-1);
    680       throw new ParseException();
    681     }
    682     {if (true) {
    683         return t.kind;
    684     }}
    685     throw new Error("Missing return statement in function");
    686   }
    687 
    688   static final public int UnOp() throws ParseException {
    689   Token t=null;
    690     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    691     case MINUS:
    692       t = jj_consume_token(MINUS);
    693       break;
    694     case NOT:
    695       t = jj_consume_token(NOT);
    696       break;
    697     default:
    698       jj_la1[16] = jj_gen;
    699       jj_consume_token(-1);
    700       throw new ParseException();
    701     }
    702     {if (true) {
    703         return t.kind;
    704     }}
    705     throw new Error("Missing return statement in function");
    706   }
    707 
    708   static private boolean jj_2_1(int xla) {
    709     jj_la = xla; jj_lastpos = jj_scanpos = token;
    710     boolean retval = !jj_3_1();
    711     jj_save(0, xla);
    712     return retval;
    713   }
    714 
    715   static private boolean jj_3R_8() {
    716     if (jj_scan_token(FALSE)) {
    717         return true;
    718     }
    719     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    720         return false;
    721     }
    722     return false;
    723   }
    724 
    725   static private boolean jj_3R_11() {
    726     if (jj_scan_token(IDENT)) {
    727         return true;
    728     }
    729     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    730         return false;
    731     }
    732     return false;
    733   }
    734 
    735   static private boolean jj_3R_7() {
    736     if (jj_scan_token(TRUE)) {
    737         return true;
    738     }
    739     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    740         return false;
    741     }
    742     return false;
    743   }
    744 
    745   static private boolean jj_3R_6() {
    746     Token xsp;
    747     xsp = jj_scanpos;
    748     if (jj_3R_7()) {
    749     jj_scanpos = xsp;
    750     if (jj_3R_8()) {
    751     jj_scanpos = xsp;
    752     if (jj_3R_9()) {
    753     jj_scanpos = xsp;
    754     if (jj_3R_10()) {
    755     jj_scanpos = xsp;
    756     if (jj_3R_11()) {
    757         return true;
    758     }
    759     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    760         return false;
    761     }
    762     } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    763         return false;
    764     }
    765     } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    766         return false;
    767     }
    768     } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    769         return false;
    770     }
    771     } else if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    772         return false;
    773     }
    774     return false;
    775   }
    776 
    777   static private boolean jj_3_1() {
    778     if (jj_3R_5()) {
    779         return true;
    780     }
    781     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    782         return false;
    783     }
    784     return false;
    785   }
    786 
    787   static private boolean jj_3R_5() {
    788     if (jj_3R_6()) {
    789         return true;
    790     }
    791     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    792         return false;
    793     }
    794     if (jj_scan_token(LPAREN)) {
    795         return true;
    796     }
    797     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    798         return false;
    799     }
    800     return false;
    801   }
    802 
    803   static private boolean jj_3R_10() {
    804     if (jj_scan_token(WRITE)) {
    805         return true;
    806     }
    807     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    808         return false;
    809     }
    810     return false;
    811   }
    812 
    813   static private boolean jj_3R_9() {
    814     if (jj_scan_token(READ)) {
    815         return true;
    816     }
    817     if (jj_la == 0 && jj_scanpos == jj_lastpos) {
    818         return false;
    819     }
    820     return false;
    821   }
    822 
    823   static private boolean jj_initialized_once = false;
    824   static public MiniParserTokenManager token_source;
    825   static ASCII_CharStream jj_input_stream;
    826   static public Token token, jj_nt;
    827   static private int jj_ntk;
    828   static private Token jj_scanpos, jj_lastpos;
    829   static private int jj_la;
    830   static public boolean lookingAhead = false;
    831 //  static private boolean jj_semLA;
    832   static private int jj_gen;
    833   static final private int[] jj_la1 = new int[17];
    834   static final private int[] jj_la1_0 = {0x200,0x0,0x1800000,0x1c000000,0x11c04400,0x1000,0x1800000,0x0,0x11c04400,
    835           0xe2000000,0x3f0000,0x1800000,0x1800000,0x1c000000,0xe2000000,0x3f0000,0x10400000,};
    836   static final private int[] jj_la1_1 = {0x0,0x8,0x130,0x0,0x331,0x0,0x130,0x8,0x331,0x0,0x0,0x331,0x130,0x0,0x0,0x0,0x0,};
    837   static final private JJCalls[] jj_2_rtns = new JJCalls[1];
    838   static private boolean jj_rescan = false;
    839   static private int jj_gc = 0;
    840 
    841   public MiniParser(java.io.InputStream stream) {
    842     if (jj_initialized_once) {
    843       System.out.println("ERROR: Second call to constructor of static parser.  You must");
    844       System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
    845       System.out.println("       during parser generation.");
    846       throw new Error();
    847     }
    848     jj_initialized_once = true;
    849     jj_input_stream = new ASCII_CharStream(stream, 1, 1);
    850     token_source = new MiniParserTokenManager(jj_input_stream);
    851     token = new Token();
    852     jj_ntk = -1;
    853     jj_gen = 0;
    854     for (int i = 0; i < 17; i++) {
    855         jj_la1[i] = -1;
    856     }
    857     for (int i = 0; i < jj_2_rtns.length; i++) {
    858         jj_2_rtns[i] = new JJCalls();
    859     }
    860   }
    861 
    862   static public void ReInit(java.io.InputStream stream) {
    863     ASCII_CharStream.ReInit(stream, 1, 1);
    864     MiniParserTokenManager.ReInit(jj_input_stream);
    865     token = new Token();
    866     jj_ntk = -1;
    867     jjtree.reset();
    868     jj_gen = 0;
    869     for (int i = 0; i < 17; i++) {
    870         jj_la1[i] = -1;
    871     }
    872     for (int i = 0; i < jj_2_rtns.length; i++) {
    873         jj_2_rtns[i] = new JJCalls();
    874     }
    875   }
    876 
    877   public MiniParser(java.io.Reader stream) {
    878     if (jj_initialized_once) {
    879       System.out.println("ERROR: Second call to constructor of static parser.  You must");
    880       System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
    881       System.out.println("       during parser generation.");
    882       throw new Error();
    883     }
    884     jj_initialized_once = true;
    885     jj_input_stream = new ASCII_CharStream(stream, 1, 1);
    886     token_source = new MiniParserTokenManager(jj_input_stream);
    887     token = new Token();
    888     jj_ntk = -1;
    889     jj_gen = 0;
    890     for (int i = 0; i < 17; i++) {
    891         jj_la1[i] = -1;
    892     }
    893     for (int i = 0; i < jj_2_rtns.length; i++) {
    894         jj_2_rtns[i] = new JJCalls();
    895     }
    896   }
    897 
    898   static public void ReInit(java.io.Reader stream) {
    899     ASCII_CharStream.ReInit(stream, 1, 1);
    900     MiniParserTokenManager.ReInit(jj_input_stream);
    901     token = new Token();
    902     jj_ntk = -1;
    903     jjtree.reset();
    904     jj_gen = 0;
    905     for (int i = 0; i < 17; i++) {
    906         jj_la1[i] = -1;
    907     }
    908     for (int i = 0; i < jj_2_rtns.length; i++) {
    909         jj_2_rtns[i] = new JJCalls();
    910     }
    911   }
    912 
    913   public MiniParser(MiniParserTokenManager tm) {
    914     if (jj_initialized_once) {
    915       System.out.println("ERROR: Second call to constructor of static parser.  You must");
    916       System.out.println("       either use ReInit() or set the JavaCC option STATIC to false");
    917       System.out.println("       during parser generation.");
    918       throw new Error();
    919     }
    920     jj_initialized_once = true;
    921     token_source = tm;
    922     token = new Token();
    923     jj_ntk = -1;
    924     jj_gen = 0;
    925     for (int i = 0; i < 17; i++) {
    926         jj_la1[i] = -1;
    927     }
    928     for (int i = 0; i < jj_2_rtns.length; i++) {
    929         jj_2_rtns[i] = new JJCalls();
    930     }
    931   }
    932 
    933   public void ReInit(MiniParserTokenManager tm) {
    934     token_source = tm;
    935     token = new Token();
    936     jj_ntk = -1;
    937     jjtree.reset();
    938     jj_gen = 0;
    939     for (int i = 0; i < 17; i++) {
    940         jj_la1[i] = -1;
    941     }
    942     for (int i = 0; i < jj_2_rtns.length; i++) {
    943         jj_2_rtns[i] = new JJCalls();
    944     }
    945   }
    946 
    947   static private Token jj_consume_token(int kind) throws ParseException {
    948     Token oldToken;
    949     if ((oldToken = token).next != null) {
    950         token = token.next;
    951     } else {
    952         token = token.next = MiniParserTokenManager.getNextToken();
    953     }
    954     jj_ntk = -1;
    955     if (token.kind == kind) {
    956       jj_gen++;
    957       if (++jj_gc > 100) {
    958         jj_gc = 0;
    959         for (int i = 0; i < jj_2_rtns.length; i++) {
    960           JJCalls c = jj_2_rtns[i];
    961           while (c != null) {
    962             if (c.gen < jj_gen) {
    963                 c.first = null;
    964             }
    965             c = c.next;
    966           }
    967         }
    968       }
    969       return token;
    970     }
    971     token = oldToken;
    972     jj_kind = kind;
    973     throw generateParseException();
    974   }
    975 
    976   static private boolean jj_scan_token(int kind) {
    977     if (jj_scanpos == jj_lastpos) {
    978       jj_la--;
    979       if (jj_scanpos.next == null) {
    980         jj_lastpos = jj_scanpos = jj_scanpos.next = MiniParserTokenManager.getNextToken();
    981       } else {
    982         jj_lastpos = jj_scanpos = jj_scanpos.next;
    983       }
    984     } else {
    985       jj_scanpos = jj_scanpos.next;
    986     }
    987     if (jj_rescan) {
    988       int i = 0; Token tok = token;
    989       while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
    990       if (tok != null) {
    991         jj_add_error_token(kind, i);
    992     }
    993     }
    994     return (jj_scanpos.kind != kind);
    995   }
    996 
    997   static public Token getNextToken() {
    998     if (token.next != null) {
    999         token = token.next;
   1000     } else {
   1001         token = token.next = MiniParserTokenManager.getNextToken();
   1002     }
   1003     jj_ntk = -1;
   1004     jj_gen++;
   1005     return token;
   1006   }
   1007 
   1008   static public Token getToken(int index) {
   1009     Token t = lookingAhead ? jj_scanpos : token;
   1010     for (int i = 0; i < index; i++) {
   1011       if (t.next != null) {
   1012         t = t.next;
   1013     } else {
   1014         t = t.next = MiniParserTokenManager.getNextToken();
   1015     }
   1016     }
   1017     return t;
   1018   }
   1019 
   1020   static private int jj_ntk() {
   1021     if ((jj_nt=token.next) == null) {
   1022         return (jj_ntk = (token.next=MiniParserTokenManager.getNextToken()).kind);
   1023     } else {
   1024         return (jj_ntk = jj_nt.kind);
   1025     }
   1026   }
   1027 
   1028   static private java.util.Vector<int[]> jj_expentries = new java.util.Vector<int[]>();
   1029   static private int[] jj_expentry;
   1030   static private int jj_kind = -1;
   1031   static private int[] jj_lasttokens = new int[100];
   1032   static private int jj_endpos;
   1033 
   1034   static private void jj_add_error_token(int kind, int pos) {
   1035     if (pos >= 100) {
   1036         return;
   1037     }
   1038     if (pos == jj_endpos + 1) {
   1039       jj_lasttokens[jj_endpos++] = kind;
   1040     } else if (jj_endpos != 0) {
   1041       jj_expentry = new int[jj_endpos];
   1042       for (int i = 0; i < jj_endpos; i++) {
   1043         jj_expentry[i] = jj_lasttokens[i];
   1044       }
   1045       boolean exists = false;
   1046       for (java.util.Enumeration<int[]> e = jj_expentries.elements(); e.hasMoreElements();) {
   1047         int[] oldentry = (e.nextElement());
   1048         if (oldentry.length == jj_expentry.length) {
   1049           exists = true;
   1050           for (int i = 0; i < jj_expentry.length; i++) {
   1051             if (oldentry[i] != jj_expentry[i]) {
   1052               exists = false;
   1053               break;
   1054             }
   1055           }
   1056           if (exists) {
   1057             break;
   1058         }
   1059         }
   1060       }
   1061       if (!exists) {
   1062         jj_expentries.addElement(jj_expentry);
   1063     }
   1064       if (pos != 0) {
   1065         jj_lasttokens[(jj_endpos = pos) - 1] = kind;
   1066     }
   1067     }
   1068   }
   1069 
   1070   static public ParseException generateParseException() {
   1071     jj_expentries.removeAllElements();
   1072     boolean[] la1tokens = new boolean[43];
   1073     for (int i = 0; i < 43; i++) {
   1074       la1tokens[i] = false;
   1075     }
   1076     if (jj_kind >= 0) {
   1077       la1tokens[jj_kind] = true;
   1078       jj_kind = -1;
   1079     }
   1080     for (int i = 0; i < 17; i++) {
   1081       if (jj_la1[i] == jj_gen) {
   1082         for (int j = 0; j < 32; j++) {
   1083           if ((jj_la1_0[i] & (1<<j)) != 0) {
   1084             la1tokens[j] = true;
   1085           }
   1086           if ((jj_la1_1[i] & (1<<j)) != 0) {
   1087             la1tokens[32+j] = true;
   1088           }
   1089         }
   1090       }
   1091     }
   1092     for (int i = 0; i < 43; i++) {
   1093       if (la1tokens[i]) {
   1094         jj_expentry = new int[1];
   1095         jj_expentry[0] = i;
   1096         jj_expentries.addElement(jj_expentry);
   1097       }
   1098     }
   1099     jj_endpos = 0;
   1100     jj_rescan_token();
   1101     jj_add_error_token(0, 0);
   1102     int[][] exptokseq = new int[jj_expentries.size()][];
   1103     for (int i = 0; i < jj_expentries.size(); i++) {
   1104       exptokseq[i] = jj_expentries.elementAt(i);
   1105     }
   1106     return new ParseException(token, exptokseq, tokenImage);
   1107   }
   1108 
   1109   static public void enable_tracing() {
   1110   }
   1111 
   1112   static public void disable_tracing() {
   1113   }
   1114 
   1115   static private void jj_rescan_token() {
   1116     jj_rescan = true;
   1117     for (int i = 0; i < 1; i++) {
   1118       JJCalls p = jj_2_rtns[i];
   1119       do {
   1120         if (p.gen > jj_gen) {
   1121           jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
   1122           switch (i) {
   1123             case 0: jj_3_1(); break;
   1124           }
   1125         }
   1126         p = p.next;
   1127       } while (p != null);
   1128     }
   1129     jj_rescan = false;
   1130   }
   1131 
   1132   static private void jj_save(int index, int xla) {
   1133     JJCalls p = jj_2_rtns[index];
   1134     while (p.gen > jj_gen) {
   1135       if (p.next == null) { p = p.next = new JJCalls(); break; }
   1136       p = p.next;
   1137     }
   1138     p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
   1139   }
   1140 
   1141   private static final class JJCalls {
   1142     int gen;
   1143     Token first;
   1144     int arg;
   1145     JJCalls next;
   1146   }
   1147 
   1148 }
   1149