/* Generated By:JavaCC: Do not edit this line. TheParser.java */ package gen; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; 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 NetworkFlowInstance parse_NetworkFlowInstance() throws ParseException { EdgeLabeledGraph> g; Node source; Node sink; jj_consume_token(1); g = parse_EdgeLabeledGraph$Node$EdgeCapacity$Option$EdgeFlow$$(); jj_consume_token(2); source = parse_Node(); jj_consume_token(3); sink = parse_Node(); {if (true) return new NetworkFlowInstance(g,source,sink);} throw new Error("Missing return statement in function"); } final public Node parse_Node() throws ParseException { String v; v = parse_String(); {if (true) return new Node(v);} throw new Error("Missing return statement in function"); } final public EdgeCapacity parse_EdgeCapacity() throws ParseException { int v; jj_consume_token(4); v = parse_int(); {if (true) return new EdgeCapacity(v);} throw new Error("Missing return statement in function"); } final public Flow parse_Flow() throws ParseException { EdgeLabeledGraph g; jj_consume_token(5); g = parse_EdgeLabeledGraph$Node$EdgeFlow$Nothing$(); {if (true) return new Flow(g);} throw new Error("Missing return statement in function"); } final public EdgeFlow parse_EdgeFlow() throws ParseException { int v; jj_consume_token(6); v = parse_int(); {if (true) return new EdgeFlow(v);} throw new Error("Missing return statement in function"); } final public Nothing parse_Nothing() throws ParseException { {if (true) return new Nothing();} throw new Error("Missing return statement in function"); } final public TestNetworkFlow parse_TestNetworkFlow() throws ParseException { List lop; lop = parse_List$InstanceAndSolution$(); jj_consume_token(0); {if (true) return new TestNetworkFlow(lop);} throw new Error("Missing return statement in function"); } final public InstanceAndSolution parse_InstanceAndSolution() throws ParseException { NetworkFlowInstance nfi; Option f; Claim c; nfi = parse_NetworkFlowInstance(); f = parse_Option$Flow$(); c = parse_Claim(); {if (true) return new InstanceAndSolution(nfi,f,c);} throw new Error("Missing return statement in function"); } final public Claim parse_Claim() throws ParseException { String proposer; String name; NetworkFlowInstance nfi; Quality q; jj_consume_token(7); jj_consume_token(8); proposer = parse_String(); jj_consume_token(9); jj_consume_token(10); name = parse_String(); nfi = parse_NetworkFlowInstance(); jj_consume_token(11); q = parse_Quality(); {if (true) return new Claim(proposer,name,nfi,q);} throw new Error("Missing return statement in function"); } final public Quality parse_Quality() throws ParseException { double v; v = parse_double(); {if (true) return new Quality(v);} throw new Error("Missing return statement in function"); } final public Option parse_Option$Flow$() throws ParseException { Option sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 5: sup = parse_Some$Flow$(); {if (true) return sup;} break; default: jj_la1[1] = jj_gen; sup = parse_None$Flow$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public None parse_None$Flow$() throws ParseException { {if (true) return new None();} throw new Error("Missing return statement in function"); } final public Some parse_Some$Flow$() throws ParseException { Flow just; just = parse_Flow(); {if (true) return new Some(just);} throw new Error("Missing return statement in function"); } final public List parse_List$InstanceAndSolution$() throws ParseException { List sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 1: sup = parse_Cons$InstanceAndSolution$(); {if (true) return sup;} break; default: jj_la1[2] = jj_gen; sup = parse_Empty$InstanceAndSolution$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty parse_Empty$InstanceAndSolution$() throws ParseException { {if (true) return new Empty();} throw new Error("Missing return statement in function"); } final public Cons parse_Cons$InstanceAndSolution$() throws ParseException { InstanceAndSolution first; List rest; first = parse_InstanceAndSolution(); rest = parse_List$InstanceAndSolution$(); {if (true) return new Cons(first,rest);} throw new Error("Missing return statement in function"); } final public EdgeLabeledGraph parse_EdgeLabeledGraph$Node$EdgeFlow$Nothing$() throws ParseException { List> adjs; adjs = parse_List$Adjacency$Node$EdgeFlow$Nothing$$(); {if (true) return new EdgeLabeledGraph(adjs);} throw new Error("Missing return statement in function"); } final public List> parse_List$Adjacency$Node$EdgeFlow$Nothing$$() throws ParseException { List> sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: sup = parse_Cons$Adjacency$Node$EdgeFlow$Nothing$$(); {if (true) return sup;} break; default: jj_la1[3] = jj_gen; sup = parse_Empty$Adjacency$Node$EdgeFlow$Nothing$$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty> parse_Empty$Adjacency$Node$EdgeFlow$Nothing$$() throws ParseException { {if (true) return new Empty>();} throw new Error("Missing return statement in function"); } final public Adjacency parse_Adjacency$Node$EdgeFlow$Nothing$() throws ParseException { Node source; List> successors; source = parse_Node(); jj_consume_token(12); jj_consume_token(13); successors = parse_List$NodeAndLabel$Node$EdgeFlow$Nothing$$(); jj_consume_token(14); {if (true) return new Adjacency(source,successors);} throw new Error("Missing return statement in function"); } final public List> parse_List$NodeAndLabel$Node$EdgeFlow$Nothing$$() throws ParseException { List> sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: sup = parse_Cons$NodeAndLabel$Node$EdgeFlow$Nothing$$(); {if (true) return sup;} break; default: jj_la1[4] = jj_gen; sup = parse_Empty$NodeAndLabel$Node$EdgeFlow$Nothing$$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty> parse_Empty$NodeAndLabel$Node$EdgeFlow$Nothing$$() throws ParseException { {if (true) return new Empty>();} throw new Error("Missing return statement in function"); } final public NodeAndLabel parse_NodeAndLabel$Node$EdgeFlow$Nothing$() throws ParseException { Node n; EdgeFlow label1; Nothing label2; n = parse_Node(); label1 = parse_EdgeFlow(); label2 = parse_Nothing(); {if (true) return new NodeAndLabel(n,label1,label2);} throw new Error("Missing return statement in function"); } final public Cons> parse_Cons$NodeAndLabel$Node$EdgeFlow$Nothing$$() throws ParseException { NodeAndLabel first; List> rest; first = parse_NodeAndLabel$Node$EdgeFlow$Nothing$(); rest = parse_List$NodeAndLabel$Node$EdgeFlow$Nothing$$(); {if (true) return new Cons>(first,rest);} throw new Error("Missing return statement in function"); } final public Cons> parse_Cons$Adjacency$Node$EdgeFlow$Nothing$$() throws ParseException { Adjacency first; List> rest; first = parse_Adjacency$Node$EdgeFlow$Nothing$(); rest = parse_List$Adjacency$Node$EdgeFlow$Nothing$$(); {if (true) return new Cons>(first,rest);} throw new Error("Missing return statement in function"); } final public EdgeLabeledGraph> parse_EdgeLabeledGraph$Node$EdgeCapacity$Option$EdgeFlow$$() throws ParseException { List>> adjs; adjs = parse_List$Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$$(); {if (true) return new EdgeLabeledGraph>(adjs);} throw new Error("Missing return statement in function"); } final public List>> parse_List$Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$$() throws ParseException { List>> sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: sup = parse_Cons$Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$$(); {if (true) return sup;} break; default: jj_la1[5] = jj_gen; sup = parse_Empty$Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty>> parse_Empty$Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$$() throws ParseException { {if (true) return new Empty>>();} throw new Error("Missing return statement in function"); } final public Adjacency> parse_Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$() throws ParseException { Node source; List>> successors; source = parse_Node(); jj_consume_token(12); jj_consume_token(13); successors = parse_List$NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$$(); jj_consume_token(14); {if (true) return new Adjacency>(source,successors);} throw new Error("Missing return statement in function"); } final public List>> parse_List$NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$$() throws ParseException { List>> sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: sup = parse_Cons$NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$$(); {if (true) return sup;} break; default: jj_la1[6] = jj_gen; sup = parse_Empty$NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public Empty>> parse_Empty$NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$$() throws ParseException { {if (true) return new Empty>>();} throw new Error("Missing return statement in function"); } final public NodeAndLabel> parse_NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$() throws ParseException { Node n; EdgeCapacity label1; Option label2; n = parse_Node(); label1 = parse_EdgeCapacity(); label2 = parse_Option$EdgeFlow$(); {if (true) return new NodeAndLabel>(n,label1,label2);} throw new Error("Missing return statement in function"); } final public Option parse_Option$EdgeFlow$() throws ParseException { Option sup = null; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case 6: sup = parse_Some$EdgeFlow$(); {if (true) return sup;} break; default: jj_la1[7] = jj_gen; sup = parse_None$EdgeFlow$(); {if (true) return sup;} } throw new Error("Missing return statement in function"); } final public None parse_None$EdgeFlow$() throws ParseException { {if (true) return new None();} throw new Error("Missing return statement in function"); } final public Some parse_Some$EdgeFlow$() throws ParseException { EdgeFlow just; just = parse_EdgeFlow(); {if (true) return new Some(just);} throw new Error("Missing return statement in function"); } final public Cons>> parse_Cons$NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$$() throws ParseException { NodeAndLabel> first; List>> rest; first = parse_NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$(); rest = parse_List$NodeAndLabel$Node$EdgeCapacity$Option$EdgeFlow$$$(); {if (true) return new Cons>>(first,rest);} throw new Error("Missing return statement in function"); } final public Cons>> parse_Cons$Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$$() throws ParseException { Adjacency> first; List>> rest; first = parse_Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$(); rest = parse_List$Adjacency$Node$EdgeCapacity$Option$EdgeFlow$$$(); {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[8]; static private int[] jj_la1_0; static { jj_la1_init_0(); } private static void jj_la1_init_0() { jj_la1_0 = new int[] {0x6000000,0x20,0x2,0x10000000,0x10000000,0x10000000,0x10000000,0x40,}; } /** 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 < 8; 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 < 8; 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 < 8; 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 < 8; 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 < 8; 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 < 8; 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[31]; if (jj_kind >= 0) { la1tokens[jj_kind] = true; jj_kind = -1; } for (int i = 0; i < 8; i++) { if (jj_la1[i] == jj_gen) { for (int j = 0; j < 32; j++) { if ((jj_la1_0[i] & (1<