/* 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.lib.*; import edu.neu.ccs.demeterf.*; import java.lang.Integer; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import java.lang.Integer; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import java.lang.Integer; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import java.lang.Integer; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import java.lang.Integer; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import java.lang.Integer; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import java.lang.Integer; import edu.neu.ccs.demeterf.Fields; import edu.neu.ccs.demeterf.lib.ident; import edu.neu.ccs.demeterf.lib.verbatim; public 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; 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[0] = jj_gen; 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 Playground parse_Playground() throws ParseException { Domain d; Claim c; jj_consume_token(1); d = parse_Domain(); c = parse_Claim(); {if (true) return new Playground(d,c);} throw new Error("Missing return statement in function"); } final public Test3 parse_Test3() throws ParseException { Instance i; Solution s; Domain d; Claim c; Playground playground; i = parse_Instance(); s = parse_Solution(); d = parse_Domain(); c = parse_Claim(); playground = parse_Playground(); jj_consume_token(0); {if (true) return new Test3(i,s,d,c,playground);} throw new Error("Missing return statement in function"); } final public InstanceSet parse_InstanceSet() throws ParseException { jj_consume_token(2); {if (true) return new InstanceSet();} throw new Error("Missing return statement in function"); } final public Claim parse_Claim() throws ParseException { InstanceSet is; Protocol p; jj_consume_token(3); is = parse_InstanceSet(); p = parse_Protocol(); {if (true) return new Claim(is,p);} throw new Error("Missing return statement in function"); } final public Protocol parse_Protocol() throws ParseException { State state; jj_consume_token(4); state = parse_State(); {if (true) return new Protocol(state);} throw new Error("Missing return statement in function"); } final public State parse_State() throws ParseException { State sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 7: sup = parse_Start(); {if (true) return sup;} break; case 8: sup = parse_End(); {if (true) return sup;} break; case 5: sup = parse_InstanceProvided(); {if (true) return sup;} break; case 6: sup = parse_InstanceSolved(); {if (true) return sup;} break; default: jj_la1[1] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public InstanceProvided parse_InstanceProvided() throws ParseException { jj_consume_token(5); {if (true) return new InstanceProvided();} throw new Error("Missing return statement in function"); } final public InstanceSolved parse_InstanceSolved() throws ParseException { jj_consume_token(6); {if (true) return new InstanceSolved();} throw new Error("Missing return statement in function"); } final public Start parse_Start() throws ParseException { jj_consume_token(7); {if (true) return new Start();} throw new Error("Missing return statement in function"); } final public End parse_End() throws ParseException { jj_consume_token(8); {if (true) return new End();} throw new Error("Missing return statement in function"); } final public PlayerProxy parse_PlayerProxy() throws ParseException { {if (true) return new PlayerProxy();} throw new Error("Missing return statement in function"); } final public EP parse_EP() throws ParseException { Expectation e; PlayerProxy p; boolean ok; e = parse_Expectation(); p = parse_PlayerProxy(); ok = parse_boolean(); {if (true) return new EP(e,p,ok);} throw new Error("Missing return statement in function"); } final public Expectation parse_Expectation() throws ParseException { {if (true) return new Expectation();} throw new Error("Missing return statement in function"); } final public Transaction parse_Transaction() throws ParseException { {if (true) return new Transaction();} throw new Error("Missing return statement in function"); } final public ClaimInterface parse_ClaimInterface() throws ParseException { ClaimInterface sup = null; {if (true) return sup;} throw new Error("Missing return statement in function"); } final public ProtocolInterface parse_ProtocolInterface() throws ParseException { ProtocolInterface sup = null; {if (true) return sup;} throw new Error("Missing return statement in function"); } final public Test2 parse_Test2() throws ParseException { Instance i; Solution s; Domain d; Claim c; i = parse_Instance(); s = parse_Solution(); d = parse_Domain(); c = parse_Claim(); jj_consume_token(0); {if (true) return new Test2(i,s,d,c);} throw new Error("Missing return statement in function"); } final public Instance parse_Instance() throws ParseException { jj_consume_token(9); {if (true) return new Instance();} throw new Error("Missing return statement in function"); } final public Solution parse_Solution() throws ParseException { jj_consume_token(10); {if (true) return new Solution();} throw new Error("Missing return statement in function"); } final public Domain parse_Domain() throws ParseException { jj_consume_token(11); {if (true) return new Domain();} throw new Error("Missing return statement in function"); } final public DomainInterface parse_DomainInterface() throws ParseException { DomainInterface sup = null; {if (true) return sup;} throw new Error("Missing return statement in function"); } final public Test1 parse_Test1() throws ParseException { Instance i; Solution s; Domain d; i = parse_Instance(); s = parse_Solution(); d = parse_Domain(); jj_consume_token(0); {if (true) return new Test1(i,s,d);} throw new Error("Missing return statement in function"); } final public RBColor parse_RBColor() throws ParseException { RBColor sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 12: sup = parse_RED(); {if (true) return sup;} break; case 13: sup = parse_BLACK(); {if (true) return sup;} break; default: jj_la1[2] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public RED parse_RED() throws ParseException { jj_consume_token(12); {if (true) return new RED();} throw new Error("Missing return statement in function"); } final public BLACK parse_BLACK() throws ParseException { jj_consume_token(13); {if (true) return new BLACK();} throw new Error("Missing return statement in function"); } /** 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 int jj_gen; final private int[] jj_la1 = new int[3]; static private int[] jj_la1_0; static { jj_la1_init_0(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x3000000,0x1e0,0x3000,}; } /** 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 < 3; i++) jj_la1[i] = -1; } /** 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 < 3; i++) jj_la1[i] = -1; } /** 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 < 3; i++) jj_la1[i] = -1; } /** 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 < 3; i++) jj_la1[i] = -1; } /** 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 < 3; i++) jj_la1[i] = -1; } /** Reinitialise. */ public void ReInit(TheParserTokenManager tm) { token_source = tm; token = new Token(); jj_ntk = -1; jj_gen = 0; for (int i = 0; i < 3; i++) jj_la1[i] = -1; } 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(); } /** 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; /** Generate ParseException. */ public ParseException generateParseException() { jj_expentries.clear(); boolean[] la1tokens = new boolean[30]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 3; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<