]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graphviz/src/org/simantics/graphviz/internal/parser/DotParser.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.graphviz / src / org / simantics / graphviz / internal / parser / DotParser.java
1 /* Generated By:JavaCC: Do not edit this line. DotParser.java */
2 package org.simantics.graphviz.internal.parser;
3
4 import org.simantics.graphviz.*;
5 import java.util.Map;
6 import java.util.HashMap;
7
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>();
13
14 /*** Parser ********************************************************/
15   final public Graph document() throws ParseException {
16                      Graph graph = new Graph();
17     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
18     case 18:
19       jj_consume_token(18);
20       break;
21     default:
22       jj_la1[0] = jj_gen;
23       ;
24     }
25     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
26     case 15:
27       jj_consume_token(15);
28       break;
29     case 14:
30       jj_consume_token(14);
31       break;
32     default:
33       jj_la1[1] = jj_gen;
34       jj_consume_token(-1);
35       throw new ParseException();
36     }
37     jj_consume_token(8);
38     label_1:
39     while (true) {
40       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
41       case 13:
42       case 15:
43       case 16:
44       case 17:
45       case STRING:
46       case HTML:
47       case IDENT:
48       case NUMBER:
49         ;
50         break;
51       default:
52         jj_la1[2] = jj_gen;
53         break label_1;
54       }
55       statement(graph);
56     }
57     jj_consume_token(9);
58     jj_consume_token(0);
59                                                                         {if (true) return graph;}
60     throw new Error("Missing return statement in function");
61   }
62
63   final public void statement(IGraph graph) throws ParseException {
64     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
65     case STRING:
66     case HTML:
67     case IDENT:
68     case NUMBER:
69     String id1, id2;
70       id1 = id();
71       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
72       case 10:
73       case 19:
74       Node node = new Node(graph); connectors.put(id1, node);
75         attributes(node);
76         break;
77       case 5:
78         jj_consume_token(5);
79         id2 = id();
80         Edge edge = new Edge(connectors.get(id1.split(":")[0]),
81                                                  connectors.get(id2.split(":")[0]));
82         attributes(edge);
83         break;
84       default:
85         jj_la1[3] = jj_gen;
86         jj_consume_token(-1);
87         throw new ParseException();
88       }
89       break;
90     case 15:
91       jj_consume_token(15);
92       attributes(graph);
93       break;
94     case 16:
95       jj_consume_token(16);
96       attributes(defaultNode);
97       break;
98     case 17:
99       jj_consume_token(17);
100       attributes(defaultEdge);
101       break;
102     case 13:
103     Subgraph subgraph; String id;
104       jj_consume_token(13);
105       id = id();
106                        subgraph = new Subgraph(graph); connectors.put(id, subgraph);
107       jj_consume_token(8);
108       label_2:
109       while (true) {
110         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
111         case 13:
112         case 15:
113         case 16:
114         case 17:
115         case STRING:
116         case HTML:
117         case IDENT:
118         case NUMBER:
119           ;
120           break;
121         default:
122           jj_la1[4] = jj_gen;
123           break label_2;
124         }
125         statement(subgraph);
126       }
127       jj_consume_token(9);
128       break;
129     default:
130       jj_la1[5] = jj_gen;
131       jj_consume_token(-1);
132       throw new ParseException();
133     }
134   }
135
136   final public void attributes(IAttributeContainer el) throws ParseException {
137     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
138     case 10:
139       jj_consume_token(10);
140       attribute(el);
141       label_3:
142       while (true) {
143         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
144         case 12:
145         case STRING:
146         case HTML:
147         case IDENT:
148         case NUMBER:
149           ;
150           break;
151         default:
152           jj_la1[6] = jj_gen;
153           break label_3;
154         }
155         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
156         case 12:
157           jj_consume_token(12);
158           break;
159         default:
160           jj_la1[7] = jj_gen;
161           ;
162         }
163         attribute(el);
164       }
165       jj_consume_token(11);
166       break;
167     default:
168       jj_la1[8] = jj_gen;
169       ;
170     }
171     jj_consume_token(19);
172
173   }
174
175   final public void attribute(IAttributeContainer el) throws ParseException {
176                                            String key, value="";
177     key = id();
178     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
179     case 4:
180       jj_consume_token(4);
181       value = id();
182       break;
183     default:
184       jj_la1[9] = jj_gen;
185       ;
186     }
187                                el.set(key, value);
188   }
189
190   final public String id() throws ParseException {
191     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
192     case NUMBER:
193       jj_consume_token(NUMBER);
194              {if (true) return token.image;}
195       break;
196     case STRING:
197       jj_consume_token(STRING);
198              {if (true) return token.image;}
199       break;
200     case IDENT:
201       jj_consume_token(IDENT);
202             {if (true) return token.image;}
203       break;
204     case HTML:
205       jj_consume_token(HTML);
206            {if (true) return token.image;}
207       break;
208     default:
209       jj_la1[10] = jj_gen;
210       jj_consume_token(-1);
211       throw new ParseException();
212     }
213     throw new Error("Missing return statement in function");
214   }
215
216   /** Generated Token Manager. */
217   public DotParserTokenManager token_source;
218   SimpleCharStream jj_input_stream;
219   /** Current token. */
220   public Token token;
221   /** Next token. */
222   public Token jj_nt;
223   private int jj_ntk;
224   private int jj_gen;
225   final private int[] jj_la1 = new int[11];
226   static private int[] jj_la1_0;
227   static {
228       jj_la1_init_0();
229    }
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,};
232    }
233
234   /** Constructor with InputStream. */
235   public DotParser(java.io.InputStream stream) {
236      this(stream, null);
237   }
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);
242     token = new Token();
243     jj_ntk = -1;
244     jj_gen = 0;
245     for (int i = 0; i < 11; i++) jj_la1[i] = -1;
246   }
247
248   /** Reinitialise. */
249   public void ReInit(java.io.InputStream stream) {
250      ReInit(stream, null);
251   }
252   /** Reinitialise. */
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);
256     token = new Token();
257     jj_ntk = -1;
258     jj_gen = 0;
259     for (int i = 0; i < 11; i++) jj_la1[i] = -1;
260   }
261
262   /** Constructor. */
263   public DotParser(java.io.Reader stream) {
264     jj_input_stream = new SimpleCharStream(stream, 1, 1);
265     token_source = new DotParserTokenManager(jj_input_stream);
266     token = new Token();
267     jj_ntk = -1;
268     jj_gen = 0;
269     for (int i = 0; i < 11; i++) jj_la1[i] = -1;
270   }
271
272   /** Reinitialise. */
273   public void ReInit(java.io.Reader stream) {
274     jj_input_stream.ReInit(stream, 1, 1);
275     token_source.ReInit(jj_input_stream);
276     token = new Token();
277     jj_ntk = -1;
278     jj_gen = 0;
279     for (int i = 0; i < 11; i++) jj_la1[i] = -1;
280   }
281
282   /** Constructor with generated Token Manager. */
283   public DotParser(DotParserTokenManager tm) {
284     token_source = tm;
285     token = new Token();
286     jj_ntk = -1;
287     jj_gen = 0;
288     for (int i = 0; i < 11; i++) jj_la1[i] = -1;
289   }
290
291   /** Reinitialise. */
292   public void ReInit(DotParserTokenManager tm) {
293     token_source = tm;
294     token = new Token();
295     jj_ntk = -1;
296     jj_gen = 0;
297     for (int i = 0; i < 11; i++) jj_la1[i] = -1;
298   }
299
300   private Token jj_consume_token(int kind) throws ParseException {
301     Token oldToken;
302     if ((oldToken = token).next != null) token = token.next;
303     else token = token.next = token_source.getNextToken();
304     jj_ntk = -1;
305     if (token.kind == kind) {
306       jj_gen++;
307       return token;
308     }
309     token = oldToken;
310     jj_kind = kind;
311     throw generateParseException();
312   }
313
314
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();
319     jj_ntk = -1;
320     jj_gen++;
321     return token;
322   }
323
324 /** Get the specific Token. */
325   final public Token getToken(int index) {
326     Token t = token;
327     for (int i = 0; i < index; i++) {
328       if (t.next != null) t = t.next;
329       else t = t.next = token_source.getNextToken();
330     }
331     return t;
332   }
333
334   private int jj_ntk() {
335     if ((jj_nt=token.next) == null)
336       return (jj_ntk = (token.next=token_source.getNextToken()).kind);
337     else
338       return (jj_ntk = jj_nt.kind);
339   }
340
341   private java.util.List<int[]> jj_expentries = new java.util.ArrayList<int[]>();
342   private int[] jj_expentry;
343   private int jj_kind = -1;
344
345   /** Generate ParseException. */
346   public ParseException generateParseException() {
347     jj_expentries.clear();
348     boolean[] la1tokens = new boolean[24];
349     if (jj_kind >= 0) {
350       la1tokens[jj_kind] = true;
351       jj_kind = -1;
352     }
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) {
357             la1tokens[j] = true;
358           }
359         }
360       }
361     }
362     for (int i = 0; i < 24; i++) {
363       if (la1tokens[i]) {
364         jj_expentry = new int[1];
365         jj_expentry[0] = i;
366         jj_expentries.add(jj_expentry);
367       }
368     }
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);
372     }
373     return new ParseException(token, exptokseq, tokenImage);
374   }
375
376   /** Enable tracing. */
377   final public void enable_tracing() {
378   }
379
380   /** Disable tracing. */
381   final public void disable_tracing() {
382   }
383
384 }