1 /* Generated By:JavaCC: Do not edit this line. DotParser.java */
2 package org.simantics.graphviz.internal.parser;
4 import org.simantics.graphviz.*;
6 import java.util.HashMap;
8 @SuppressWarnings("all")
9 public class DotParser implements DotParserConstants {
10 AbstractAttributeContainer defaultNode = new AbstractAttributeContainer();
11 AbstractAttributeContainer defaultEdge = new AbstractAttributeContainer();
12 Map<String,Identifiable> connectors = new HashMap<String,Identifiable>();
14 /*** Parser ********************************************************/
15 final public Graph document() throws ParseException {
16 Graph graph = new Graph();
17 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
25 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
35 throw new ParseException();
40 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
59 {if (true) return graph;}
60 throw new Error("Missing return statement in function");
63 final public void statement(IGraph graph) throws ParseException {
64 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
71 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
74 Node node = new Node(graph); connectors.put(id1, node);
80 Edge edge = new Edge(connectors.get(id1.split(":")[0]),
81 connectors.get(id2.split(":")[0]));
87 throw new ParseException();
96 attributes(defaultNode);
100 attributes(defaultEdge);
103 Subgraph subgraph; String id;
104 jj_consume_token(13);
106 subgraph = new Subgraph(graph); connectors.put(id, subgraph);
110 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
131 jj_consume_token(-1);
132 throw new ParseException();
136 final public void attributes(IAttributeContainer el) throws ParseException {
137 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
139 jj_consume_token(10);
143 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
155 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
157 jj_consume_token(12);
165 jj_consume_token(11);
171 jj_consume_token(19);
175 final public void attribute(IAttributeContainer el) throws ParseException {
176 String key, value="";
178 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
190 final public String id() throws ParseException {
191 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
193 jj_consume_token(NUMBER);
194 {if (true) return token.image;}
197 jj_consume_token(STRING);
198 {if (true) return token.image;}
201 jj_consume_token(IDENT);
202 {if (true) return token.image;}
205 jj_consume_token(HTML);
206 {if (true) return token.image;}
210 jj_consume_token(-1);
211 throw new ParseException();
213 throw new Error("Missing return statement in function");
216 /** Generated Token Manager. */
217 public DotParserTokenManager token_source;
218 SimpleCharStream jj_input_stream;
219 /** Current token. */
225 final private int[] jj_la1 = new int[11];
226 static private int[] jj_la1_0;
230 private static void jj_la1_init_0() {
231 jj_la1_0 = new int[] {0x40000,0xc000,0xf3a000,0x80420,0xf3a000,0xf3a000,0xf01000,0x1000,0x400,0x10,0xf00000,};
234 /** Constructor with InputStream. */
235 public DotParser(java.io.InputStream stream) {
238 /** Constructor with InputStream and supplied encoding */
239 public DotParser(java.io.InputStream stream, String encoding) {
240 try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
241 token_source = new DotParserTokenManager(jj_input_stream);
245 for (int i = 0; i < 11; i++) jj_la1[i] = -1;
249 public void ReInit(java.io.InputStream stream) {
250 ReInit(stream, null);
253 public void ReInit(java.io.InputStream stream, String encoding) {
254 try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
255 token_source.ReInit(jj_input_stream);
259 for (int i = 0; i < 11; i++) jj_la1[i] = -1;
263 public DotParser(java.io.Reader stream) {
264 jj_input_stream = new SimpleCharStream(stream, 1, 1);
265 token_source = new DotParserTokenManager(jj_input_stream);
269 for (int i = 0; i < 11; i++) jj_la1[i] = -1;
273 public void ReInit(java.io.Reader stream) {
274 jj_input_stream.ReInit(stream, 1, 1);
275 token_source.ReInit(jj_input_stream);
279 for (int i = 0; i < 11; i++) jj_la1[i] = -1;
282 /** Constructor with generated Token Manager. */
283 public DotParser(DotParserTokenManager tm) {
288 for (int i = 0; i < 11; i++) jj_la1[i] = -1;
292 public void ReInit(DotParserTokenManager tm) {
297 for (int i = 0; i < 11; i++) jj_la1[i] = -1;
300 private Token jj_consume_token(int kind) throws ParseException {
302 if ((oldToken = token).next != null) token = token.next;
303 else token = token.next = token_source.getNextToken();
305 if (token.kind == kind) {
311 throw generateParseException();
315 /** Get the next Token. */
316 final public Token getNextToken() {
317 if (token.next != null) token = token.next;
318 else token = token.next = token_source.getNextToken();
324 /** Get the specific Token. */
325 final public Token getToken(int index) {
327 for (int i = 0; i < index; i++) {
328 if (t.next != null) t = t.next;
329 else t = t.next = token_source.getNextToken();
334 private int jj_ntk() {
335 if ((jj_nt=token.next) == null)
336 return (jj_ntk = (token.next=token_source.getNextToken()).kind);
338 return (jj_ntk = jj_nt.kind);
341 private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
342 private int[] jj_expentry;
343 private int jj_kind = -1;
345 /** Generate ParseException. */
346 public ParseException generateParseException() {
347 jj_expentries.clear();
348 boolean[] la1tokens = new boolean[24];
350 la1tokens[jj_kind] = true;
353 for (int i = 0; i < 11; i++) {
354 if (jj_la1[i] == jj_gen) {
355 for (int j = 0; j < 32; j++) {
356 if ((jj_la1_0[i] & (1<<j)) != 0) {
362 for (int i = 0; i < 24; i++) {
364 jj_expentry = new int[1];
366 jj_expentries.add(jj_expentry);
369 int[][] exptokseq = new int[jj_expentries.size()][];
370 for (int i = 0; i < jj_expentries.size(); i++) {
371 exptokseq[i] = jj_expentries.get(i);
373 return new ParseException(token, exptokseq, tokenImage);
376 /** Enable tracing. */
377 final public void enable_tracing() {
380 /** Disable tracing. */
381 final public void disable_tracing() {