X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.graphviz%2Fsrc%2Forg%2Fsimantics%2Fgraphviz%2Finternal%2Fparser%2FDotParser.java;h=a9684a1c4b0b0847eec9bfa481de5acbba848478;hp=fb43a4f4a77829b6dba9888438c8ae59c5586075;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.graphviz/src/org/simantics/graphviz/internal/parser/DotParser.java b/bundles/org.simantics.graphviz/src/org/simantics/graphviz/internal/parser/DotParser.java index fb43a4f4a..a9684a1c4 100644 --- a/bundles/org.simantics.graphviz/src/org/simantics/graphviz/internal/parser/DotParser.java +++ b/bundles/org.simantics.graphviz/src/org/simantics/graphviz/internal/parser/DotParser.java @@ -1,384 +1,384 @@ -/* Generated By:JavaCC: Do not edit this line. DotParser.java */ -package org.simantics.graphviz.internal.parser; - -import org.simantics.graphviz.*; -import java.util.Map; -import java.util.HashMap; - -@SuppressWarnings("all") -public class DotParser implements DotParserConstants { - AbstractAttributeContainer defaultNode = new AbstractAttributeContainer(); - AbstractAttributeContainer defaultEdge = new AbstractAttributeContainer(); - Map connectors = new HashMap(); - -/*** Parser ********************************************************/ - final public Graph document() throws ParseException { - Graph graph = new Graph(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 18: - jj_consume_token(18); - break; - default: - jj_la1[0] = jj_gen; - ; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 15: - jj_consume_token(15); - break; - case 14: - jj_consume_token(14); - break; - default: - jj_la1[1] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - jj_consume_token(8); - label_1: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 13: - case 15: - case 16: - case 17: - case STRING: - case HTML: - case IDENT: - case NUMBER: - ; - break; - default: - jj_la1[2] = jj_gen; - break label_1; - } - statement(graph); - } - jj_consume_token(9); - jj_consume_token(0); - {if (true) return graph;} - throw new Error("Missing return statement in function"); - } - - final public void statement(IGraph graph) throws ParseException { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case STRING: - case HTML: - case IDENT: - case NUMBER: - String id1, id2; - id1 = id(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 10: - case 19: - Node node = new Node(graph); connectors.put(id1, node); - attributes(node); - break; - case 5: - jj_consume_token(5); - id2 = id(); - Edge edge = new Edge(connectors.get(id1.split(":")[0]), - connectors.get(id2.split(":")[0])); - attributes(edge); - break; - default: - jj_la1[3] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - break; - case 15: - jj_consume_token(15); - attributes(graph); - break; - case 16: - jj_consume_token(16); - attributes(defaultNode); - break; - case 17: - jj_consume_token(17); - attributes(defaultEdge); - break; - case 13: - Subgraph subgraph; String id; - jj_consume_token(13); - id = id(); - subgraph = new Subgraph(graph); connectors.put(id, subgraph); - jj_consume_token(8); - label_2: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 13: - case 15: - case 16: - case 17: - case STRING: - case HTML: - case IDENT: - case NUMBER: - ; - break; - default: - jj_la1[4] = jj_gen; - break label_2; - } - statement(subgraph); - } - jj_consume_token(9); - break; - default: - jj_la1[5] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } - - final public void attributes(IAttributeContainer el) throws ParseException { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 10: - jj_consume_token(10); - attribute(el); - label_3: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 12: - case STRING: - case HTML: - case IDENT: - case NUMBER: - ; - break; - default: - jj_la1[6] = jj_gen; - break label_3; - } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 12: - jj_consume_token(12); - break; - default: - jj_la1[7] = jj_gen; - ; - } - attribute(el); - } - jj_consume_token(11); - break; - default: - jj_la1[8] = jj_gen; - ; - } - jj_consume_token(19); - - } - - final public void attribute(IAttributeContainer el) throws ParseException { - String key, value=""; - key = id(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case 4: - jj_consume_token(4); - value = id(); - break; - default: - jj_la1[9] = jj_gen; - ; - } - el.set(key, value); - } - - final public String id() throws ParseException { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NUMBER: - jj_consume_token(NUMBER); - {if (true) return token.image;} - break; - case STRING: - jj_consume_token(STRING); - {if (true) return token.image;} - break; - case IDENT: - jj_consume_token(IDENT); - {if (true) return token.image;} - break; - case HTML: - jj_consume_token(HTML); - {if (true) return token.image;} - break; - default: - jj_la1[10] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - /** Generated Token Manager. */ - public DotParserTokenManager 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[11]; - static private int[] jj_la1_0; - static { - jj_la1_init_0(); - } - private static void jj_la1_init_0() { - jj_la1_0 = new int[] {0x40000,0xc000,0xf3a000,0x80420,0xf3a000,0xf3a000,0xf01000,0x1000,0x400,0x10,0xf00000,}; - } - - /** Constructor with InputStream. */ - public DotParser(java.io.InputStream stream) { - this(stream, null); - } - /** Constructor with InputStream and supplied encoding */ - public DotParser(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 DotParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; 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 < 11; i++) jj_la1[i] = -1; - } - - /** Constructor. */ - public DotParser(java.io.Reader stream) { - jj_input_stream = new SimpleCharStream(stream, 1, 1); - token_source = new DotParserTokenManager(jj_input_stream); - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; 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 < 11; i++) jj_la1[i] = -1; - } - - /** Constructor with generated Token Manager. */ - public DotParser(DotParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; i++) jj_la1[i] = -1; - } - - /** Reinitialise. */ - public void ReInit(DotParserTokenManager tm) { - token_source = tm; - token = new Token(); - jj_ntk = -1; - jj_gen = 0; - for (int i = 0; i < 11; 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[24]; - if (jj_kind >= 0) { - la1tokens[jj_kind] = true; - jj_kind = -1; - } - for (int i = 0; i < 11; i++) { - if (jj_la1[i] == jj_gen) { - for (int j = 0; j < 32; j++) { - if ((jj_la1_0[i] & (1< connectors = new HashMap(); + +/*** Parser ********************************************************/ + final public Graph document() throws ParseException { + Graph graph = new Graph(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 18: + jj_consume_token(18); + break; + default: + jj_la1[0] = jj_gen; + ; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 15: + jj_consume_token(15); + break; + case 14: + jj_consume_token(14); + break; + default: + jj_la1[1] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + jj_consume_token(8); + label_1: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 13: + case 15: + case 16: + case 17: + case STRING: + case HTML: + case IDENT: + case NUMBER: + ; + break; + default: + jj_la1[2] = jj_gen; + break label_1; + } + statement(graph); + } + jj_consume_token(9); + jj_consume_token(0); + {if (true) return graph;} + throw new Error("Missing return statement in function"); + } + + final public void statement(IGraph graph) throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case STRING: + case HTML: + case IDENT: + case NUMBER: + String id1, id2; + id1 = id(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 10: + case 19: + Node node = new Node(graph); connectors.put(id1, node); + attributes(node); + break; + case 5: + jj_consume_token(5); + id2 = id(); + Edge edge = new Edge(connectors.get(id1.split(":")[0]), + connectors.get(id2.split(":")[0])); + attributes(edge); + break; + default: + jj_la1[3] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + break; + case 15: + jj_consume_token(15); + attributes(graph); + break; + case 16: + jj_consume_token(16); + attributes(defaultNode); + break; + case 17: + jj_consume_token(17); + attributes(defaultEdge); + break; + case 13: + Subgraph subgraph; String id; + jj_consume_token(13); + id = id(); + subgraph = new Subgraph(graph); connectors.put(id, subgraph); + jj_consume_token(8); + label_2: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 13: + case 15: + case 16: + case 17: + case STRING: + case HTML: + case IDENT: + case NUMBER: + ; + break; + default: + jj_la1[4] = jj_gen; + break label_2; + } + statement(subgraph); + } + jj_consume_token(9); + break; + default: + jj_la1[5] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + + final public void attributes(IAttributeContainer el) throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 10: + jj_consume_token(10); + attribute(el); + label_3: + while (true) { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 12: + case STRING: + case HTML: + case IDENT: + case NUMBER: + ; + break; + default: + jj_la1[6] = jj_gen; + break label_3; + } + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 12: + jj_consume_token(12); + break; + default: + jj_la1[7] = jj_gen; + ; + } + attribute(el); + } + jj_consume_token(11); + break; + default: + jj_la1[8] = jj_gen; + ; + } + jj_consume_token(19); + + } + + final public void attribute(IAttributeContainer el) throws ParseException { + String key, value=""; + key = id(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case 4: + jj_consume_token(4); + value = id(); + break; + default: + jj_la1[9] = jj_gen; + ; + } + el.set(key, value); + } + + final public String id() throws ParseException { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case NUMBER: + jj_consume_token(NUMBER); + {if (true) return token.image;} + break; + case STRING: + jj_consume_token(STRING); + {if (true) return token.image;} + break; + case IDENT: + jj_consume_token(IDENT); + {if (true) return token.image;} + break; + case HTML: + jj_consume_token(HTML); + {if (true) return token.image;} + break; + default: + jj_la1[10] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + /** Generated Token Manager. */ + public DotParserTokenManager 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[11]; + static private int[] jj_la1_0; + static { + jj_la1_init_0(); + } + private static void jj_la1_init_0() { + jj_la1_0 = new int[] {0x40000,0xc000,0xf3a000,0x80420,0xf3a000,0xf3a000,0xf01000,0x1000,0x400,0x10,0xf00000,}; + } + + /** Constructor with InputStream. */ + public DotParser(java.io.InputStream stream) { + this(stream, null); + } + /** Constructor with InputStream and supplied encoding */ + public DotParser(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 DotParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 11; 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 < 11; i++) jj_la1[i] = -1; + } + + /** Constructor. */ + public DotParser(java.io.Reader stream) { + jj_input_stream = new SimpleCharStream(stream, 1, 1); + token_source = new DotParserTokenManager(jj_input_stream); + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 11; 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 < 11; i++) jj_la1[i] = -1; + } + + /** Constructor with generated Token Manager. */ + public DotParser(DotParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 11; i++) jj_la1[i] = -1; + } + + /** Reinitialise. */ + public void ReInit(DotParserTokenManager tm) { + token_source = tm; + token = new Token(); + jj_ntk = -1; + jj_gen = 0; + for (int i = 0; i < 11; 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[24]; + if (jj_kind >= 0) { + la1tokens[jj_kind] = true; + jj_kind = -1; + } + for (int i = 0; i < 11; i++) { + if (jj_la1[i] == jj_gen) { + for (int j = 0; j < 32; j++) { + if ((jj_la1_0[i] & (1<