/* Generated By:JavaCC: Do not edit this line. Parser.java */ import edu.neu.ccs.demeterf.*; import edu.neu.ccs.demeterf.util.Util; import edu.neu.ccs.demeter.*; public class Parser implements ParserConstants { // oit is uugly. Why isn't there a Character.valueOf(String)? static char unescapifyChar(String s) { char c = s.charAt(0); if (c == '\\') { switch (s.charAt(1)) { case 'n': c = '\n'; break; case 't': c = '\t'; break; case 'b': c = '\b'; break; case 'r': c = '\r'; break; case 'f': c = '\f'; break; case '\\': c = '\\'; break; case '\'': c = '\''; break; case '\"': c = '\"'; break; default: c = (char) Integer.parseInt(s.substring(1, s.length()), 8); break; } } return c; } // Even uglier... static String unescapify(String s) { char str[] = new char[s.length()]; int i = 0, o = 0; while (i < s.length()) { char c = s.charAt(i++); if (c == '\\') { int j = i + 1; while (j < s.length() && Character.digit(s.charAt(j), 8) != -1) { j++; } c = unescapifyChar(s.substring(i-1, j)); i = j; } str[o++] = c; } return String.valueOf(str, 0, o); } final public Main _Main() throws ParseException { Main it = null; FuncDef _func; ClassDefList _cd; it=new Main(); _func = _FuncDef(); it.set_func(_func); _cd = _ClassDefList(); it.set_cd(_cd); {if (true) return it;} throw new Error("Missing return statement in function"); } final public FuncDef _FuncDef() throws ParseException { FuncDef it = null; MethodList _methodlist; it=new FuncDef(); jj_consume_token(1); jj_consume_token(2); _methodlist = _MethodList(); it.set_methodlist(_methodlist); jj_consume_token(3); {if (true) return it;} throw new Error("Missing return statement in function"); } final public MethodDef _MethodDef() throws ParseException { MethodDef it = null; TypeName _ret; TypeName _arg; it=new MethodDef(); _ret = _TypeName(); it.set_ret(_ret); jj_consume_token(4); jj_consume_token(5); _arg = _TypeName(); it.set_arg(_arg); jj_consume_token(6); {if (true) return it;} throw new Error("Missing return statement in function"); } final public MethodList _MethodList() throws ParseException { MethodList it = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: it = _MethodCons(); break; default: jj_la1[0] = jj_gen; it = _MethodEmpty(); } {if (true) return it;} throw new Error("Missing return statement in function"); } final public void common_MethodList(MethodList it) throws ParseException { } final public MethodCons _MethodCons() throws ParseException { MethodCons it = null; MethodDef _first; MethodList _rest; it=new MethodCons(); _first = _MethodDef(); it.set_first(_first); jj_consume_token(7); _rest = _MethodList(); it.set_rest(_rest); common_MethodList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public MethodEmpty _MethodEmpty() throws ParseException { MethodEmpty it = null; it=new MethodEmpty(); common_MethodList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public ClassDef _ClassDef() throws ParseException { ClassDef it = null; Ident _name; Decl _decl; it=new ClassDef(); _name = _Ident(); it.set_name(_name); _decl = _Decl(); it.set_decl(_decl); jj_consume_token(8); {if (true) return it;} throw new Error("Missing return statement in function"); } final public Decl _Decl() throws ParseException { Decl it = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 9: it = _Abstract(); break; case 10: it = _Concrete(); break; default: jj_la1[1] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return it;} throw new Error("Missing return statement in function"); } final public void common_Decl(Decl it) throws ParseException { } final public Abstract _Abstract() throws ParseException { Abstract it = null; NESubtypeList _subtypes; it=new Abstract(); jj_consume_token(9); _subtypes = _NESubtypeList(); it.set_subtypes(_subtypes); common_Decl(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public Concrete _Concrete() throws ParseException { Concrete it = null; FieldList _fields; it=new Concrete(); jj_consume_token(10); _fields = _FieldList(); it.set_fields(_fields); common_Decl(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public Field _Field() throws ParseException { Field it = null; Ident _name; TypeName _typename; it=new Field(); jj_consume_token(11); _name = _Ident(); it.set_name(_name); jj_consume_token(12); _typename = _TypeName(); it.set_typename(_typename); {if (true) return it;} throw new Error("Missing return statement in function"); } final public TypeName _TypeName() throws ParseException { TypeName it = null; Ident _name; it=new TypeName(); _name = _Ident(); it.set_name(_name); {if (true) return it;} throw new Error("Missing return statement in function"); } final public ClassDefList _ClassDefList() throws ParseException { ClassDefList it = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: it = _ClassDefCons(); break; default: jj_la1[2] = jj_gen; it = _ClassDefEmpty(); } {if (true) return it;} throw new Error("Missing return statement in function"); } final public void common_ClassDefList(ClassDefList it) throws ParseException { } final public ClassDefCons _ClassDefCons() throws ParseException { ClassDefCons it = null; ClassDef _first; ClassDefList _rest; it=new ClassDefCons(); _first = _ClassDef(); it.set_first(_first); _rest = _ClassDefList(); it.set_rest(_rest); common_ClassDefList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public ClassDefEmpty _ClassDefEmpty() throws ParseException { ClassDefEmpty it = null; it=new ClassDefEmpty(); common_ClassDefList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public FieldList _FieldList() throws ParseException { FieldList it = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 11: it = _FieldCons(); break; default: jj_la1[3] = jj_gen; it = _FieldEmpty(); } {if (true) return it;} throw new Error("Missing return statement in function"); } final public void common_FieldList(FieldList it) throws ParseException { } final public FieldCons _FieldCons() throws ParseException { FieldCons it = null; Field _first; FieldList _rest; it=new FieldCons(); _first = _Field(); it.set_first(_first); _rest = _FieldList(); it.set_rest(_rest); common_FieldList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public FieldEmpty _FieldEmpty() throws ParseException { FieldEmpty it = null; it=new FieldEmpty(); common_FieldList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public NESubtypeList _NESubtypeList() throws ParseException { NESubtypeList it = null; TypeName _first; SubtypeList _rest; it=new NESubtypeList(); _first = _TypeName(); it.set_first(_first); _rest = _SubtypeList(); it.set_rest(_rest); {if (true) return it;} throw new Error("Missing return statement in function"); } final public SubtypeList _SubtypeList() throws ParseException { SubtypeList it = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 13: it = _SubtypeCons(); break; default: jj_la1[4] = jj_gen; it = _SubtypeEmpty(); } {if (true) return it;} throw new Error("Missing return statement in function"); } final public void common_SubtypeList(SubtypeList it) throws ParseException { } final public SubtypeCons _SubtypeCons() throws ParseException { SubtypeCons it = null; TypeName _first; SubtypeList _rest; it=new SubtypeCons(); jj_consume_token(13); _first = _TypeName(); it.set_first(_first); _rest = _SubtypeList(); it.set_rest(_rest); common_SubtypeList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public SubtypeEmpty _SubtypeEmpty() throws ParseException { SubtypeEmpty it = null; it=new SubtypeEmpty(); common_SubtypeList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public StringList _StringList() throws ParseException { StringList it = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING_LITERAL: it = _StringCons(); break; default: jj_la1[5] = jj_gen; it = _StringEmpty(); } {if (true) return it;} throw new Error("Missing return statement in function"); } final public void common_StringList(StringList it) throws ParseException { } final public StringCons _StringCons() throws ParseException { StringCons it = null; String _first; StringList _rest; it=new StringCons(); _first = _String(); it.set_first(_first); _rest = _StringList(); it.set_rest(_rest); common_StringList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public StringEmpty _StringEmpty() throws ParseException { StringEmpty it = null; it=new StringEmpty(); common_StringList(it); {if (true) return it;} throw new Error("Missing return statement in function"); } final public boolean _boolean() throws ParseException { Token t; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: t = jj_consume_token(TRUE); {if (true) return true;} break; case FALSE: t = jj_consume_token(FALSE); {if (true) return false;} break; default: jj_la1[6] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public char _char() throws ParseException { Token t; t = jj_consume_token(CHARACTER_LITERAL); String s = t.image; {if (true) return unescapifyChar(s.substring(1, s.length()-1));} throw new Error("Missing return statement in function"); } final public byte _byte() throws ParseException { int i; i = _int(); {if (true) return (byte) i;} throw new Error("Missing return statement in function"); } final public short _short() throws ParseException { int i; i = _int(); {if (true) return (short) i;} throw new Error("Missing return statement in function"); } final public int _int() throws ParseException { Number num; num = _Number(); {if (true) return num.intValue();} throw new Error("Missing return statement in function"); } final public long _long() throws ParseException { Number num; num = _Number(); {if (true) return num.longValue();} throw new Error("Missing return statement in function"); } final public float _float() throws ParseException { Number num; num = _Number(); {if (true) return num.floatValue();} throw new Error("Missing return statement in function"); } final public double _double() throws ParseException { Number num; num = _Number(); {if (true) return num.doubleValue();} throw new Error("Missing return statement in function"); } final public Boolean _Boolean() throws ParseException { Token t; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: t = jj_consume_token(TRUE); {if (true) return Boolean.TRUE;} break; case FALSE: t = jj_consume_token(FALSE); {if (true) return Boolean.FALSE;} break; default: jj_la1[7] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public Character _Character() throws ParseException { char c; c = _char(); {if (true) return new Character(c);} throw new Error("Missing return statement in function"); } final public Integer _Integer() throws ParseException { int i; i = _int(); {if (true) return new Integer(i);} throw new Error("Missing return statement in function"); } final public Long _Long() throws ParseException { long l; l = _long(); {if (true) return new Long(l);} throw new Error("Missing return statement in function"); } final public Float _Float() throws ParseException { float f; f = _float(); {if (true) return new Float(f);} throw new Error("Missing return statement in function"); } final public Double _Double() throws ParseException { double d; d = _double(); {if (true) return new Double(d);} throw new Error("Missing return statement in function"); } final public Number _Number() throws ParseException { Token t; String s = null; int radix = 0; Number num = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DECIMAL_LITERAL: case HEX_LITERAL: case OCTAL_LITERAL: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DECIMAL_LITERAL: t = jj_consume_token(DECIMAL_LITERAL); s = t.image; radix = 10; break; case HEX_LITERAL: t = jj_consume_token(HEX_LITERAL); // Strip off the "0x". s = t.image.substring(2, t.image.length()); radix = 16; break; case OCTAL_LITERAL: t = jj_consume_token(OCTAL_LITERAL); s = t.image; radix = 8; break; default: jj_la1[8] = jj_gen; jj_consume_token(-1); throw new ParseException(); } switch (s.charAt(s.length()-1)) { case 'l': case 'L': s = s.substring(0, s.length()-1); num = new Long(new java.math.BigInteger(s, radix).longValue()); break; default: num = new Integer(new java.math.BigInteger(s, radix).intValue()); break; } break; case FLOATING_POINT_LITERAL: t = jj_consume_token(FLOATING_POINT_LITERAL); s = t.image; switch (s.charAt(s.length()-1)) { case 'd': case 'D': num = Double.valueOf(s.substring(0, s.length()-1)); break; case 'f': case 'F': num = Float.valueOf(s.substring(0, s.length()-1)); break; default: num = Float.valueOf(s); break; } break; default: jj_la1[9] = jj_gen; jj_consume_token(-1); throw new ParseException(); } {if (true) return num;} throw new Error("Missing return statement in function"); } final public String _String() throws ParseException { Token t; t = jj_consume_token(STRING_LITERAL); String s = t.image; {if (true) return unescapify(s.substring(1, s.length()-1));} throw new Error("Missing return statement in function"); } final public StringBuffer _StringBuffer() throws ParseException { String s; s = _String(); {if (true) return new StringBuffer(s);} throw new Error("Missing return statement in function"); } final public Ident _Ident() throws ParseException { Token t; t = jj_consume_token(IDENTIFIER); {if (true) return new Ident(t.image);} throw new Error("Missing return statement in function"); } final public Text _Text() throws ParseException { Token t; t = jj_consume_token(TEXT_LITERAL); String s = t.image; {if (true) return new Text(s.substring(2, s.length()-2));} throw new Error("Missing return statement in function"); } final public Line _Line() throws ParseException { Token t; token_source.SwitchTo(1); t = jj_consume_token(LINE); {if (true) return new Line(t.image);} throw new Error("Missing return statement in function"); } final public Word _Word() throws ParseException { Token t; token_source.SwitchTo(2); t = jj_consume_token(WORD); {if (true) return new Word(t.image);} throw new Error("Missing return statement in function"); } public ParserTokenManager token_source; ASCII_UCodeESC_CharStream jj_input_stream; public Token token, jj_nt; private int jj_ntk; private int jj_gen; final private int[] jj_la1 = new int[10]; final private int[] jj_la1_0 = {0x40000000,0x600,0x40000000,0x800,0x2000,0x4000000,0x30000000,0x30000000,0x700000,0xf00000,}; final private int[] jj_la1_1 = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; public Parser(java.io.InputStream stream) { jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1); token_source = new ParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 10; i++) jj_la1[i] = -1; } public void ReInit(java.io.InputStream 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 < 10; i++) jj_la1[i] = -1; } public Parser(java.io.Reader stream) { jj_input_stream = new ASCII_UCodeESC_CharStream(stream, 1, 1); token_source = new ParserTokenManager(jj_input_stream); token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 10; i++) jj_la1[i] = -1; } 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 < 10; i++) jj_la1[i] = -1; } public Parser(ParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 10; i++) jj_la1[i] = -1; } public void ReInit(ParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 10; i++) jj_la1[i] = -1; } final 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++; return token; } token = oldToken; jj_kind = kind; throw generateParseException(); } 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; } 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; } final 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.Vector jj_expentries = new java.util.Vector(); private int[] jj_expentry; private int jj_kind = -1; final public ParseException generateParseException() { jj_expentries.removeAllElements(); boolean[] la1tokens = new boolean[39]; for (int i = 0; i < 39; i++) { la1tokens[i] = false; } if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 10; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<