/* 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 Expectation2 parse_Expectation2() throws ParseException { Expectation2 sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: sup = parse_ProposeClaimExpectation(); {if (true) return sup;} break; case 2: sup = parse_OpposeOrAgreeClaimExpectation(); {if (true) return sup;} break; case 3: sup = parse_ProvideInstanceExpectation(); {if (true) return sup;} break; case 4: sup = parse_ProvideSolutionExpectation(); {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 Reply parse_Reply() throws ParseException { Reply sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 5: sup = parse_ClaimReply(); {if (true) return sup;} break; case 6: case 7: case 8: sup = parse_OpposeOrAgreeReply(); {if (true) return sup;} break; case 3: sup = parse_InstanceReply(); {if (true) return sup;} break; case 4: sup = parse_SolutionReply(); {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 OpposeOrAgreeReply parse_OpposeOrAgreeReply() throws ParseException { OpposeOrAgreeReply sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 6: sup = parse_RefuteReply(); {if (true) return sup;} break; case 7: sup = parse_StrengthenReply(); {if (true) return sup;} break; case 8: sup = parse_AgreeReply(); {if (true) return sup;} break; default: jj_la1[3] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } final public ProposeClaimExpectation parse_ProposeClaimExpectation() throws ParseException { List forbidden; jj_consume_token(1); forbidden = parse_List$Claim$(); {if (true) return new ProposeClaimExpectation(forbidden);} throw new Error("Missing return statement in function"); } final public OpposeOrAgreeClaimExpectation parse_OpposeOrAgreeClaimExpectation() throws ParseException { List claims; jj_consume_token(2); claims = parse_List$Claim$(); {if (true) return new OpposeOrAgreeClaimExpectation(claims);} throw new Error("Missing return statement in function"); } final public ProvideInstanceExpectation parse_ProvideInstanceExpectation() throws ParseException { Claim belongsTo; jj_consume_token(3); belongsTo = parse_Claim(); {if (true) return new ProvideInstanceExpectation(belongsTo);} throw new Error("Missing return statement in function"); } final public ProvideSolutionExpectation parse_ProvideSolutionExpectation() throws ParseException { Instance toBeSolved; Claim belongsTo; jj_consume_token(4); toBeSolved = parse_Instance(); belongsTo = parse_Claim(); {if (true) return new ProvideSolutionExpectation(toBeSolved,belongsTo);} throw new Error("Missing return statement in function"); } final public ClaimReply parse_ClaimReply() throws ParseException { Claim c; jj_consume_token(5); c = parse_Claim(); {if (true) return new ClaimReply(c);} throw new Error("Missing return statement in function"); } final public InstanceReply parse_InstanceReply() throws ParseException { Instance i; jj_consume_token(3); i = parse_Instance(); {if (true) return new InstanceReply(i);} throw new Error("Missing return statement in function"); } final public SolutionReply parse_SolutionReply() throws ParseException { Solution s; jj_consume_token(4); s = parse_Solution(); {if (true) return new SolutionReply(s);} throw new Error("Missing return statement in function"); } final public RefuteReply parse_RefuteReply() throws ParseException { Claim c; jj_consume_token(6); c = parse_Claim(); {if (true) return new RefuteReply(c);} throw new Error("Missing return statement in function"); } final public StrengthenReply parse_StrengthenReply() throws ParseException { Claim c; jj_consume_token(7); c = parse_Claim(); {if (true) return new StrengthenReply(c);} throw new Error("Missing return statement in function"); } final public AgreeReply parse_AgreeReply() throws ParseException { jj_consume_token(8); {if (true) return new AgreeReply();} throw new Error("Missing return statement in function"); } final public TestER parse_TestER() throws ParseException { List es; List ss; Domain d; jj_consume_token(9); es = parse_List$Expectation2$(); jj_consume_token(10); ss = parse_List$Reply$(); d = parse_Domain(); jj_consume_token(0); {if (true) return new TestER(es,ss,d);} throw new Error("Missing return statement in function"); } final public InstanceSet parse_InstanceSet() throws ParseException { jj_consume_token(11); {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(5); 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(12); 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 15: sup = parse_Start(); {if (true) return sup;} break; case 16: sup = parse_End(); {if (true) return sup;} break; case 13: sup = parse_InstanceProvided(); {if (true) return sup;} break; case 14: sup = parse_InstanceSolved(); {if (true) return sup;} break; default: jj_la1[4] = 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(13); {if (true) return new InstanceProvided();} throw new Error("Missing return statement in function"); } final public InstanceSolved parse_InstanceSolved() throws ParseException { jj_consume_token(14); {if (true) return new InstanceSolved();} throw new Error("Missing return statement in function"); } final public Start parse_Start() throws ParseException { jj_consume_token(15); {if (true) return new Start();} throw new Error("Missing return statement in function"); } final public End parse_End() throws ParseException { jj_consume_token(16); {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(17); {if (true) return new Instance();} throw new Error("Missing return statement in function"); } final public Solution parse_Solution() throws ParseException { jj_consume_token(18); {if (true) return new Solution();} throw new Error("Missing return statement in function"); } final public Domain parse_Domain() throws ParseException { jj_consume_token(19); {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 20: sup = parse_RED(); {if (true) return sup;} break; case 21: sup = parse_BLACK(); {if (true) return sup;} break; default: jj_la1[5] = 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(20); {if (true) return new RED();} throw new Error("Missing return statement in function"); } final public BLACK parse_BLACK() throws ParseException { jj_consume_token(21); {if (true) return new BLACK();} throw new Error("Missing return statement in function"); } final public List parse_List$Reply$() throws ParseException { List sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 3: case 4: case 5: case 6: case 7: case 8: sup = parse_Cons$Reply$(); {if (true) return sup;} break; default: jj_la1[6] = jj_gen; sup = parse_Empty$Reply$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty parse_Empty$Reply$() throws ParseException { {if (true) return new Empty();} throw new Error("Missing return statement in function"); } final public Cons parse_Cons$Reply$() throws ParseException { Reply first; List rest; first = parse_Reply(); rest = parse_List$Reply$(); {if (true) return new Cons(first,rest);} throw new Error("Missing return statement in function"); } final public List parse_List$Expectation2$() throws ParseException { List sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: case 2: case 3: case 4: sup = parse_Cons$Expectation2$(); {if (true) return sup;} break; default: jj_la1[7] = jj_gen; sup = parse_Empty$Expectation2$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty parse_Empty$Expectation2$() throws ParseException { {if (true) return new Empty();} throw new Error("Missing return statement in function"); } final public Cons parse_Cons$Expectation2$() throws ParseException { Expectation2 first; List rest; first = parse_Expectation2(); rest = parse_List$Expectation2$(); {if (true) return new Cons(first,rest);} throw new Error("Missing return statement in function"); } final public List parse_List$Claim$() throws ParseException { List sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 5: sup = parse_Cons$Claim$(); {if (true) return sup;} break; default: jj_la1[8] = jj_gen; sup = parse_Empty$Claim$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty parse_Empty$Claim$() throws ParseException { {if (true) return new Empty();} throw new Error("Missing return statement in function"); } final public Cons parse_Cons$Claim$() throws ParseException { Claim first; List rest; first = parse_Claim(); rest = parse_List$Claim$(); {if (true) return new Cons(first,rest);} 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[9]; 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[] {0x0,0x1e,0x1f8,0x1c0,0x1e000,0x300000,0x1f8,0x1e,0x20,}; } private static void jj_la1_init_1() { jj_la1_1 = new int[] {0x3,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,}; } /** 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 < 9; 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 < 9; 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 < 9; 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 < 9; 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 < 9; 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 < 9; 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[38]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 9; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<