/* Generated By:JavaCC: Do not edit this line. TheParser.java */ package gen; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.control.Fields; import edu.neu.ccs.demeterf.lib.ident; import edu.neu.ccs.demeterf.lib.verbatim; class TheParser implements TheParserConstants { public static String unescape(String str){ String retval = ""; int index = 0; char ch, ch1; int ordinal = 0; while (index < str.length()) { if(str.charAt(index) != '\\') { retval += str.charAt(index++); continue; } ch = str.charAt(++index); if(ch == 'b') { retval += '\b'; index++; continue; } if(ch == 't') { retval += '\t'; index++; continue; } if(ch == 'n') { retval += '\n'; index++; continue; } if(ch == 'f') { retval += '\f'; index++; continue; } if(ch == 'r') { retval += '\r'; index++; continue; } if(ch == '"') { retval += '\"'; index++; continue; } if(ch == '\'') { retval += '\''; index++; continue; } if(ch == '\\') { retval += '\\'; index++; continue; } if(ch >= '0' && ch <= '7'){ ordinal = ((int)ch) - ((int)'0'); index++; ch1 = str.charAt(index); if(ch1 >= '0' && ch1 <= '7'){ ordinal = ordinal*8 + ((int)ch1) - ((int)'0'); index++; ch1 = str.charAt(index); if(ch <= '3' && ch1 >= '0' && ch1 <= '7'){ ordinal = ordinal*8 + ((int)ch1) - ((int)'0'); index++; } } retval += (char)ordinal; continue; } if(ch == 'u'){ ordinal = 0; for(int i = 0; i < 4; i++){ index++; ch = str.charAt(index); ordinal = ordinal*16+hexval(ch); } index++; retval += (char)ordinal; continue; } } return retval; } static int hexval(char c){ int r = "0123456789ABCDEF".indexOf(Character.toUpperCase(c)); if(r >= 0)return r; throw new RuntimeException(" ** Bad Escaped Character"); } final public byte parse_byte() throws ParseException { int i; i = parse_int(); {if (true) return (byte)i;} throw new Error("Missing return statement in function"); } final public Byte parse_Byte() throws ParseException { byte b; b = parse_byte(); {if (true) return b;} throw new Error("Missing return statement in function"); } final public short parse_short() throws ParseException { int i; i = parse_int(); {if (true) return (short)i;} throw new Error("Missing return statement in function"); } final public Short parse_Short() throws ParseException { short s; s = parse_short(); {if (true) return s;} throw new Error("Missing return statement in function"); } final public int parse_int() throws ParseException { Token t; t = jj_consume_token(INT); if(t.image.length() > 1 && Character.toLowerCase(t.image.charAt(1)) == 'x') {if (true) return Integer.parseInt(t.image.substring(2), 16);} {if (true) return Integer.parseInt(t.image);} throw new Error("Missing return statement in function"); } final public Integer parse_Integer() throws ParseException { int i; i = parse_int(); {if (true) return i;} throw new Error("Missing return statement in function"); } final public long parse_long() throws ParseException { Token t; t = jj_consume_token(INT); if(t.image.length() > 1 && Character.toLowerCase(t.image.charAt(1)) == 'x') {if (true) return Long.parseLong(t.image.substring(2), 16);} {if (true) return Long.parseLong(t.image);} throw new Error("Missing return statement in function"); } final public Long parse_Long() throws ParseException { long l; l = parse_long(); {if (true) return l;} throw new Error("Missing return statement in function"); } final public double parse_double() throws ParseException { Token t; t = jj_consume_token(DOUBLE); {if (true) return Double.parseDouble(t.image);} throw new Error("Missing return statement in function"); } final public Double parse_Double() throws ParseException { double d; d = parse_double(); {if (true) return d;} throw new Error("Missing return statement in function"); } final public float parse_float() throws ParseException { Token t; t = jj_consume_token(DOUBLE); {if (true) return Float.parseFloat(t.image);} throw new Error("Missing return statement in function"); } final public Float parse_Float() throws ParseException { float f; f = parse_float(); {if (true) return f;} throw new Error("Missing return statement in function"); } final public String parse_String() throws ParseException { Token t; t = jj_consume_token(STRING); {if (true) return unescape(t.image.substring(1,t.image.length()-1));} throw new Error("Missing return statement in function"); } final public boolean parse_boolean() throws ParseException { Token t; if (jj_2_1(2)) { t = jj_consume_token(TRUE); {if (true) return true;} } else if (jj_2_2(2)) { t = jj_consume_token(FALSE); {if (true) return false;} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public Boolean parse_Boolean() throws ParseException { boolean b; b = parse_boolean(); {if (true) return b;} throw new Error("Missing return statement in function"); } final public char parse_char() throws ParseException { Token t; t = jj_consume_token(CHAR); {if (true) return unescape(t.image.substring(1,t.image.length()-1)).charAt(0);} throw new Error("Missing return statement in function"); } final public Character parse_Character() throws ParseException { char c; c = parse_char(); {if (true) return c;} throw new Error("Missing return statement in function"); } final public ident parse_ident() throws ParseException { Token t; t = jj_consume_token(IDENT); {if (true) return new ident(t.image);} throw new Error("Missing return statement in function"); } final public verbatim parse_verbatim() throws ParseException { Token t; t = jj_consume_token(TEXT); {if (true) return new verbatim(t.image.substring(2,t.image.length()-2));} throw new Error("Missing return statement in function"); } final public Exp parse_Exp() throws ParseException { Exp sup = null; if (jj_2_3(2)) { sup = parse_Ifz(); {if (true) return sup;} } else if (jj_2_4(2)) { sup = parse_Def(); {if (true) return sup;} } else if (jj_2_5(2)) { sup = parse_Bin(); {if (true) return sup;} } else if (jj_2_6(2)) { sup = parse_Var(); {if (true) return sup;} } else if (jj_2_7(2)) { sup = parse_Num(); {if (true) return sup;} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public Ifz parse_Ifz() throws ParseException { Exp cnd; Exp thn; Exp els; jj_consume_token(1); cnd = parse_Exp(); jj_consume_token(2); thn = parse_Exp(); jj_consume_token(3); els = parse_Exp(); {if (true) return new Ifz(cnd,thn,els);} throw new Error("Missing return statement in function"); } final public Def parse_Def() throws ParseException { ident id; Exp e; Exp body; id = parse_ident(); jj_consume_token(4); e = parse_Exp(); jj_consume_token(5); body = parse_Exp(); {if (true) return new Def(id,e,body);} throw new Error("Missing return statement in function"); } final public Bin parse_Bin() throws ParseException { Oper op; Exp left; Exp right; jj_consume_token(6); op = parse_Oper(); left = parse_Exp(); right = parse_Exp(); jj_consume_token(7); {if (true) return new Bin(op,left,right);} throw new Error("Missing return statement in function"); } final public Var parse_Var() throws ParseException { ident id; id = parse_ident(); {if (true) return new Var(id);} throw new Error("Missing return statement in function"); } final public Num parse_Num() throws ParseException { int val; val = parse_int(); {if (true) return new Num(val);} throw new Error("Missing return statement in function"); } final public Oper parse_Oper() throws ParseException { Oper sup = null; sup = parse_Sub(); {if (true) return sup;} throw new Error("Missing return statement in function"); } final public Sub parse_Sub() throws ParseException { jj_consume_token(8); {if (true) return new Sub();} throw new Error("Missing return statement in function"); } final public Env parse_Env() throws ParseException { Env sup = null; if (jj_2_8(2)) { sup = parse_ExtEnv(); {if (true) return sup;} } else { sup = parse_EmptyEnv(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public ExtEnv parse_ExtEnv() throws ParseException { ident id; int v; Env rest; id = parse_ident(); jj_consume_token(4); v = parse_int(); jj_consume_token(5); rest = parse_Env(); {if (true) return new ExtEnv(id,v,rest);} throw new Error("Missing return statement in function"); } final public EmptyEnv parse_EmptyEnv() throws ParseException { {if (true) return new EmptyEnv();} throw new Error("Missing return statement in function"); } final public error parse_error() throws ParseException { {if (true) return new error();} throw new Error("Missing return statement in function"); } final public Op parse_Op() throws ParseException { Op sup = null; if (jj_2_9(2)) { sup = parse_MathOp(); {if (true) return sup;} } else if (jj_2_10(2)) { sup = parse_StkOp(); {if (true) return sup;} } else if (jj_2_11(2)) { sup = parse_CtrlOp(); {if (true) return sup;} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public MathOp parse_MathOp() throws ParseException { MathOp sup = null; sup = parse_Minus(); {if (true) return sup;} throw new Error("Missing return statement in function"); } final public StkOp parse_StkOp() throws ParseException { StkOp sup = null; if (jj_2_12(2)) { sup = parse_Push(); {if (true) return sup;} } else if (jj_2_13(2)) { sup = parse_Pop(); {if (true) return sup;} } else if (jj_2_14(2)) { sup = parse_Define(); {if (true) return sup;} } else if (jj_2_15(2)) { sup = parse_Undef(); {if (true) return sup;} } else if (jj_2_16(2)) { sup = parse_Load(); {if (true) return sup;} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public CtrlOp parse_CtrlOp() throws ParseException { CtrlOp sup = null; if (jj_2_17(2)) { sup = parse_Label(); {if (true) return sup;} } else if (jj_2_18(2)) { sup = parse_Jmp(); {if (true) return sup;} } else if (jj_2_19(2)) { sup = parse_IfNZ(); {if (true) return sup;} } else { jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public Minus parse_Minus() throws ParseException { jj_consume_token(9); {if (true) return new Minus();} throw new Error("Missing return statement in function"); } final public Push parse_Push() throws ParseException { int i; jj_consume_token(10); i = parse_int(); {if (true) return new Push(i);} throw new Error("Missing return statement in function"); } final public Pop parse_Pop() throws ParseException { jj_consume_token(11); {if (true) return new Pop();} throw new Error("Missing return statement in function"); } final public Define parse_Define() throws ParseException { jj_consume_token(12); {if (true) return new Define();} throw new Error("Missing return statement in function"); } final public Undef parse_Undef() throws ParseException { jj_consume_token(13); {if (true) return new Undef();} throw new Error("Missing return statement in function"); } final public Load parse_Load() throws ParseException { int i; jj_consume_token(14); i = parse_int(); {if (true) return new Load(i);} throw new Error("Missing return statement in function"); } final public Label parse_Label() throws ParseException { ident id; jj_consume_token(15); id = parse_ident(); {if (true) return new Label(id);} throw new Error("Missing return statement in function"); } final public Jmp parse_Jmp() throws ParseException { ident id; jj_consume_token(16); id = parse_ident(); {if (true) return new Jmp(id);} throw new Error("Missing return statement in function"); } final public IfNZ parse_IfNZ() throws ParseException { ident id; jj_consume_token(17); id = parse_ident(); {if (true) return new IfNZ(id);} throw new Error("Missing return statement in function"); } final public OpList parse_OpList() throws ParseException { OpList sup = null; if (jj_2_20(2)) { sup = parse_OpCons(); {if (true) return sup;} } else { sup = parse_OpEmpty(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public OpCons parse_OpCons() throws ParseException { Op first; OpList rest; first = parse_Op(); rest = parse_OpList(); {if (true) return new OpCons(first,rest);} throw new Error("Missing return statement in function"); } final public OpEmpty parse_OpEmpty() throws ParseException { {if (true) return new OpEmpty();} throw new Error("Missing return statement in function"); } final public ExecStack parse_ExecStack() throws ParseException { {if (true) return new ExecStack();} throw new Error("Missing return statement in function"); } final public CodeEntry parse_CodeEntry() throws ParseException { String label; OpList pc; label = parse_String(); pc = parse_OpList(); {if (true) return new CodeEntry(label,pc);} throw new Error("Missing return statement in function"); } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } 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); } } private boolean jj_2_16(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_16(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(15, xla); } } private boolean jj_2_17(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_17(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(16, xla); } } private boolean jj_2_18(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_18(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(17, xla); } } private boolean jj_2_19(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_19(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(18, xla); } } private boolean jj_2_20(int xla) { jj_la = xla; jj_lastpos = jj_scanpos = token; try { return !jj_3_20(); } catch(LookaheadSuccess ls) { return true; } finally { jj_save(19, xla); } } private boolean jj_3_19() { if (jj_3R_17()) return true; return false; } private boolean jj_3R_3() { if (jj_scan_token(6)) return true; if (jj_3R_21()) return true; return false; } private boolean jj_3_18() { if (jj_3R_16()) return true; return false; } private boolean jj_3_17() { if (jj_3R_15()) return true; return false; } private boolean jj_3R_22() { if (jj_scan_token(INT)) return true; return false; } private boolean jj_3R_9() { Token xsp; xsp = jj_scanpos; if (jj_3_17()) { jj_scanpos = xsp; if (jj_3_18()) { jj_scanpos = xsp; if (jj_3_19()) return true; } } return false; } private boolean jj_3_16() { if (jj_3R_14()) return true; return false; } private boolean jj_3R_28() { return false; } private boolean jj_3_15() { if (jj_3R_13()) return true; return false; } private boolean jj_3_14() { if (jj_3R_12()) return true; return false; } private boolean jj_3_13() { if (jj_3R_11()) return true; return false; } private boolean jj_3_12() { if (jj_3R_10()) return true; return false; } private boolean jj_3R_2() { if (jj_3R_20()) return true; if (jj_scan_token(4)) return true; return false; } private boolean jj_3R_8() { Token xsp; xsp = jj_scanpos; if (jj_3_12()) { jj_scanpos = xsp; if (jj_3_13()) { jj_scanpos = xsp; if (jj_3_14()) { jj_scanpos = xsp; if (jj_3_15()) { jj_scanpos = xsp; if (jj_3_16()) return true; } } } } return false; } private boolean jj_3R_18() { if (jj_3R_24()) return true; if (jj_3R_25()) return true; return false; } private boolean jj_3R_7() { if (jj_3R_23()) return true; return false; } private boolean jj_3R_27() { if (jj_3R_28()) return true; return false; } private boolean jj_3_11() { if (jj_3R_9()) return true; return false; } private boolean jj_3_10() { if (jj_3R_8()) return true; return false; } private boolean jj_3_20() { if (jj_3R_18()) return true; return false; } private boolean jj_3_9() { if (jj_3R_7()) return true; return false; } private boolean jj_3R_1() { if (jj_scan_token(1)) return true; if (jj_3R_19()) return true; return false; } private boolean jj_3R_25() { Token xsp; xsp = jj_scanpos; if (jj_3_20()) { jj_scanpos = xsp; if (jj_3R_27()) return true; } return false; } private boolean jj_3R_24() { Token xsp; xsp = jj_scanpos; if (jj_3_9()) { jj_scanpos = xsp; if (jj_3_10()) { jj_scanpos = xsp; if (jj_3_11()) return true; } } return false; } private boolean jj_3R_17() { if (jj_scan_token(17)) return true; if (jj_3R_20()) return true; return false; } private boolean jj_3_7() { if (jj_3R_5()) return true; return false; } private boolean jj_3_6() { if (jj_3R_4()) return true; return false; } private boolean jj_3_5() { if (jj_3R_3()) return true; return false; } private boolean jj_3_4() { if (jj_3R_2()) return true; return false; } private boolean jj_3_3() { if (jj_3R_1()) return true; return false; } private boolean jj_3R_16() { if (jj_scan_token(16)) return true; if (jj_3R_20()) return true; return false; } private boolean jj_3R_19() { Token xsp; xsp = jj_scanpos; if (jj_3_3()) { jj_scanpos = xsp; if (jj_3_4()) { jj_scanpos = xsp; if (jj_3_5()) { jj_scanpos = xsp; if (jj_3_6()) { jj_scanpos = xsp; if (jj_3_7()) return true; } } } } return false; } private boolean jj_3R_15() { if (jj_scan_token(15)) return true; if (jj_3R_20()) return true; return false; } private boolean jj_3R_6() { if (jj_3R_20()) return true; if (jj_scan_token(4)) return true; return false; } private boolean jj_3R_20() { if (jj_scan_token(IDENT)) return true; return false; } private boolean jj_3R_14() { if (jj_scan_token(14)) return true; if (jj_3R_22()) return true; return false; } private boolean jj_3_8() { if (jj_3R_6()) return true; return false; } private boolean jj_3_2() { if (jj_scan_token(FALSE)) return true; return false; } private boolean jj_3R_13() { if (jj_scan_token(13)) return true; return false; } private boolean jj_3_1() { if (jj_scan_token(TRUE)) return true; return false; } private boolean jj_3R_26() { if (jj_scan_token(8)) return true; return false; } private boolean jj_3R_12() { if (jj_scan_token(12)) return true; return false; } private boolean jj_3R_21() { if (jj_3R_26()) return true; return false; } private boolean jj_3R_11() { if (jj_scan_token(11)) return true; return false; } private boolean jj_3R_5() { if (jj_3R_22()) return true; return false; } private boolean jj_3R_10() { if (jj_scan_token(10)) return true; if (jj_3R_22()) return true; return false; } private boolean jj_3R_4() { if (jj_3R_20()) return true; return false; } private boolean jj_3R_23() { if (jj_scan_token(9)) return true; return false; } /** Generated Token Manager. */ public TheParserTokenManager token_source; SimpleCharStream jj_input_stream; /** Current token. */ public Token token; /** Next token. */ public Token jj_nt; private int jj_ntk; private Token jj_scanpos, jj_lastpos; private int jj_la; private int jj_gen; final private int[] jj_la1 = new int[0]; 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[] {}; } private static void jj_la1_init_1() { jj_la1_1 = new int[] {}; } final private JJCalls[] jj_2_rtns = new JJCalls[20]; private boolean jj_rescan = false; private int jj_gc = 0; /** Constructor with InputStream. */ public TheParser(java.io.InputStream stream) { this(stream, null); } /** Constructor with InputStream and supplied encoding */ public TheParser(java.io.InputStream stream, String encoding) { try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); } token_source = new TheParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 0; 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(java.io.InputStream stream) { ReInit(stream, null); } /** Reinitialise. */ 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 < 0; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } /** Constructor. */ public TheParser(java.io.Reader stream) { jj_input_stream = new SimpleCharStream(stream, 1, 1); token_source = new TheParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 0; 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(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 < 0; 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 TheParser(TheParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 0; 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(TheParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 0; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); } 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; } } } return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } static private final class LookaheadSuccess extends java.lang.Error { } final private LookaheadSuccess jj_ls = new LookaheadSuccess(); 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. */ final public Token getNextToken() { if (token.next != null) token = token.next; else token = token.next = token_source.getNextToken(); jj_ntk = -1; jj_gen++; return token; } /** Get the specific Token. */ 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; } 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); } private java.util.List jj_expentries = new java.util.ArrayList(); private int[] jj_expentry; private int jj_kind = -1; private int[] jj_lasttokens = new int[100]; private int jj_endpos; 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. */ public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[34]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 0; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<<j)) != 0) { la1tokens[j] = true; } if ((jj_la1_1[i] & (1<<j)) != 0) { la1tokens[32+j] = true; } } } } for (int i = 0; i < 34; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i; jj_expentries.add(jj_expentry); } } jj_endpos = 0; jj_rescan_token(); jj_add_error_token(0, 0); int[][] exptokseq = new int[jj_expentries.size()][]; for (int i = 0; i < jj_expentries.size(); i++) { exptokseq[i] = (int[])jj_expentries.get(i); } return new ParseException(token, exptokseq, tokenImage); } /** Enable tracing. */ final public void enable_tracing() { } /** Disable tracing. */ final public void disable_tracing() { } private void jj_rescan_token() { jj_rescan = true; for (int i = 0; i < 20; 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; case 15: jj_3_16(); break; case 16: jj_3_17(); break; case 17: jj_3_18(); break; case 18: jj_3_19(); break; case 19: jj_3_20(); break; } } p = p.next; } while (p != null); } catch(LookaheadSuccess ls) { } } jj_rescan = false; } 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; } }