/* Generated By:JavaCC: Do not edit this line. TheParser.java */ package scg.net; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import java.io.*; import edu.neu.ccs.demeterf.lib.*; 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) != '\u005c\u005c') { retval += str.charAt(index++); continue; } ch = str.charAt(++index); if(ch == 'b') { retval += '\u005cb'; index++; continue; } if(ch == 't') { retval += '\u005ct'; index++; continue; } if(ch == 'n') { retval += '\u005cn'; index++; continue; } if(ch == 'f') { retval += '\u005cf'; index++; continue; } if(ch == 'r') { retval += '\u005cr'; index++; continue; } if(ch == '"') { retval += '\u005c"'; index++; continue; } if(ch == '\u005c'') { retval += '\u005c''; index++; continue; } if(ch == '\u005c\u005c') { retval += '\u005c\u005c'; 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 PlayerSpec parse_PlayerSpec() throws ParseException { String name; String address; int port; jj_consume_token(1); name = parse_String(); address = parse_String(); port = parse_int(); jj_consume_token(2); {if (true) return new PlayerSpec(name,address,port);} throw new Error("Missing return statement in function"); } final public PlayersFile parse_PlayersFile() throws ParseException { List players; players = parse_List$PlayerSpec$(); jj_consume_token(0); {if (true) return new PlayersFile(players);} throw new Error("Missing return statement in function"); } final public PasswordEntry parse_PasswordEntry() throws ParseException { String name; String passhash; jj_consume_token(3); name = parse_String(); passhash = parse_String(); jj_consume_token(2); {if (true) return new PasswordEntry(name,passhash);} throw new Error("Missing return statement in function"); } final public PasswordFile parse_PasswordFile() throws ParseException { List passwds; passwds = parse_List$PasswordEntry$(); jj_consume_token(0); {if (true) return new PasswordFile(passwds);} throw new Error("Missing return statement in function"); } final public TeamSpec parse_TeamSpec() throws ParseException { String name; String passhash; List players; jj_consume_token(4); name = parse_String(); passhash = parse_String(); players = parse_List$String$(); jj_consume_token(2); {if (true) return new TeamSpec(name,passhash,players);} throw new Error("Missing return statement in function"); } final public TeamFile parse_TeamFile() throws ParseException { List teams; teams = parse_List$TeamSpec$(); jj_consume_token(0); {if (true) return new TeamFile(teams);} 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 5: sup = parse_RED(); {if (true) return sup;} break; case 6: sup = parse_BLACK(); {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 RED parse_RED() throws ParseException { jj_consume_token(5); {if (true) return new RED();} throw new Error("Missing return statement in function"); } final public BLACK parse_BLACK() throws ParseException { jj_consume_token(6); {if (true) return new BLACK();} throw new Error("Missing return statement in function"); } final public List parse_List$TeamSpec$() throws ParseException { List sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 4: sup = parse_Cons$TeamSpec$(); {if (true) return sup;} break; default: jj_la1[2] = jj_gen; sup = parse_Empty$TeamSpec$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty parse_Empty$TeamSpec$() throws ParseException { {if (true) return new Empty();} throw new Error("Missing return statement in function"); } final public Cons parse_Cons$TeamSpec$() throws ParseException { TeamSpec first; List rest; first = parse_TeamSpec(); rest = parse_List$TeamSpec$(); {if (true) return new Cons(first,rest);} throw new Error("Missing return statement in function"); } final public List parse_List$String$() throws ParseException { List sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: sup = parse_Cons$String$(); {if (true) return sup;} break; default: jj_la1[3] = jj_gen; sup = parse_Empty$String$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty parse_Empty$String$() throws ParseException { {if (true) return new Empty();} throw new Error("Missing return statement in function"); } final public Cons parse_Cons$String$() throws ParseException { String first; List rest; first = parse_String(); rest = parse_List$String$(); {if (true) return new Cons(first,rest);} throw new Error("Missing return statement in function"); } final public List parse_List$PasswordEntry$() throws ParseException { List sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 3: sup = parse_Cons$PasswordEntry$(); {if (true) return sup;} break; default: jj_la1[4] = jj_gen; sup = parse_Empty$PasswordEntry$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty parse_Empty$PasswordEntry$() throws ParseException { {if (true) return new Empty();} throw new Error("Missing return statement in function"); } final public Cons parse_Cons$PasswordEntry$() throws ParseException { PasswordEntry first; List rest; first = parse_PasswordEntry(); rest = parse_List$PasswordEntry$(); {if (true) return new Cons(first,rest);} throw new Error("Missing return statement in function"); } final public List parse_List$PlayerSpec$() throws ParseException { List sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: sup = parse_Cons$PlayerSpec$(); {if (true) return sup;} break; default: jj_la1[5] = jj_gen; sup = parse_Empty$PlayerSpec$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty parse_Empty$PlayerSpec$() throws ParseException { {if (true) return new Empty();} throw new Error("Missing return statement in function"); } final public Cons parse_Cons$PlayerSpec$() throws ParseException { PlayerSpec first; List rest; first = parse_PlayerSpec(); rest = parse_List$PlayerSpec$(); {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[6]; static private int[] jj_la1_0; static { jj_la1_init_0(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x60000,0x60,0x10,0x100000,0x8,0x2,}; } /** 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 < 6; 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 < 6; 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 < 6; 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 < 6; 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 < 6; 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 < 6; 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[23]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 6; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<