/* Generated By:JavaCC: Do not edit this line. simplejava.java */ public class simplejava implements simplejavaConstants { /***************************************** * SimpleJava Language Grammar Starts Here *****************************************/ static final public void program() throws ParseException { trace_call("program"); try { label_1: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CLASS: case BOOLEAN: case VOID: case IDENTIFIER: ; break; default: jj_la1[0] = jj_gen; break label_1; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case CLASS: ClassDefinitions(); break; case BOOLEAN: case VOID: case IDENTIFIER: FunctionDeclaration(); break; default: jj_la1[1] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } jj_consume_token(0); } finally { trace_return("program"); } } static final public void ClassDefinitions() throws ParseException { trace_call("ClassDefinitions"); try { jj_consume_token(CLASS); jj_consume_token(IDENTIFIER); jj_consume_token(LBRACE); label_2: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEAN: case IDENTIFIER: ; break; default: jj_la1[2] = jj_gen; break label_2; } VariableDeclarationStatement(); } jj_consume_token(RBRACE); } finally { trace_return("ClassDefinitions"); } } /*Two kinds of Function Declarations: FunctionProtoype or FunctionDefinition. */ static final public void FunctionDeclaration() throws ParseException { trace_call("FunctionDeclaration"); try { FunctionType(); jj_consume_token(IDENTIFIER); FormalParameterList(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: jj_consume_token(SEMICOLON); break; case LBRACE: jj_consume_token(LBRACE); StatementList(); jj_consume_token(RBRACE); break; default: jj_la1[3] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } finally { trace_return("FunctionDeclaration"); } } static final public void FunctionType() throws ParseException { trace_call("FunctionType"); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case VOID: jj_consume_token(VOID); break; case BOOLEAN: jj_consume_token(BOOLEAN); break; case IDENTIFIER: jj_consume_token(IDENTIFIER); break; default: jj_la1[4] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } finally { trace_return("FunctionType"); } } static final public void VariableType() throws ParseException { trace_call("VariableType"); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEAN: jj_consume_token(BOOLEAN); break; case IDENTIFIER: jj_consume_token(IDENTIFIER); break; default: jj_la1[5] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } finally { trace_return("VariableType"); } } // 5th Expression static final public void NewExpression() throws ParseException { trace_call("NewExpression"); try { if (jj_2_1(3)) { jj_consume_token(NEW); VariableType(); jj_consume_token(LPAREN); jj_consume_token(RPAREN); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NEW: jj_consume_token(NEW); VariableType(); jj_consume_token(LBRACKET); Variable(); jj_consume_token(RBRACKET); label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: ; break; default: jj_la1[6] = jj_gen; break label_3; } jj_consume_token(LBRACKET); jj_consume_token(RBRACKET); } break; default: jj_la1[7] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } finally { trace_return("NewExpression"); } } static final public void FormalParameterList() throws ParseException { trace_call("FormalParameterList"); try { jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BOOLEAN: case IDENTIFIER: FormalParameter(); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[8] = jj_gen; break label_4; } jj_consume_token(COMMA); FormalParameter(); } break; default: jj_la1[9] = jj_gen; ; } jj_consume_token(RPAREN); } finally { trace_return("FormalParameterList"); } } static final public void FormalParameter() throws ParseException { trace_call("FormalParameter"); try { VariableType(); Variable(); label_5: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LBRACKET: ; break; default: jj_la1[10] = jj_gen; break label_5; } jj_consume_token(LBRACKET); jj_consume_token(RBRACKET); } } finally { trace_return("FormalParameter"); } } static final public void ExpressionList() throws ParseException { trace_call("ExpressionList"); try { Expression(); label_6: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: jj_la1[11] = jj_gen; break label_6; } jj_consume_token(COMMA); Expression(); } } finally { trace_return("ExpressionList"); } } /* four VariableTypes of expression. */ static final public void Expression() throws ParseException { trace_call("Expression"); try { if (jj_2_2(3)) { FunctionCall(); } else if (jj_2_3(2)) { CompleteOperatorExpression(); } else if (jj_2_4(2)) { Variable(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: case FALSE: case INTEGER_LITERAL: ConstantExpression(); break; case NEW: NewExpression(); break; default: jj_la1[12] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } finally { trace_return("Expression"); } } // First Expression. static final public void ConstantExpression() throws ParseException { trace_call("ConstantExpression"); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: jj_consume_token(INTEGER_LITERAL); break; case TRUE: jj_consume_token(TRUE); break; case FALSE: jj_consume_token(FALSE); break; default: jj_la1[13] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } finally { trace_return("ConstantExpression"); } } // Three kinds of variables. static final public void Variable() throws ParseException { trace_call("Variable"); try { if (jj_2_5(2)) { ArrayVariable(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: PrimitiveVariableTypeOrClassVariable(); break; default: jj_la1[14] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } finally { trace_return("Variable"); } } //TODO: Make sure the variable in [] is integer value. static final public void ArrayVariable() throws ParseException { trace_call("ArrayVariable"); try { jj_consume_token(IDENTIFIER); jj_consume_token(LBRACKET); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: Variable(); break; default: jj_la1[15] = jj_gen; ; } jj_consume_token(RBRACKET); } finally { trace_return("ArrayVariable"); } } static final public void PrimitiveVariableTypeOrClassVariable() throws ParseException { trace_call("PrimitiveVariableTypeOrClassVariable"); try { if (jj_2_6(2)) { jj_consume_token(IDENTIFIER); label_7: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PERIOD: ; break; default: jj_la1[16] = jj_gen; break label_7; } jj_consume_token(PERIOD); jj_consume_token(IDENTIFIER); } } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: jj_consume_token(IDENTIFIER); label_8: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PERIOD: ; break; default: jj_la1[17] = jj_gen; break label_8; } jj_consume_token(PERIOD); ArrayVariable(); } break; default: jj_la1[18] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } finally { trace_return("PrimitiveVariableTypeOrClassVariable"); } } // TODO check this classvariable // void ClassVariable(): // {} // { // // } // Three built-in function: readfunction,printfunction and printlnfunction. static final public void ReadFunctionCall() throws ParseException { trace_call("ReadFunctionCall"); try { jj_consume_token(READ); jj_consume_token(LPAREN); jj_consume_token(RPAREN); } finally { trace_return("ReadFunctionCall"); } } //TODO make sure print(int value) static final public void PrintFunctionCall() throws ParseException { trace_call("PrintFunctionCall"); try { jj_consume_token(PRINT); jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: jj_consume_token(INTEGER_LITERAL); break; case IDENTIFIER: jj_consume_token(IDENTIFIER); break; default: jj_la1[19] = jj_gen; jj_consume_token(-1); throw new ParseException(); } jj_consume_token(RPAREN); } finally { trace_return("PrintFunctionCall"); } } static final public void PrintlnFunctionCall() throws ParseException { trace_call("PrintlnFunctionCall"); try { jj_consume_token(PRINTLN); jj_consume_token(LPAREN); jj_consume_token(RPAREN); } finally { trace_return("PrintlnFunctionCall"); } } static final public void CustomizedFunctionCall() throws ParseException { trace_call("CustomizedFunctionCall"); try { jj_consume_token(IDENTIFIER); jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: case FALSE: case NEW: case READ: case PRINT: case PRINTLN: case INTEGER_LITERAL: case IDENTIFIER: case MINUS: case LPAREN: case NOT: ExpressionList(); break; default: jj_la1[20] = jj_gen; ; } jj_consume_token(RPAREN); } finally { trace_return("CustomizedFunctionCall"); } } //Three built-in function and a customized function. static final public void FunctionCall() throws ParseException { trace_call("FunctionCall"); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case READ: ReadFunctionCall(); break; case PRINT: PrintFunctionCall(); break; case PRINTLN: PrintlnFunctionCall(); break; case IDENTIFIER: CustomizedFunctionCall(); break; default: jj_la1[21] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } finally { trace_return("FunctionCall"); } } //4th Expression //The OperatorExpression static final public void CompleteOperatorExpression() throws ParseException { trace_call("CompleteOperatorExpression"); try { AndExpression(); label_9: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case OR: ; break; default: jj_la1[22] = jj_gen; break label_9; } jj_consume_token(OR); AndExpression(); } } finally { trace_return("CompleteOperatorExpression"); } } static final public void AndExpression() throws ParseException { trace_call("AndExpression"); try { NotExpression(); label_10: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AND: ; break; default: jj_la1[23] = jj_gen; break label_10; } jj_consume_token(AND); NotExpression(); } } finally { trace_return("AndExpression"); } } static final public void NotExpression() throws ParseException { trace_call("NotExpression"); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case NOT: jj_consume_token(NOT); break; default: jj_la1[24] = jj_gen; ; } CompareExpression(); } finally { trace_return("NotExpression"); } } static final public void CompareExpression() throws ParseException { trace_call("CompareExpression"); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: jj_consume_token(TRUE); break; case FALSE: jj_consume_token(FALSE); break; case READ: case PRINT: case PRINTLN: case INTEGER_LITERAL: case IDENTIFIER: case MINUS: case LPAREN: MathExpression(); label_11: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQUALEQUAL: case NOTEQUALTO: case LESSTHAN: case LESSTHANOREQUALTO: case GREATERTHAN: case GREATERTHANOREQUALTO: ; break; default: jj_la1[25] = jj_gen; break label_11; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EQUALEQUAL: jj_consume_token(EQUALEQUAL); break; case NOTEQUALTO: jj_consume_token(NOTEQUALTO); break; case LESSTHAN: jj_consume_token(LESSTHAN); break; case LESSTHANOREQUALTO: jj_consume_token(LESSTHANOREQUALTO); break; case GREATERTHAN: jj_consume_token(GREATERTHAN); break; case GREATERTHANOREQUALTO: jj_consume_token(GREATERTHANOREQUALTO); break; default: jj_la1[26] = jj_gen; jj_consume_token(-1); throw new ParseException(); } MathExpression(); } break; default: jj_la1[27] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } finally { trace_return("CompareExpression"); } } static final public void MathExpression() throws ParseException { trace_call("MathExpression"); try { term(); label_12: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: case MINUS: ; break; default: jj_la1[28] = jj_gen; break label_12; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: jj_consume_token(PLUS); break; case MINUS: jj_consume_token(MINUS); break; default: jj_la1[29] = jj_gen; jj_consume_token(-1); throw new ParseException(); } term(); } } finally { trace_return("MathExpression"); } } static final public void term() throws ParseException { trace_call("term"); try { factor(); label_13: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MULTIPLY: case DIVIDE: ; break; default: jj_la1[30] = jj_gen; break label_13; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MULTIPLY: jj_consume_token(MULTIPLY); break; case DIVIDE: jj_consume_token(DIVIDE); break; default: jj_la1[31] = jj_gen; jj_consume_token(-1); throw new ParseException(); } factor(); } } finally { trace_return("term"); } } static final public void factor() throws ParseException { trace_call("factor"); try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case MINUS: jj_consume_token(MINUS); factor(); break; case INTEGER_LITERAL: jj_consume_token(INTEGER_LITERAL); break; default: jj_la1[32] = jj_gen; if (jj_2_7(2)) { Variable(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: jj_consume_token(LPAREN); Expression(); jj_consume_token(RPAREN); break; case READ: case PRINT: case PRINTLN: case IDENTIFIER: FunctionCall(); break; default: jj_la1[33] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } } finally { trace_return("factor"); } } // zero or more statements. static final public void StatementList() throws ParseException { trace_call("StatementList"); try { label_14: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FOR: case IF: case WHILE: case DO: case BOOLEAN: case RETURN: case READ: case PRINT: case PRINTLN: case IDENTIFIER: case SEMICOLON: case LBRACE: ; break; default: jj_la1[34] = jj_gen; break label_14; } Statement(); } } finally { trace_return("StatementList"); } } // 11 kinds of statement static final public void Statement() throws ParseException { trace_call("Statement"); try { if (jj_2_8(3)) { AssignmentStatement(); } else if (jj_2_9(3)) { IncrementStatement(); } else if (jj_2_10(3)) { VariableDeclarationStatement(); } else if (jj_2_11(3)) { IfStatement(); } else if (jj_2_12(3)) { DanglingIfElseStatement(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case WHILE: WhileStatement(); break; case DO: DoWhileStatement(); break; case FOR: ForStatement(); break; case READ: case PRINT: case PRINTLN: case IDENTIFIER: FunctionCallStatement(); break; case RETURN: ReturnStatement(); break; case SEMICOLON: EmptyStatement(); break; case LBRACE: BlockStatement(); break; default: jj_la1[35] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } finally { trace_return("Statement"); } } static final public void AssignmentStatement() throws ParseException { trace_call("AssignmentStatement"); try { Variable(); jj_consume_token(GETS); Expression(); jj_consume_token(SEMICOLON); } finally { trace_return("AssignmentStatement"); } } // TODO incrementstatement just like ++ or -- static final public void IncrementStatement() throws ParseException { trace_call("IncrementStatement"); try { if (jj_2_13(3)) { Variable(); jj_consume_token(PLUSPLUS); } else if (jj_2_14(3)) { Variable(); jj_consume_token(MINUS); jj_consume_token(MINUS); } else { jj_consume_token(-1); throw new ParseException(); } } finally { trace_return("IncrementStatement"); } } static final public void VariableDeclarationStatement() throws ParseException { trace_call("VariableDeclarationStatement"); try { VariableType(); Variable(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case GETS: jj_consume_token(GETS); Expression(); break; default: jj_la1[36] = jj_gen; ; } jj_consume_token(SEMICOLON); } finally { trace_return("VariableDeclarationStatement"); } } static final public void IfStatement() throws ParseException { trace_call("IfStatement"); try { jj_consume_token(IF); jj_consume_token(LPAREN); Expression(); jj_consume_token(RPAREN); Statement(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ELSE: jj_consume_token(ELSE); Statement(); break; default: jj_la1[37] = jj_gen; ; } } finally { trace_return("IfStatement"); } } static final public void DanglingIfElseStatement() throws ParseException { trace_call("DanglingIfElseStatement"); try { jj_consume_token(IF); jj_consume_token(LPAREN); Expression(); jj_consume_token(RPAREN); jj_consume_token(LBRACE); jj_consume_token(LPAREN); jj_consume_token(IF); jj_consume_token(LPAREN); Expression(); jj_consume_token(RPAREN); Statement(); jj_consume_token(ELSE); Statement(); jj_consume_token(RBRACE); } finally { trace_return("DanglingIfElseStatement"); } } static final public void WhileStatement() throws ParseException { trace_call("WhileStatement"); try { jj_consume_token(WHILE); jj_consume_token(LPAREN); Expression(); jj_consume_token(RPAREN); Statement(); } finally { trace_return("WhileStatement"); } } static final public void DoWhileStatement() throws ParseException { trace_call("DoWhileStatement"); try { jj_consume_token(DO); Statement(); jj_consume_token(WHILE); jj_consume_token(LPAREN); Expression(); jj_consume_token(RPAREN); jj_consume_token(SEMICOLON); } finally { trace_return("DoWhileStatement"); } } static final public void ForStatement() throws ParseException { trace_call("ForStatement"); try { jj_consume_token(FOR); jj_consume_token(LPAREN); ForInit(); Expression(); jj_consume_token(SEMICOLON); IncrementStatement(); jj_consume_token(RPAREN); Statement(); } finally { trace_return("ForStatement"); } } // TODO check ForInit can taek incremnet statement. static final public void ForInit() throws ParseException { trace_call("ForInit"); try { if (jj_2_15(3)) { VariableType(); Variable(); } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: AssignmentStatement(); break; case SEMICOLON: EmptyStatement(); break; default: jj_la1[38] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } } finally { trace_return("ForInit"); } } static final public void EmptyStatement() throws ParseException { trace_call("EmptyStatement"); try { jj_consume_token(SEMICOLON); } finally { trace_return("EmptyStatement"); } } static final public void FunctionCallStatement() throws ParseException { trace_call("FunctionCallStatement"); try { FunctionCall(); jj_consume_token(SEMICOLON); } finally { trace_return("FunctionCallStatement"); } } static final public void ReturnStatement() throws ParseException { trace_call("ReturnStatement"); try { jj_consume_token(RETURN); Expression(); jj_consume_token(SEMICOLON); } finally { trace_return("ReturnStatement"); } } static final public void BlockStatement() throws ParseException { trace_call("BlockStatement"); try { jj_consume_token(LBRACE); StatementList(); jj_consume_token(RBRACE); } finally { trace_return("BlockStatement"); } } static private boolean jj_2_1(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_1(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(0, xla); } } static private boolean jj_2_2(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_2(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(1, xla); } } static private boolean jj_2_3(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_3(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(2, xla); } } static private boolean jj_2_4(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_4(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(3, xla); } } static private boolean jj_2_5(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_5(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(4, xla); } } static private boolean jj_2_6(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_6(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(5, xla); } } static private boolean jj_2_7(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_7(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(6, xla); } } static private boolean jj_2_8(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_8(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(7, xla); } } static private boolean jj_2_9(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_9(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(8, xla); } } static private boolean jj_2_10(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_10(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(9, xla); } } static private boolean jj_2_11(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_11(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(10, xla); } } static private boolean jj_2_12(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_12(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(11, xla); } } static private boolean jj_2_13(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_13(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(12, xla); } } static private boolean jj_2_14(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_14(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(13, xla); } } static private boolean jj_2_15(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_15(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(14, xla); } } static private boolean jj_3R_57() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(28)) { jj_scanpos = xsp; if (jj_scan_token(30)) return true; } return false; } static private boolean jj_3R_47() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(26)) { jj_scanpos = xsp; if (jj_scan_token(18)) { jj_scanpos = xsp; if (jj_scan_token(19)) return true; } } return false; } static private boolean jj_3R_56() { if (jj_3R_58()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_59()) { jj_scanpos = xsp; break; } } return false; } static private boolean jj_3_15() { if (jj_3R_15()) return true; if (jj_3R_18()) return true; return false; } static private boolean jj_3R_40() { if (jj_scan_token(AND)) return true; return false; } static private boolean jj_3R_54() { if (jj_3R_56()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_57()) { jj_scanpos = xsp; break; } } return false; } static private boolean jj_3R_51() { if (jj_3R_54()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_55()) { jj_scanpos = xsp; break; } } return false; } static private boolean jj_3R_42() { if (jj_3R_47()) return true; return false; } static private boolean jj_3_2() { if (jj_3R_16()) return true; return false; } static private boolean jj_3R_33() { Token xsp; xsp = jj_scanpos; if (jj_3_2()) { jj_scanpos = xsp; if (jj_3_3()) { jj_scanpos = xsp; if (jj_3_4()) { jj_scanpos = xsp; if (jj_3R_42()) { jj_scanpos = xsp; if (jj_3R_43()) return true; } } } } return false; } static private boolean jj_3R_45() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(18)) { jj_scanpos = xsp; if (jj_scan_token(19)) { jj_scanpos = xsp; if (jj_3R_51()) return true; } } return false; } static private boolean jj_3R_34() { if (jj_scan_token(GETS)) return true; return false; } static private boolean jj_3R_31() { if (jj_scan_token(OR)) return true; return false; } static private boolean jj_3R_50() { if (jj_3R_33()) return true; return false; } static private boolean jj_3R_39() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(44)) jj_scanpos = xsp; if (jj_3R_45()) return true; return false; } static private boolean jj_3R_30() { if (jj_3R_39()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_40()) { jj_scanpos = xsp; break; } } return false; } static private boolean jj_3R_25() { if (jj_scan_token(IF)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_33()) return true; return false; } static private boolean jj_3R_44() { if (jj_3R_50()) return true; return false; } static private boolean jj_3R_17() { if (jj_3R_30()) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_31()) { jj_scanpos = xsp; break; } } return false; } static private boolean jj_3R_53() { if (jj_scan_token(NEW)) return true; return false; } static private boolean jj_3R_24() { if (jj_scan_token(IF)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_3R_33()) return true; return false; } static private boolean jj_3R_48() { Token xsp; xsp = jj_scanpos; if (jj_3_1()) { jj_scanpos = xsp; if (jj_3R_53()) return true; } return false; } static private boolean jj_3_1() { if (jj_scan_token(NEW)) return true; if (jj_3R_15()) return true; if (jj_scan_token(LPAREN)) return true; return false; } static private boolean jj_3_4() { if (jj_3R_18()) return true; return false; } static private boolean jj_3R_23() { if (jj_3R_15()) return true; if (jj_3R_18()) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_34()) jj_scanpos = xsp; if (jj_scan_token(SEMICOLON)) return true; return false; } static private boolean jj_3R_29() { if (jj_3R_38()) return true; return false; } static private boolean jj_3R_15() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(17)) { jj_scanpos = xsp; if (jj_scan_token(27)) return true; } return false; } static private boolean jj_3R_28() { if (jj_3R_37()) return true; return false; } static private boolean jj_3R_27() { if (jj_3R_36()) return true; return false; } static private boolean jj_3R_16() { Token xsp; xsp = jj_scanpos; if (jj_3R_26()) { jj_scanpos = xsp; if (jj_3R_27()) { jj_scanpos = xsp; if (jj_3R_28()) { jj_scanpos = xsp; if (jj_3R_29()) return true; } } } return false; } static private boolean jj_3R_26() { if (jj_3R_35()) return true; return false; } static private boolean jj_3_14() { if (jj_3R_18()) return true; if (jj_scan_token(MINUS)) return true; if (jj_scan_token(MINUS)) return true; return false; } static private boolean jj_3_13() { if (jj_3R_18()) return true; if (jj_scan_token(PLUSPLUS)) return true; return false; } static private boolean jj_3R_22() { Token xsp; xsp = jj_scanpos; if (jj_3_13()) { jj_scanpos = xsp; if (jj_3_14()) return true; } return false; } static private boolean jj_3R_38() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(LPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_44()) jj_scanpos = xsp; if (jj_scan_token(RPAREN)) return true; return false; } static private boolean jj_3R_21() { if (jj_3R_18()) return true; if (jj_scan_token(GETS)) return true; if (jj_3R_33()) return true; return false; } static private boolean jj_3R_37() { if (jj_scan_token(PRINTLN)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_scan_token(RPAREN)) return true; return false; } static private boolean jj_3R_20() { if (jj_scan_token(PERIOD)) return true; if (jj_scan_token(IDENTIFIER)) return true; return false; } static private boolean jj_3R_36() { if (jj_scan_token(PRINT)) return true; if (jj_scan_token(LPAREN)) return true; Token xsp; xsp = jj_scanpos; if (jj_scan_token(26)) { jj_scanpos = xsp; if (jj_scan_token(27)) return true; } return false; } static private boolean jj_3R_32() { if (jj_3R_41()) return true; return false; } static private boolean jj_3R_49() { if (jj_3R_18()) return true; return false; } static private boolean jj_3_12() { if (jj_3R_25()) return true; return false; } static private boolean jj_3R_35() { if (jj_scan_token(READ)) return true; if (jj_scan_token(LPAREN)) return true; if (jj_scan_token(RPAREN)) return true; return false; } static private boolean jj_3_10() { if (jj_3R_23()) return true; return false; } static private boolean jj_3R_52() { if (jj_scan_token(PERIOD)) return true; if (jj_3R_19()) return true; return false; } static private boolean jj_3_9() { if (jj_3R_22()) return true; return false; } static private boolean jj_3_8() { if (jj_3R_21()) return true; return false; } static private boolean jj_3_11() { if (jj_3R_24()) return true; return false; } static private boolean jj_3_3() { if (jj_3R_17()) return true; return false; } static private boolean jj_3R_46() { if (jj_scan_token(IDENTIFIER)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_52()) { jj_scanpos = xsp; break; } } return false; } static private boolean jj_3R_41() { Token xsp; xsp = jj_scanpos; if (jj_3_6()) { jj_scanpos = xsp; if (jj_3R_46()) return true; } return false; } static private boolean jj_3_6() { if (jj_scan_token(IDENTIFIER)) return true; Token xsp; while (true) { xsp = jj_scanpos; if (jj_3R_20()) { jj_scanpos = xsp; break; } } return false; } static private boolean jj_3R_62() { if (jj_3R_16()) return true; return false; } static private boolean jj_3R_43() { if (jj_3R_48()) return true; return false; } static private boolean jj_3_7() { if (jj_3R_18()) return true; return false; } static private boolean jj_3R_19() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_scan_token(LBRACKET)) return true; Token xsp; xsp = jj_scanpos; if (jj_3R_49()) jj_scanpos = xsp; if (jj_scan_token(RBRACKET)) return true; return false; } static private boolean jj_3R_55() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(41)) { jj_scanpos = xsp; if (jj_scan_token(43)) { jj_scanpos = xsp; if (jj_scan_token(45)) { jj_scanpos = xsp; if (jj_scan_token(46)) { jj_scanpos = xsp; if (jj_scan_token(47)) { jj_scanpos = xsp; if (jj_scan_token(48)) return true; } } } } } return false; } static private boolean jj_3R_61() { if (jj_scan_token(LPAREN)) return true; if (jj_3R_33()) return true; return false; } static private boolean jj_3R_59() { Token xsp; xsp = jj_scanpos; if (jj_scan_token(31)) { jj_scanpos = xsp; if (jj_scan_token(32)) return true; } return false; } static private boolean jj_3R_60() { if (jj_scan_token(MINUS)) return true; if (jj_3R_58()) return true; return false; } static private boolean jj_3R_58() { Token xsp; xsp = jj_scanpos; if (jj_3R_60()) { jj_scanpos = xsp; if (jj_scan_token(26)) { jj_scanpos = xsp; if (jj_3_7()) { jj_scanpos = xsp; if (jj_3R_61()) { jj_scanpos = xsp; if (jj_3R_62()) return true; } } } } return false; } static private boolean jj_3_5() { if (jj_3R_19()) return true; return false; } static private boolean jj_3R_18() { Token xsp; xsp = jj_scanpos; if (jj_3_5()) { jj_scanpos = xsp; if (jj_3R_32()) return true; } return false; } static private boolean jj_initialized_once = false; /** Generated Token Manager. */ static public simplejavaTokenManager token_source; static JavaCharStream jj_input_stream; /** Current token. */ static public Token token; /** Next token. */ static public Token jj_nt; static private int jj_ntk; static private Token jj_scanpos, jj_lastpos; static private int jj_la; static private int jj_gen; static final private int[] jj_la1 = new int[39]; static private int[] jj_la1_0; static private int[] jj_la1_1; static { jj_la1_init_0(); jj_la1_init_1(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0xa030000,0xa030000,0x8020000,0x20000000,0xa020000,0x8020000,0x0,0x200000,0x0,0x8020000,0x0,0x0,0x42c0000,0x40c0000,0x8000000,0x8000000,0x0,0x0,0x8000000,0xc000000,0x4dec0000,0x9c00000,0x0,0x0,0x0,0x0,0x0,0x4dcc0000,0x50000000,0x50000000,0x80000000,0x80000000,0x44000000,0x9c00000,0x29d27400,0x29d06400,0x0,0x8000,0x28000000,}; } private static void jj_la1_init_1() { jj_la1_1 = new int[] {0x0,0x0,0x0,0x8,0x0,0x0,0x20,0x0,0x100,0x0,0x20,0x100,0x0,0x0,0x0,0x0,0x80,0x80,0x0,0x0,0x1002,0x0,0x40000,0x20000,0x1000,0x1ea00,0x1ea00,0x2,0x0,0x0,0x1,0x1,0x0,0x2,0x8,0x8,0x400,0x0,0x0,}; } static final private JJCalls[] jj_2_rtns = new JJCalls[15]; static private boolean jj_rescan = false; static private int jj_gc = 0; /** Constructor with InputStream. */ public simplejava(java.io.InputStream stream) { this(stream, null); } /** Constructor with InputStream and supplied encoding */ public simplejava(java.io.InputStream stream, String encoding) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. "); System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; try { jj_input_stream = new JavaCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new simplejavaTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ static public void ReInit(java.io.InputStream stream) { ReInit(stream, null); } /** Reinitialise. */ static public void ReInit(java.io.InputStream stream, String encoding) { try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor. */ public simplejava(java.io.Reader stream) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. "); System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; jj_input_stream = new JavaCharStream(stream, 1, 1); token_source = new simplejavaTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ static public void ReInit(java.io.Reader stream) { jj_input_stream.ReInit(stream, 1, 1); token_source.ReInit(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor with generated Token Manager. */ public simplejava(simplejavaTokenManager tm) { if (jj_initialized_once) { System.out.println("ERROR: Second call to constructor of static parser. "); System.out.println(" You must either use ReInit() or set the JavaCC option STATIC to false"); System.out.println(" during parser generation."); throw new Error(); } jj_initialized_once = true; token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Reinitialise. */ public void ReInit(simplejavaTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 39; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } static private Token jj_consume_token(int kind) throws ParseException { Token oldToken; if ((oldToken = token).next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; if (token.kind == kind) { jj_gen++; if (++jj_gc > 100) { jj_gc = 0; for (int i = 0; i < jj_2_rtns.length; i++) { JJCalls c = jj_2_rtns[i]; while (c != null) { if (c.gen < jj_gen) c.first = null; c = c.next; } } } trace_token(token, ""); return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } static private final class LookaheadSuccess extends java.lang.Error { } static final private LookaheadSuccess jj_ls = new LookaheadSuccess(); static private boolean jj_scan_token(int kind) { if (jj_scanpos == jj_lastpos) { jj_la--; if (jj_scanpos.next == null) { jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken(); } else { jj_lastpos = jj_scanpos = jj_scanpos.next; } } else { jj_scanpos = jj_scanpos.next; } if (jj_rescan) { int i = 0; Token tok = token; while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; } if (tok != null) jj_add_error_token(kind, i); } if (jj_scanpos.kind != kind) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls; return false; } /** Get the next Token. */ static final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; trace_token(token, " (in getNextToken)"); return token; } /** Get the specific Token. */ static final public Token getToken(int index) { Token t = token; for (int i = 0; i < index; i++) { if (t.next != null) t = t.next; else t = t.next = token_source.getNextToken(); } return t; } static private int jj_ntk() { if ((jj_nt=token.next) == null) return (jj_ntk = (token.next=token_source.getNextToken()).kind); else return (jj_ntk = jj_nt.kind); } static private java.util.List jj_expentries = new java.util.ArrayList(); static private int[] jj_expentry; static private int jj_kind = -1; static private int[] jj_lasttokens = new int[100]; static private int jj_endpos; static private void jj_add_error_token(int kind, int pos) { if (pos >= 100) return; if (pos == jj_endpos + 1) { jj_lasttokens[jj_endpos++] = kind; } else if (jj_endpos != 0) { jj_expentry = new int[jj_endpos]; for (int i = 0; i < jj_endpos; i++) { jj_expentry[i] = jj_lasttokens[i]; } jj_entries_loop: for (java.util.Iterator it = jj_expentries.iterator(); it.hasNext();) { int[] oldentry = (int[])(it.next()); if (oldentry.length == jj_expentry.length) { for (int i = 0; i < jj_expentry.length; i++) { if (oldentry[i] != jj_expentry[i]) { continue jj_entries_loop; } } jj_expentries.add(jj_expentry); break jj_entries_loop; } } if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind; } } /** Generate ParseException. */ static public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[52]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 39; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<" + where); } } static private void trace_scan(Token t1, int t2) { if (trace_enabled) { for (int i = 0; i < trace_indent; i++) { System.out.print(" "); } System.out.print("Visited token: <" + tokenImage[t1.kind]); if (t1.kind != 0 && !tokenImage[t1.kind].equals("\"" + t1.image + "\"")) { System.out.print(": \"" + t1.image + "\""); } System.out.println(" at line " + t1.beginLine + " column " + t1.beginColumn + ">; Expected token: <" + tokenImage[t2] + ">"); } } static private void jj_rescan_token() { jj_rescan = true; for (int i = 0; i < 15; i++) { try { JJCalls p = jj_2_rtns[i]; do { if (p.gen > jj_gen) { jj_la = p.arg; jj_lastpos = jj_scanpos = p.first; switch (i) { case 0: jj_3_1(); break; case 1: jj_3_2(); break; case 2: jj_3_3(); break; case 3: jj_3_4(); break; case 4: jj_3_5(); break; case 5: jj_3_6(); break; case 6: jj_3_7(); break; case 7: jj_3_8(); break; case 8: jj_3_9(); break; case 9: jj_3_10(); break; case 10: jj_3_11(); break; case 11: jj_3_12(); break; case 12: jj_3_13(); break; case 13: jj_3_14(); break; case 14: jj_3_15(); break; } } p = p.next; } while (p != null); } catch(LookaheadSuccess ls) { } } jj_rescan = false; } static private void jj_save(int index, int xla) { JJCalls p = jj_2_rtns[index]; while (p.gen > jj_gen) { if (p.next == null) { p = p.next = new JJCalls(); break; } p = p.next; } p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla; } static final class JJCalls { int gen; Token first; int arg; JJCalls next; } }