--- /dev/null
+/* Generated By:JavaCC: Do not edit this line. DotParser.java */\r
+package org.simantics.graphviz.internal.parser;\r
+\r
+import org.simantics.graphviz.*;\r
+import java.util.Map;\r
+import java.util.HashMap;\r
+\r
+@SuppressWarnings("all")\r
+public class DotParser implements DotParserConstants {\r
+ AbstractAttributeContainer defaultNode = new AbstractAttributeContainer();\r
+ AbstractAttributeContainer defaultEdge = new AbstractAttributeContainer();\r
+ Map<String,Identifiable> connectors = new HashMap<String,Identifiable>();\r
+\r
+/*** Parser ********************************************************/\r
+ final public Graph document() throws ParseException {\r
+ Graph graph = new Graph();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 18:\r
+ jj_consume_token(18);\r
+ break;\r
+ default:\r
+ jj_la1[0] = jj_gen;\r
+ ;\r
+ }\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 15:\r
+ jj_consume_token(15);\r
+ break;\r
+ case 14:\r
+ jj_consume_token(14);\r
+ break;\r
+ default:\r
+ jj_la1[1] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ jj_consume_token(8);\r
+ label_1:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 13:\r
+ case 15:\r
+ case 16:\r
+ case 17:\r
+ case STRING:\r
+ case HTML:\r
+ case IDENT:\r
+ case NUMBER:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[2] = jj_gen;\r
+ break label_1;\r
+ }\r
+ statement(graph);\r
+ }\r
+ jj_consume_token(9);\r
+ jj_consume_token(0);\r
+ {if (true) return graph;}\r
+ throw new Error("Missing return statement in function");\r
+ }\r
+\r
+ final public void statement(IGraph graph) throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case STRING:\r
+ case HTML:\r
+ case IDENT:\r
+ case NUMBER:\r
+ String id1, id2;\r
+ id1 = id();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 10:\r
+ case 19:\r
+ Node node = new Node(graph); connectors.put(id1, node);\r
+ attributes(node);\r
+ break;\r
+ case 5:\r
+ jj_consume_token(5);\r
+ id2 = id();\r
+ Edge edge = new Edge(connectors.get(id1.split(":")[0]),\r
+ connectors.get(id2.split(":")[0]));\r
+ attributes(edge);\r
+ break;\r
+ default:\r
+ jj_la1[3] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ break;\r
+ case 15:\r
+ jj_consume_token(15);\r
+ attributes(graph);\r
+ break;\r
+ case 16:\r
+ jj_consume_token(16);\r
+ attributes(defaultNode);\r
+ break;\r
+ case 17:\r
+ jj_consume_token(17);\r
+ attributes(defaultEdge);\r
+ break;\r
+ case 13:\r
+ Subgraph subgraph; String id;\r
+ jj_consume_token(13);\r
+ id = id();\r
+ subgraph = new Subgraph(graph); connectors.put(id, subgraph);\r
+ jj_consume_token(8);\r
+ label_2:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 13:\r
+ case 15:\r
+ case 16:\r
+ case 17:\r
+ case STRING:\r
+ case HTML:\r
+ case IDENT:\r
+ case NUMBER:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[4] = jj_gen;\r
+ break label_2;\r
+ }\r
+ statement(subgraph);\r
+ }\r
+ jj_consume_token(9);\r
+ break;\r
+ default:\r
+ jj_la1[5] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ }\r
+\r
+ final public void attributes(IAttributeContainer el) throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 10:\r
+ jj_consume_token(10);\r
+ attribute(el);\r
+ label_3:\r
+ while (true) {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 12:\r
+ case STRING:\r
+ case HTML:\r
+ case IDENT:\r
+ case NUMBER:\r
+ ;\r
+ break;\r
+ default:\r
+ jj_la1[6] = jj_gen;\r
+ break label_3;\r
+ }\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 12:\r
+ jj_consume_token(12);\r
+ break;\r
+ default:\r
+ jj_la1[7] = jj_gen;\r
+ ;\r
+ }\r
+ attribute(el);\r
+ }\r
+ jj_consume_token(11);\r
+ break;\r
+ default:\r
+ jj_la1[8] = jj_gen;\r
+ ;\r
+ }\r
+ jj_consume_token(19);\r
+\r
+ }\r
+\r
+ final public void attribute(IAttributeContainer el) throws ParseException {\r
+ String key, value="";\r
+ key = id();\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case 4:\r
+ jj_consume_token(4);\r
+ value = id();\r
+ break;\r
+ default:\r
+ jj_la1[9] = jj_gen;\r
+ ;\r
+ }\r
+ el.set(key, value);\r
+ }\r
+\r
+ final public String id() throws ParseException {\r
+ switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+ case NUMBER:\r
+ jj_consume_token(NUMBER);\r
+ {if (true) return token.image;}\r
+ break;\r
+ case STRING:\r
+ jj_consume_token(STRING);\r
+ {if (true) return token.image;}\r
+ break;\r
+ case IDENT:\r
+ jj_consume_token(IDENT);\r
+ {if (true) return token.image;}\r
+ break;\r
+ case HTML:\r
+ jj_consume_token(HTML);\r
+ {if (true) return token.image;}\r
+ break;\r
+ default:\r
+ jj_la1[10] = jj_gen;\r
+ jj_consume_token(-1);\r
+ throw new ParseException();\r
+ }\r
+ throw new Error("Missing return statement in function");\r
+ }\r
+\r
+ /** Generated Token Manager. */\r
+ public DotParserTokenManager token_source;\r
+ SimpleCharStream jj_input_stream;\r
+ /** Current token. */\r
+ public Token token;\r
+ /** Next token. */\r
+ public Token jj_nt;\r
+ private int jj_ntk;\r
+ private int jj_gen;\r
+ final private int[] jj_la1 = new int[11];\r
+ static private int[] jj_la1_0;\r
+ static {\r
+ jj_la1_init_0();\r
+ }\r
+ private static void jj_la1_init_0() {\r
+ jj_la1_0 = new int[] {0x40000,0xc000,0xf3a000,0x80420,0xf3a000,0xf3a000,0xf01000,0x1000,0x400,0x10,0xf00000,};\r
+ }\r
+\r
+ /** Constructor with InputStream. */\r
+ public DotParser(java.io.InputStream stream) {\r
+ this(stream, null);\r
+ }\r
+ /** Constructor with InputStream and supplied encoding */\r
+ public DotParser(java.io.InputStream stream, String encoding) {\r
+ try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }\r
+ token_source = new DotParserTokenManager(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 11; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream stream) {\r
+ ReInit(stream, null);\r
+ }\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.InputStream stream, String encoding) {\r
+ try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }\r
+ token_source.ReInit(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 11; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Constructor. */\r
+ public DotParser(java.io.Reader stream) {\r
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);\r
+ token_source = new DotParserTokenManager(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 11; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(java.io.Reader stream) {\r
+ jj_input_stream.ReInit(stream, 1, 1);\r
+ token_source.ReInit(jj_input_stream);\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 11; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Constructor with generated Token Manager. */\r
+ public DotParser(DotParserTokenManager tm) {\r
+ token_source = tm;\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 11; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ /** Reinitialise. */\r
+ public void ReInit(DotParserTokenManager tm) {\r
+ token_source = tm;\r
+ token = new Token();\r
+ jj_ntk = -1;\r
+ jj_gen = 0;\r
+ for (int i = 0; i < 11; i++) jj_la1[i] = -1;\r
+ }\r
+\r
+ private Token jj_consume_token(int kind) throws ParseException {\r
+ Token oldToken;\r
+ if ((oldToken = token).next != null) token = token.next;\r
+ else token = token.next = token_source.getNextToken();\r
+ jj_ntk = -1;\r
+ if (token.kind == kind) {\r
+ jj_gen++;\r
+ return token;\r
+ }\r
+ token = oldToken;\r
+ jj_kind = kind;\r
+ throw generateParseException();\r
+ }\r
+\r
+\r
+/** Get the next Token. */\r
+ final public Token getNextToken() {\r
+ if (token.next != null) token = token.next;\r
+ else token = token.next = token_source.getNextToken();\r
+ jj_ntk = -1;\r
+ jj_gen++;\r
+ return token;\r
+ }\r
+\r
+/** Get the specific Token. */\r
+ final public Token getToken(int index) {\r
+ Token t = token;\r
+ for (int i = 0; i < index; i++) {\r
+ if (t.next != null) t = t.next;\r
+ else t = t.next = token_source.getNextToken();\r
+ }\r
+ return t;\r
+ }\r
+\r
+ private int jj_ntk() {\r
+ if ((jj_nt=token.next) == null)\r
+ return (jj_ntk = (token.next=token_source.getNextToken()).kind);\r
+ else\r
+ return (jj_ntk = jj_nt.kind);\r
+ }\r
+\r
+ private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();\r
+ private int[] jj_expentry;\r
+ private int jj_kind = -1;\r
+\r
+ /** Generate ParseException. */\r
+ public ParseException generateParseException() {\r
+ jj_expentries.clear();\r
+ boolean[] la1tokens = new boolean[24];\r
+ if (jj_kind >= 0) {\r
+ la1tokens[jj_kind] = true;\r
+ jj_kind = -1;\r
+ }\r
+ for (int i = 0; i < 11; i++) {\r
+ if (jj_la1[i] == jj_gen) {\r
+ for (int j = 0; j < 32; j++) {\r
+ if ((jj_la1_0[i] & (1<<j)) != 0) {\r
+ la1tokens[j] = true;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ for (int i = 0; i < 24; i++) {\r
+ if (la1tokens[i]) {\r
+ jj_expentry = new int[1];\r
+ jj_expentry[0] = i;\r
+ jj_expentries.add(jj_expentry);\r
+ }\r
+ }\r
+ int[][] exptokseq = new int[jj_expentries.size()][];\r
+ for (int i = 0; i < jj_expentries.size(); i++) {\r
+ exptokseq[i] = jj_expentries.get(i);\r
+ }\r
+ return new ParseException(token, exptokseq, tokenImage);\r
+ }\r
+\r
+ /** Enable tracing. */\r
+ final public void enable_tracing() {\r
+ }\r
+\r
+ /** Disable tracing. */\r
+ final public void disable_tracing() {\r
+ }\r
+\r
+}\r