Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / parsing / GraphParser.java
1 // $ANTLR 3.3 Nov 30, 2010 12:50:56 src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g 2011-12-19 14:53:14\r
2  package org.simantics.graph.compiler.internal.parsing; \r
3 \r
4 import org.antlr.runtime.*;\r
5 import java.util.Stack;\r
6 import java.util.List;\r
7 import java.util.ArrayList;\r
8 import java.util.Map;\r
9 import java.util.HashMap;\r
10 \r
11 import org.antlr.runtime.tree.*;\r
12 \r
13 @SuppressWarnings("unused")\r
14 public class GraphParser extends Parser {\r
15     public static final String[] tokenNames = new String[] {\r
16         "<invalid>", "<EOR>", "<DOWN>", "<UP>", "INDENT", "DEDENT", "FILE", "RESOURCE", "PROPERTY", "VARIABLE", "EMBEDDED_VALUE", "EMBEDDED_TYPE", "TEMPLATE_INSTANCE", "TEMPLATE_DEFINITION", "BLANK", "REF", "EQUALS", "INSTANCE_OF", "INHERITS", "SUBRELATION_OF", "HAS_DOMAIN", "HAS_RANGE", "DOMAIN_OF", "REQUIRES_VALUE_TYPE", "TYPE_DEFINITIONS", "TYPE_DEFINITION", "UNION_TYPE", "RECORD_TYPE", "TUPLE_TYPE", "ARRAY_TYPE", "TYPE_REFERENCE", "TYPE_ANNOTATION", "TYPE_COMPONENT", "VALUE_DEFINITIONS", "VALUE_DEFINITION", "NO_VALUE", "VARIANT", "ARRAY", "TUPLE", "TAGGED_VALUE", "RECORD", "MAP", "ASSIGNMENT", "TRUE", "FALSE", "ID", "COMMENT", "WS", "LPAREN", "RPAREN", "LBRACKET", "RBRACKET", "LCURLY", "RCURLY", "INT", "INT_RANGE", "FLOAT", "RANGE", "NEWLINE", "EXPONENT", "ESC_SEQ", "STRING", "URI", "HEX_DIGIT", "UNICODE_ESC", "'@'", "'.'", "'<T'", "'<R'", "'<--'", "'-->'", "'==>'", "'>--'", "':'", "'='", "'%'", "'$'", "'|'", "','", "'true'", "'false'"\r
17     };\r
18     public static final int EOF=-1;\r
19     public static final int T__65=65;\r
20     public static final int T__66=66;\r
21     public static final int T__67=67;\r
22     public static final int T__68=68;\r
23     public static final int T__69=69;\r
24     public static final int T__70=70;\r
25     public static final int T__71=71;\r
26     public static final int T__72=72;\r
27     public static final int T__73=73;\r
28     public static final int T__74=74;\r
29     public static final int T__75=75;\r
30     public static final int T__76=76;\r
31     public static final int T__77=77;\r
32     public static final int T__78=78;\r
33     public static final int T__79=79;\r
34     public static final int T__80=80;\r
35     public static final int INDENT=4;\r
36     public static final int DEDENT=5;\r
37     public static final int FILE=6;\r
38     public static final int RESOURCE=7;\r
39     public static final int PROPERTY=8;\r
40     public static final int VARIABLE=9;\r
41     public static final int EMBEDDED_VALUE=10;\r
42     public static final int EMBEDDED_TYPE=11;\r
43     public static final int TEMPLATE_INSTANCE=12;\r
44     public static final int TEMPLATE_DEFINITION=13;\r
45     public static final int BLANK=14;\r
46     public static final int REF=15;\r
47     public static final int EQUALS=16;\r
48     public static final int INSTANCE_OF=17;\r
49     public static final int INHERITS=18;\r
50     public static final int SUBRELATION_OF=19;\r
51     public static final int HAS_DOMAIN=20;\r
52     public static final int HAS_RANGE=21;\r
53     public static final int DOMAIN_OF=22;\r
54     public static final int REQUIRES_VALUE_TYPE=23;\r
55     public static final int TYPE_DEFINITIONS=24;\r
56     public static final int TYPE_DEFINITION=25;\r
57     public static final int UNION_TYPE=26;\r
58     public static final int RECORD_TYPE=27;\r
59     public static final int TUPLE_TYPE=28;\r
60     public static final int ARRAY_TYPE=29;\r
61     public static final int TYPE_REFERENCE=30;\r
62     public static final int TYPE_ANNOTATION=31;\r
63     public static final int TYPE_COMPONENT=32;\r
64     public static final int VALUE_DEFINITIONS=33;\r
65     public static final int VALUE_DEFINITION=34;\r
66     public static final int NO_VALUE=35;\r
67     public static final int VARIANT=36;\r
68     public static final int ARRAY=37;\r
69     public static final int TUPLE=38;\r
70     public static final int TAGGED_VALUE=39;\r
71     public static final int RECORD=40;\r
72     public static final int MAP=41;\r
73     public static final int ASSIGNMENT=42;\r
74     public static final int TRUE=43;\r
75     public static final int FALSE=44;\r
76     public static final int ID=45;\r
77     public static final int COMMENT=46;\r
78     public static final int WS=47;\r
79     public static final int LPAREN=48;\r
80     public static final int RPAREN=49;\r
81     public static final int LBRACKET=50;\r
82     public static final int RBRACKET=51;\r
83     public static final int LCURLY=52;\r
84     public static final int RCURLY=53;\r
85     public static final int INT=54;\r
86     public static final int INT_RANGE=55;\r
87     public static final int FLOAT=56;\r
88     public static final int RANGE=57;\r
89     public static final int NEWLINE=58;\r
90     public static final int EXPONENT=59;\r
91     public static final int ESC_SEQ=60;\r
92     public static final int STRING=61;\r
93     public static final int URI=62;\r
94     public static final int HEX_DIGIT=63;\r
95     public static final int UNICODE_ESC=64;\r
96 \r
97     // delegates\r
98     // delegators\r
99 \r
100 \r
101         public GraphParser(TokenStream input) {\r
102             this(input, new RecognizerSharedState());\r
103         }\r
104         public GraphParser(TokenStream input, RecognizerSharedState state) {\r
105             super(input, state);\r
106              \r
107         }\r
108         \r
109     protected TreeAdaptor adaptor = new CommonTreeAdaptor();\r
110 \r
111     public void setTreeAdaptor(TreeAdaptor adaptor) {\r
112         this.adaptor = adaptor;\r
113     }\r
114     public TreeAdaptor getTreeAdaptor() {\r
115         return adaptor;\r
116     }\r
117 \r
118     public String[] getTokenNames() { return GraphParser.tokenNames; }\r
119     public String getGrammarFileName() { return "src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g"; }\r
120 \r
121 \r
122     public static class file_return extends ParserRuleReturnScope {\r
123         CommonTree tree;\r
124         public Object getTree() { return tree; }\r
125     };\r
126 \r
127     // $ANTLR start "file"\r
128     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:1: file : ( NEWLINE )? ( resourceDefinitions )? EOF -> ^( FILE ( resourceDefinitions )? ) ;\r
129     public final GraphParser.file_return file() throws RecognitionException {\r
130         GraphParser.file_return retval = new GraphParser.file_return();\r
131         retval.start = input.LT(1);\r
132 \r
133         CommonTree root_0 = null;\r
134 \r
135         Token NEWLINE1=null;\r
136         Token EOF3=null;\r
137         GraphParser.resourceDefinitions_return resourceDefinitions2 = null;\r
138 \r
139 \r
140         CommonTree NEWLINE1_tree=null;\r
141         CommonTree EOF3_tree=null;\r
142         RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");\r
143         RewriteRuleTokenStream stream_EOF=new RewriteRuleTokenStream(adaptor,"token EOF");\r
144         RewriteRuleSubtreeStream stream_resourceDefinitions=new RewriteRuleSubtreeStream(adaptor,"rule resourceDefinitions");\r
145         try {\r
146             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:6: ( ( NEWLINE )? ( resourceDefinitions )? EOF -> ^( FILE ( resourceDefinitions )? ) )\r
147             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:8: ( NEWLINE )? ( resourceDefinitions )? EOF\r
148             {\r
149             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:8: ( NEWLINE )?\r
150             int alt1=2;\r
151             int LA1_0 = input.LA(1);\r
152 \r
153             if ( (LA1_0==NEWLINE) ) {\r
154                 alt1=1;\r
155             }\r
156             switch (alt1) {\r
157                 case 1 :\r
158                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:8: NEWLINE\r
159                     {\r
160                     NEWLINE1=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_file1230); if (state.failed) return retval; \r
161                     if ( state.backtracking==0 ) stream_NEWLINE.add(NEWLINE1);\r
162 \r
163 \r
164                     }\r
165                     break;\r
166 \r
167             }\r
168 \r
169             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:17: ( resourceDefinitions )?\r
170             int alt2=2;\r
171             int LA2_0 = input.LA(1);\r
172 \r
173             if ( (LA2_0==ID||LA2_0==LPAREN||LA2_0==LBRACKET||LA2_0==LCURLY||LA2_0==INT||LA2_0==FLOAT||(LA2_0>=STRING && LA2_0<=URI)||LA2_0==65||(LA2_0>=75 && LA2_0<=76)||(LA2_0>=79 && LA2_0<=80)) ) {\r
174                 alt2=1;\r
175             }\r
176             switch (alt2) {\r
177                 case 1 :\r
178                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:17: resourceDefinitions\r
179                     {\r
180                     pushFollow(FOLLOW_resourceDefinitions_in_file1233);\r
181                     resourceDefinitions2=resourceDefinitions();\r
182 \r
183                     state._fsp--;\r
184                     if (state.failed) return retval;\r
185                     if ( state.backtracking==0 ) stream_resourceDefinitions.add(resourceDefinitions2.getTree());\r
186 \r
187                     }\r
188                     break;\r
189 \r
190             }\r
191 \r
192             EOF3=(Token)match(input,EOF,FOLLOW_EOF_in_file1236); if (state.failed) return retval; \r
193             if ( state.backtracking==0 ) stream_EOF.add(EOF3);\r
194 \r
195 \r
196 \r
197             // AST REWRITE\r
198             // elements: resourceDefinitions\r
199             // token labels: \r
200             // rule labels: retval\r
201             // token list labels: \r
202             // rule list labels: \r
203             // wildcard labels: \r
204             if ( state.backtracking==0 ) {\r
205             retval.tree = root_0;\r
206             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
207 \r
208             root_0 = (CommonTree)adaptor.nil();\r
209             // 224:42: -> ^( FILE ( resourceDefinitions )? )\r
210             {\r
211                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:45: ^( FILE ( resourceDefinitions )? )\r
212                 {\r
213                 CommonTree root_1 = (CommonTree)adaptor.nil();\r
214                 root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(FILE, "FILE"), root_1);\r
215 \r
216                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:224:52: ( resourceDefinitions )?\r
217                 if ( stream_resourceDefinitions.hasNext() ) {\r
218                     adaptor.addChild(root_1, stream_resourceDefinitions.nextTree());\r
219 \r
220                 }\r
221                 stream_resourceDefinitions.reset();\r
222 \r
223                 adaptor.addChild(root_0, root_1);\r
224                 }\r
225 \r
226             }\r
227 \r
228             retval.tree = root_0;}\r
229             }\r
230 \r
231             retval.stop = input.LT(-1);\r
232 \r
233             if ( state.backtracking==0 ) {\r
234 \r
235             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
236             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
237             }\r
238         }\r
239         catch (RecognitionException re) {\r
240             reportError(re);\r
241             recover(input,re);\r
242         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
243 \r
244         }\r
245         finally {\r
246         }\r
247         return retval;\r
248     }\r
249     // $ANTLR end "file"\r
250 \r
251     public static class resourceDefinitions_return extends ParserRuleReturnScope {\r
252         CommonTree tree;\r
253         public Object getTree() { return tree; }\r
254     };\r
255 \r
256     // $ANTLR start "resourceDefinitions"\r
257     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:226:1: resourceDefinitions : resourceDefinition ( NEWLINE resourceDefinition )* ;\r
258     public final GraphParser.resourceDefinitions_return resourceDefinitions() throws RecognitionException {\r
259         GraphParser.resourceDefinitions_return retval = new GraphParser.resourceDefinitions_return();\r
260         retval.start = input.LT(1);\r
261 \r
262         CommonTree root_0 = null;\r
263 \r
264         Token NEWLINE5=null;\r
265         GraphParser.resourceDefinition_return resourceDefinition4 = null;\r
266 \r
267         GraphParser.resourceDefinition_return resourceDefinition6 = null;\r
268 \r
269 \r
270         CommonTree NEWLINE5_tree=null;\r
271 \r
272         try {\r
273             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:227:6: ( resourceDefinition ( NEWLINE resourceDefinition )* )\r
274             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:227:8: resourceDefinition ( NEWLINE resourceDefinition )*\r
275             {\r
276             root_0 = (CommonTree)adaptor.nil();\r
277 \r
278             pushFollow(FOLLOW_resourceDefinition_in_resourceDefinitions1260);\r
279             resourceDefinition4=resourceDefinition();\r
280 \r
281             state._fsp--;\r
282             if (state.failed) return retval;\r
283             if ( state.backtracking==0 ) adaptor.addChild(root_0, resourceDefinition4.getTree());\r
284             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:227:27: ( NEWLINE resourceDefinition )*\r
285             loop3:\r
286             do {\r
287                 int alt3=2;\r
288                 int LA3_0 = input.LA(1);\r
289 \r
290                 if ( (LA3_0==NEWLINE) ) {\r
291                     alt3=1;\r
292                 }\r
293 \r
294 \r
295                 switch (alt3) {\r
296                 case 1 :\r
297                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:227:28: NEWLINE resourceDefinition\r
298                     {\r
299                     NEWLINE5=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_resourceDefinitions1263); if (state.failed) return retval;\r
300                     pushFollow(FOLLOW_resourceDefinition_in_resourceDefinitions1266);\r
301                     resourceDefinition6=resourceDefinition();\r
302 \r
303                     state._fsp--;\r
304                     if (state.failed) return retval;\r
305                     if ( state.backtracking==0 ) adaptor.addChild(root_0, resourceDefinition6.getTree());\r
306 \r
307                     }\r
308                     break;\r
309 \r
310                 default :\r
311                     break loop3;\r
312                 }\r
313             } while (true);\r
314 \r
315 \r
316             }\r
317 \r
318             retval.stop = input.LT(-1);\r
319 \r
320             if ( state.backtracking==0 ) {\r
321 \r
322             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
323             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
324             }\r
325         }\r
326         catch (RecognitionException re) {\r
327             reportError(re);\r
328             recover(input,re);\r
329         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
330 \r
331         }\r
332         finally {\r
333         }\r
334         return retval;\r
335     }\r
336     // $ANTLR end "resourceDefinitions"\r
337 \r
338     public static class resourceDefinition_return extends ParserRuleReturnScope {\r
339         CommonTree tree;\r
340         public Object getTree() { return tree; }\r
341     };\r
342 \r
343     // $ANTLR start "resourceDefinition"\r
344     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:230:1: resourceDefinition : ( resource ( localProperty )* ( INDENT property ( NEWLINE property )* DEDENT )? -> ^( RESOURCE resource ( localProperty )* ( property )* ) | template -> ^( RESOURCE ^( BLANK template ) template ) );\r
345     public final GraphParser.resourceDefinition_return resourceDefinition() throws RecognitionException {\r
346         GraphParser.resourceDefinition_return retval = new GraphParser.resourceDefinition_return();\r
347         retval.start = input.LT(1);\r
348 \r
349         CommonTree root_0 = null;\r
350 \r
351         Token INDENT9=null;\r
352         Token NEWLINE11=null;\r
353         Token DEDENT13=null;\r
354         GraphParser.resource_return resource7 = null;\r
355 \r
356         GraphParser.localProperty_return localProperty8 = null;\r
357 \r
358         GraphParser.property_return property10 = null;\r
359 \r
360         GraphParser.property_return property12 = null;\r
361 \r
362         GraphParser.template_return template14 = null;\r
363 \r
364 \r
365         CommonTree INDENT9_tree=null;\r
366         CommonTree NEWLINE11_tree=null;\r
367         CommonTree DEDENT13_tree=null;\r
368         RewriteRuleTokenStream stream_DEDENT=new RewriteRuleTokenStream(adaptor,"token DEDENT");\r
369         RewriteRuleTokenStream stream_NEWLINE=new RewriteRuleTokenStream(adaptor,"token NEWLINE");\r
370         RewriteRuleTokenStream stream_INDENT=new RewriteRuleTokenStream(adaptor,"token INDENT");\r
371         RewriteRuleSubtreeStream stream_template=new RewriteRuleSubtreeStream(adaptor,"rule template");\r
372         RewriteRuleSubtreeStream stream_resource=new RewriteRuleSubtreeStream(adaptor,"rule resource");\r
373         RewriteRuleSubtreeStream stream_property=new RewriteRuleSubtreeStream(adaptor,"rule property");\r
374         RewriteRuleSubtreeStream stream_localProperty=new RewriteRuleSubtreeStream(adaptor,"rule localProperty");\r
375         try {\r
376             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:231:5: ( resource ( localProperty )* ( INDENT property ( NEWLINE property )* DEDENT )? -> ^( RESOURCE resource ( localProperty )* ( property )* ) | template -> ^( RESOURCE ^( BLANK template ) template ) )\r
377             int alt7=2;\r
378             int LA7_0 = input.LA(1);\r
379 \r
380             if ( (LA7_0==ID||LA7_0==LPAREN||LA7_0==LBRACKET||LA7_0==LCURLY||LA7_0==INT||LA7_0==FLOAT||(LA7_0>=STRING && LA7_0<=URI)||(LA7_0>=75 && LA7_0<=76)||(LA7_0>=79 && LA7_0<=80)) ) {\r
381                 alt7=1;\r
382             }\r
383             else if ( (LA7_0==65) ) {\r
384                 alt7=2;\r
385             }\r
386             else {\r
387                 if (state.backtracking>0) {state.failed=true; return retval;}\r
388                 NoViableAltException nvae =\r
389                     new NoViableAltException("", 7, 0, input);\r
390 \r
391                 throw nvae;\r
392             }\r
393             switch (alt7) {\r
394                 case 1 :\r
395                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:231:7: resource ( localProperty )* ( INDENT property ( NEWLINE property )* DEDENT )?\r
396                     {\r
397                     pushFollow(FOLLOW_resource_in_resourceDefinition1300);\r
398                     resource7=resource();\r
399 \r
400                     state._fsp--;\r
401                     if (state.failed) return retval;\r
402                     if ( state.backtracking==0 ) stream_resource.add(resource7.getTree());\r
403                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:232:7: ( localProperty )*\r
404                     loop4:\r
405                     do {\r
406                         int alt4=2;\r
407                         int LA4_0 = input.LA(1);\r
408 \r
409                         if ( (LA4_0==ID||LA4_0==URI||(LA4_0>=67 && LA4_0<=75)) ) {\r
410                             alt4=1;\r
411                         }\r
412 \r
413 \r
414                         switch (alt4) {\r
415                         case 1 :\r
416                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:232:7: localProperty\r
417                             {\r
418                             pushFollow(FOLLOW_localProperty_in_resourceDefinition1308);\r
419                             localProperty8=localProperty();\r
420 \r
421                             state._fsp--;\r
422                             if (state.failed) return retval;\r
423                             if ( state.backtracking==0 ) stream_localProperty.add(localProperty8.getTree());\r
424 \r
425                             }\r
426                             break;\r
427 \r
428                         default :\r
429                             break loop4;\r
430                         }\r
431                     } while (true);\r
432 \r
433                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:233:7: ( INDENT property ( NEWLINE property )* DEDENT )?\r
434                     int alt6=2;\r
435                     int LA6_0 = input.LA(1);\r
436 \r
437                     if ( (LA6_0==INDENT) ) {\r
438                         alt6=1;\r
439                     }\r
440                     switch (alt6) {\r
441                         case 1 :\r
442                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:233:8: INDENT property ( NEWLINE property )* DEDENT\r
443                             {\r
444                             INDENT9=(Token)match(input,INDENT,FOLLOW_INDENT_in_resourceDefinition1318); if (state.failed) return retval; \r
445                             if ( state.backtracking==0 ) stream_INDENT.add(INDENT9);\r
446 \r
447                             pushFollow(FOLLOW_property_in_resourceDefinition1320);\r
448                             property10=property();\r
449 \r
450                             state._fsp--;\r
451                             if (state.failed) return retval;\r
452                             if ( state.backtracking==0 ) stream_property.add(property10.getTree());\r
453                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:233:24: ( NEWLINE property )*\r
454                             loop5:\r
455                             do {\r
456                                 int alt5=2;\r
457                                 int LA5_0 = input.LA(1);\r
458 \r
459                                 if ( (LA5_0==NEWLINE) ) {\r
460                                     alt5=1;\r
461                                 }\r
462 \r
463 \r
464                                 switch (alt5) {\r
465                                 case 1 :\r
466                                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:233:25: NEWLINE property\r
467                                     {\r
468                                     NEWLINE11=(Token)match(input,NEWLINE,FOLLOW_NEWLINE_in_resourceDefinition1323); if (state.failed) return retval; \r
469                                     if ( state.backtracking==0 ) stream_NEWLINE.add(NEWLINE11);\r
470 \r
471                                     pushFollow(FOLLOW_property_in_resourceDefinition1325);\r
472                                     property12=property();\r
473 \r
474                                     state._fsp--;\r
475                                     if (state.failed) return retval;\r
476                                     if ( state.backtracking==0 ) stream_property.add(property12.getTree());\r
477 \r
478                                     }\r
479                                     break;\r
480 \r
481                                 default :\r
482                                     break loop5;\r
483                                 }\r
484                             } while (true);\r
485 \r
486                             DEDENT13=(Token)match(input,DEDENT,FOLLOW_DEDENT_in_resourceDefinition1329); if (state.failed) return retval; \r
487                             if ( state.backtracking==0 ) stream_DEDENT.add(DEDENT13);\r
488 \r
489 \r
490                             }\r
491                             break;\r
492 \r
493                     }\r
494 \r
495 \r
496 \r
497                     // AST REWRITE\r
498                     // elements: property, localProperty, resource\r
499                     // token labels: \r
500                     // rule labels: retval\r
501                     // token list labels: \r
502                     // rule list labels: \r
503                     // wildcard labels: \r
504                     if ( state.backtracking==0 ) {\r
505                     retval.tree = root_0;\r
506                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
507 \r
508                     root_0 = (CommonTree)adaptor.nil();\r
509                     // 234:5: -> ^( RESOURCE resource ( localProperty )* ( property )* )\r
510                     {\r
511                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:234:8: ^( RESOURCE resource ( localProperty )* ( property )* )\r
512                         {\r
513                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
514                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(RESOURCE, "RESOURCE"), root_1);\r
515 \r
516                         adaptor.addChild(root_1, stream_resource.nextTree());\r
517                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:234:28: ( localProperty )*\r
518                         while ( stream_localProperty.hasNext() ) {\r
519                             adaptor.addChild(root_1, stream_localProperty.nextTree());\r
520 \r
521                         }\r
522                         stream_localProperty.reset();\r
523                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:234:43: ( property )*\r
524                         while ( stream_property.hasNext() ) {\r
525                             adaptor.addChild(root_1, stream_property.nextTree());\r
526 \r
527                         }\r
528                         stream_property.reset();\r
529 \r
530                         adaptor.addChild(root_0, root_1);\r
531                         }\r
532 \r
533                     }\r
534 \r
535                     retval.tree = root_0;}\r
536                     }\r
537                     break;\r
538                 case 2 :\r
539                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:235:7: template\r
540                     {\r
541                     pushFollow(FOLLOW_template_in_resourceDefinition1358);\r
542                     template14=template();\r
543 \r
544                     state._fsp--;\r
545                     if (state.failed) return retval;\r
546                     if ( state.backtracking==0 ) stream_template.add(template14.getTree());\r
547 \r
548 \r
549                     // AST REWRITE\r
550                     // elements: template, template\r
551                     // token labels: \r
552                     // rule labels: retval\r
553                     // token list labels: \r
554                     // rule list labels: \r
555                     // wildcard labels: \r
556                     if ( state.backtracking==0 ) {\r
557                     retval.tree = root_0;\r
558                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
559 \r
560                     root_0 = (CommonTree)adaptor.nil();\r
561                     // 235:16: -> ^( RESOURCE ^( BLANK template ) template )\r
562                     {\r
563                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:235:19: ^( RESOURCE ^( BLANK template ) template )\r
564                         {\r
565                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
566                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(RESOURCE, "RESOURCE"), root_1);\r
567 \r
568                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:235:30: ^( BLANK template )\r
569                         {\r
570                         CommonTree root_2 = (CommonTree)adaptor.nil();\r
571                         root_2 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(BLANK, "BLANK"), root_2);\r
572 \r
573                         adaptor.addChild(root_2, stream_template.nextTree());\r
574 \r
575                         adaptor.addChild(root_1, root_2);\r
576                         }\r
577                         adaptor.addChild(root_1, stream_template.nextTree());\r
578 \r
579                         adaptor.addChild(root_0, root_1);\r
580                         }\r
581 \r
582                     }\r
583 \r
584                     retval.tree = root_0;}\r
585                     }\r
586                     break;\r
587 \r
588             }\r
589             retval.stop = input.LT(-1);\r
590 \r
591             if ( state.backtracking==0 ) {\r
592 \r
593             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
594             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
595             }\r
596         }\r
597         catch (RecognitionException re) {\r
598             reportError(re);\r
599             recover(input,re);\r
600         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
601 \r
602         }\r
603         finally {\r
604         }\r
605         return retval;\r
606     }\r
607     // $ANTLR end "resourceDefinition"\r
608 \r
609     public static class localProperty_return extends ParserRuleReturnScope {\r
610         CommonTree tree;\r
611         public Object getTree() { return tree; }\r
612     };\r
613 \r
614     // $ANTLR start "localProperty"\r
615     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:238:1: localProperty : relation resource -> ^( PROPERTY relation ^( RESOURCE resource ) ) ;\r
616     public final GraphParser.localProperty_return localProperty() throws RecognitionException {\r
617         GraphParser.localProperty_return retval = new GraphParser.localProperty_return();\r
618         retval.start = input.LT(1);\r
619 \r
620         CommonTree root_0 = null;\r
621 \r
622         GraphParser.relation_return relation15 = null;\r
623 \r
624         GraphParser.resource_return resource16 = null;\r
625 \r
626 \r
627         RewriteRuleSubtreeStream stream_relation=new RewriteRuleSubtreeStream(adaptor,"rule relation");\r
628         RewriteRuleSubtreeStream stream_resource=new RewriteRuleSubtreeStream(adaptor,"rule resource");\r
629         try {\r
630             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:239:5: ( relation resource -> ^( PROPERTY relation ^( RESOURCE resource ) ) )\r
631             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:239:7: relation resource\r
632             {\r
633             pushFollow(FOLLOW_relation_in_localProperty1393);\r
634             relation15=relation();\r
635 \r
636             state._fsp--;\r
637             if (state.failed) return retval;\r
638             if ( state.backtracking==0 ) stream_relation.add(relation15.getTree());\r
639             pushFollow(FOLLOW_resource_in_localProperty1395);\r
640             resource16=resource();\r
641 \r
642             state._fsp--;\r
643             if (state.failed) return retval;\r
644             if ( state.backtracking==0 ) stream_resource.add(resource16.getTree());\r
645 \r
646 \r
647             // AST REWRITE\r
648             // elements: resource, relation\r
649             // token labels: \r
650             // rule labels: retval\r
651             // token list labels: \r
652             // rule list labels: \r
653             // wildcard labels: \r
654             if ( state.backtracking==0 ) {\r
655             retval.tree = root_0;\r
656             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
657 \r
658             root_0 = (CommonTree)adaptor.nil();\r
659             // 240:5: -> ^( PROPERTY relation ^( RESOURCE resource ) )\r
660             {\r
661                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:240:8: ^( PROPERTY relation ^( RESOURCE resource ) )\r
662                 {\r
663                 CommonTree root_1 = (CommonTree)adaptor.nil();\r
664                 root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(PROPERTY, "PROPERTY"), root_1);\r
665 \r
666                 adaptor.addChild(root_1, stream_relation.nextTree());\r
667                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:240:28: ^( RESOURCE resource )\r
668                 {\r
669                 CommonTree root_2 = (CommonTree)adaptor.nil();\r
670                 root_2 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(RESOURCE, "RESOURCE"), root_2);\r
671 \r
672                 adaptor.addChild(root_2, stream_resource.nextTree());\r
673 \r
674                 adaptor.addChild(root_1, root_2);\r
675                 }\r
676 \r
677                 adaptor.addChild(root_0, root_1);\r
678                 }\r
679 \r
680             }\r
681 \r
682             retval.tree = root_0;}\r
683             }\r
684 \r
685             retval.stop = input.LT(-1);\r
686 \r
687             if ( state.backtracking==0 ) {\r
688 \r
689             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
690             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
691             }\r
692         }\r
693         catch (RecognitionException re) {\r
694             reportError(re);\r
695             recover(input,re);\r
696         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
697 \r
698         }\r
699         finally {\r
700         }\r
701         return retval;\r
702     }\r
703     // $ANTLR end "localProperty"\r
704 \r
705     public static class property_return extends ParserRuleReturnScope {\r
706         CommonTree tree;\r
707         public Object getTree() { return tree; }\r
708     };\r
709 \r
710     // $ANTLR start "property"\r
711     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:243:1: property : ( relation ( resourceDefinition -> ^( PROPERTY relation resourceDefinition ) | INDENT resourceDefinitions DEDENT -> ^( PROPERTY relation resourceDefinitions ) ) | template );\r
712     public final GraphParser.property_return property() throws RecognitionException {\r
713         GraphParser.property_return retval = new GraphParser.property_return();\r
714         retval.start = input.LT(1);\r
715 \r
716         CommonTree root_0 = null;\r
717 \r
718         Token INDENT19=null;\r
719         Token DEDENT21=null;\r
720         GraphParser.relation_return relation17 = null;\r
721 \r
722         GraphParser.resourceDefinition_return resourceDefinition18 = null;\r
723 \r
724         GraphParser.resourceDefinitions_return resourceDefinitions20 = null;\r
725 \r
726         GraphParser.template_return template22 = null;\r
727 \r
728 \r
729         CommonTree INDENT19_tree=null;\r
730         CommonTree DEDENT21_tree=null;\r
731         RewriteRuleTokenStream stream_DEDENT=new RewriteRuleTokenStream(adaptor,"token DEDENT");\r
732         RewriteRuleTokenStream stream_INDENT=new RewriteRuleTokenStream(adaptor,"token INDENT");\r
733         RewriteRuleSubtreeStream stream_resourceDefinition=new RewriteRuleSubtreeStream(adaptor,"rule resourceDefinition");\r
734         RewriteRuleSubtreeStream stream_relation=new RewriteRuleSubtreeStream(adaptor,"rule relation");\r
735         RewriteRuleSubtreeStream stream_resourceDefinitions=new RewriteRuleSubtreeStream(adaptor,"rule resourceDefinitions");\r
736         try {\r
737             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:244:5: ( relation ( resourceDefinition -> ^( PROPERTY relation resourceDefinition ) | INDENT resourceDefinitions DEDENT -> ^( PROPERTY relation resourceDefinitions ) ) | template )\r
738             int alt9=2;\r
739             int LA9_0 = input.LA(1);\r
740 \r
741             if ( (LA9_0==ID||LA9_0==URI||(LA9_0>=67 && LA9_0<=75)) ) {\r
742                 alt9=1;\r
743             }\r
744             else if ( (LA9_0==65) ) {\r
745                 alt9=2;\r
746             }\r
747             else {\r
748                 if (state.backtracking>0) {state.failed=true; return retval;}\r
749                 NoViableAltException nvae =\r
750                     new NoViableAltException("", 9, 0, input);\r
751 \r
752                 throw nvae;\r
753             }\r
754             switch (alt9) {\r
755                 case 1 :\r
756                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:244:7: relation ( resourceDefinition -> ^( PROPERTY relation resourceDefinition ) | INDENT resourceDefinitions DEDENT -> ^( PROPERTY relation resourceDefinitions ) )\r
757                     {\r
758                     pushFollow(FOLLOW_relation_in_property1434);\r
759                     relation17=relation();\r
760 \r
761                     state._fsp--;\r
762                     if (state.failed) return retval;\r
763                     if ( state.backtracking==0 ) stream_relation.add(relation17.getTree());\r
764                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:245:7: ( resourceDefinition -> ^( PROPERTY relation resourceDefinition ) | INDENT resourceDefinitions DEDENT -> ^( PROPERTY relation resourceDefinitions ) )\r
765                     int alt8=2;\r
766                     int LA8_0 = input.LA(1);\r
767 \r
768                     if ( (LA8_0==ID||LA8_0==LPAREN||LA8_0==LBRACKET||LA8_0==LCURLY||LA8_0==INT||LA8_0==FLOAT||(LA8_0>=STRING && LA8_0<=URI)||LA8_0==65||(LA8_0>=75 && LA8_0<=76)||(LA8_0>=79 && LA8_0<=80)) ) {\r
769                         alt8=1;\r
770                     }\r
771                     else if ( (LA8_0==INDENT) ) {\r
772                         alt8=2;\r
773                     }\r
774                     else {\r
775                         if (state.backtracking>0) {state.failed=true; return retval;}\r
776                         NoViableAltException nvae =\r
777                             new NoViableAltException("", 8, 0, input);\r
778 \r
779                         throw nvae;\r
780                     }\r
781                     switch (alt8) {\r
782                         case 1 :\r
783                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:245:9: resourceDefinition\r
784                             {\r
785                             pushFollow(FOLLOW_resourceDefinition_in_property1444);\r
786                             resourceDefinition18=resourceDefinition();\r
787 \r
788                             state._fsp--;\r
789                             if (state.failed) return retval;\r
790                             if ( state.backtracking==0 ) stream_resourceDefinition.add(resourceDefinition18.getTree());\r
791 \r
792 \r
793                             // AST REWRITE\r
794                             // elements: relation, resourceDefinition\r
795                             // token labels: \r
796                             // rule labels: retval\r
797                             // token list labels: \r
798                             // rule list labels: \r
799                             // wildcard labels: \r
800                             if ( state.backtracking==0 ) {\r
801                             retval.tree = root_0;\r
802                             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
803 \r
804                             root_0 = (CommonTree)adaptor.nil();\r
805                             // 245:28: -> ^( PROPERTY relation resourceDefinition )\r
806                             {\r
807                                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:245:31: ^( PROPERTY relation resourceDefinition )\r
808                                 {\r
809                                 CommonTree root_1 = (CommonTree)adaptor.nil();\r
810                                 root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(PROPERTY, "PROPERTY"), root_1);\r
811 \r
812                                 adaptor.addChild(root_1, stream_relation.nextTree());\r
813                                 adaptor.addChild(root_1, stream_resourceDefinition.nextTree());\r
814 \r
815                                 adaptor.addChild(root_0, root_1);\r
816                                 }\r
817 \r
818                             }\r
819 \r
820                             retval.tree = root_0;}\r
821                             }\r
822                             break;\r
823                         case 2 :\r
824                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:246:9: INDENT resourceDefinitions DEDENT\r
825                             {\r
826                             INDENT19=(Token)match(input,INDENT,FOLLOW_INDENT_in_property1464); if (state.failed) return retval; \r
827                             if ( state.backtracking==0 ) stream_INDENT.add(INDENT19);\r
828 \r
829                             pushFollow(FOLLOW_resourceDefinitions_in_property1466);\r
830                             resourceDefinitions20=resourceDefinitions();\r
831 \r
832                             state._fsp--;\r
833                             if (state.failed) return retval;\r
834                             if ( state.backtracking==0 ) stream_resourceDefinitions.add(resourceDefinitions20.getTree());\r
835                             DEDENT21=(Token)match(input,DEDENT,FOLLOW_DEDENT_in_property1468); if (state.failed) return retval; \r
836                             if ( state.backtracking==0 ) stream_DEDENT.add(DEDENT21);\r
837 \r
838 \r
839 \r
840                             // AST REWRITE\r
841                             // elements: relation, resourceDefinitions\r
842                             // token labels: \r
843                             // rule labels: retval\r
844                             // token list labels: \r
845                             // rule list labels: \r
846                             // wildcard labels: \r
847                             if ( state.backtracking==0 ) {\r
848                             retval.tree = root_0;\r
849                             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
850 \r
851                             root_0 = (CommonTree)adaptor.nil();\r
852                             // 246:43: -> ^( PROPERTY relation resourceDefinitions )\r
853                             {\r
854                                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:246:46: ^( PROPERTY relation resourceDefinitions )\r
855                                 {\r
856                                 CommonTree root_1 = (CommonTree)adaptor.nil();\r
857                                 root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(PROPERTY, "PROPERTY"), root_1);\r
858 \r
859                                 adaptor.addChild(root_1, stream_relation.nextTree());\r
860                                 adaptor.addChild(root_1, stream_resourceDefinitions.nextTree());\r
861 \r
862                                 adaptor.addChild(root_0, root_1);\r
863                                 }\r
864 \r
865                             }\r
866 \r
867                             retval.tree = root_0;}\r
868                             }\r
869                             break;\r
870 \r
871                     }\r
872 \r
873 \r
874                     }\r
875                     break;\r
876                 case 2 :\r
877                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:248:7: template\r
878                     {\r
879                     root_0 = (CommonTree)adaptor.nil();\r
880 \r
881                     pushFollow(FOLLOW_template_in_property1494);\r
882                     template22=template();\r
883 \r
884                     state._fsp--;\r
885                     if (state.failed) return retval;\r
886                     if ( state.backtracking==0 ) adaptor.addChild(root_0, template22.getTree());\r
887 \r
888                     }\r
889                     break;\r
890 \r
891             }\r
892             retval.stop = input.LT(-1);\r
893 \r
894             if ( state.backtracking==0 ) {\r
895 \r
896             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
897             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
898             }\r
899         }\r
900         catch (RecognitionException re) {\r
901             reportError(re);\r
902             recover(input,re);\r
903         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
904 \r
905         }\r
906         finally {\r
907         }\r
908         return retval;\r
909     }\r
910     // $ANTLR end "property"\r
911 \r
912     public static class template_return extends ParserRuleReturnScope {\r
913         CommonTree tree;\r
914         public Object getTree() { return tree; }\r
915     };\r
916 \r
917     // $ANTLR start "template"\r
918     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:251:1: template : '@' ({...}? => ID ( resource )+ INDENT resourceDefinitions DEDENT -> ^( TEMPLATE_DEFINITION ( resource )+ resourceDefinitions ) | ( resource )+ ( INDENT resourceDefinitions DEDENT )? -> ^( TEMPLATE_INSTANCE ( resource )+ ( resourceDefinitions )? ) ) ;\r
919     public final GraphParser.template_return template() throws RecognitionException {\r
920         GraphParser.template_return retval = new GraphParser.template_return();\r
921         retval.start = input.LT(1);\r
922 \r
923         CommonTree root_0 = null;\r
924 \r
925         Token char_literal23=null;\r
926         Token ID24=null;\r
927         Token INDENT26=null;\r
928         Token DEDENT28=null;\r
929         Token INDENT30=null;\r
930         Token DEDENT32=null;\r
931         GraphParser.resource_return resource25 = null;\r
932 \r
933         GraphParser.resourceDefinitions_return resourceDefinitions27 = null;\r
934 \r
935         GraphParser.resource_return resource29 = null;\r
936 \r
937         GraphParser.resourceDefinitions_return resourceDefinitions31 = null;\r
938 \r
939 \r
940         CommonTree char_literal23_tree=null;\r
941         CommonTree ID24_tree=null;\r
942         CommonTree INDENT26_tree=null;\r
943         CommonTree DEDENT28_tree=null;\r
944         CommonTree INDENT30_tree=null;\r
945         CommonTree DEDENT32_tree=null;\r
946         RewriteRuleTokenStream stream_DEDENT=new RewriteRuleTokenStream(adaptor,"token DEDENT");\r
947         RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");\r
948         RewriteRuleTokenStream stream_65=new RewriteRuleTokenStream(adaptor,"token 65");\r
949         RewriteRuleTokenStream stream_INDENT=new RewriteRuleTokenStream(adaptor,"token INDENT");\r
950         RewriteRuleSubtreeStream stream_resource=new RewriteRuleSubtreeStream(adaptor,"rule resource");\r
951         RewriteRuleSubtreeStream stream_resourceDefinitions=new RewriteRuleSubtreeStream(adaptor,"rule resourceDefinitions");\r
952         try {\r
953             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:252:5: ( '@' ({...}? => ID ( resource )+ INDENT resourceDefinitions DEDENT -> ^( TEMPLATE_DEFINITION ( resource )+ resourceDefinitions ) | ( resource )+ ( INDENT resourceDefinitions DEDENT )? -> ^( TEMPLATE_INSTANCE ( resource )+ ( resourceDefinitions )? ) ) )\r
954             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:252:7: '@' ({...}? => ID ( resource )+ INDENT resourceDefinitions DEDENT -> ^( TEMPLATE_DEFINITION ( resource )+ resourceDefinitions ) | ( resource )+ ( INDENT resourceDefinitions DEDENT )? -> ^( TEMPLATE_INSTANCE ( resource )+ ( resourceDefinitions )? ) )\r
955             {\r
956             char_literal23=(Token)match(input,65,FOLLOW_65_in_template1515); if (state.failed) return retval; \r
957             if ( state.backtracking==0 ) stream_65.add(char_literal23);\r
958 \r
959             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:253:5: ({...}? => ID ( resource )+ INDENT resourceDefinitions DEDENT -> ^( TEMPLATE_DEFINITION ( resource )+ resourceDefinitions ) | ( resource )+ ( INDENT resourceDefinitions DEDENT )? -> ^( TEMPLATE_INSTANCE ( resource )+ ( resourceDefinitions )? ) )\r
960             int alt13=2;\r
961             alt13 = dfa13.predict(input);\r
962             switch (alt13) {\r
963                 case 1 :\r
964                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:253:7: {...}? => ID ( resource )+ INDENT resourceDefinitions DEDENT\r
965                     {\r
966                     if ( !((input.LT(1).getText().equals("template"))) ) {\r
967                         if (state.backtracking>0) {state.failed=true; return retval;}\r
968                         throw new FailedPredicateException(input, "template", "input.LT(1).getText().equals(\"template\")");\r
969                     }\r
970                     ID24=(Token)match(input,ID,FOLLOW_ID_in_template1533); if (state.failed) return retval; \r
971                     if ( state.backtracking==0 ) stream_ID.add(ID24);\r
972 \r
973                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:254:10: ( resource )+\r
974                     int cnt10=0;\r
975                     loop10:\r
976                     do {\r
977                         int alt10=2;\r
978                         int LA10_0 = input.LA(1);\r
979 \r
980                         if ( (LA10_0==ID||LA10_0==LPAREN||LA10_0==LBRACKET||LA10_0==LCURLY||LA10_0==INT||LA10_0==FLOAT||(LA10_0>=STRING && LA10_0<=URI)||(LA10_0>=75 && LA10_0<=76)||(LA10_0>=79 && LA10_0<=80)) ) {\r
981                             alt10=1;\r
982                         }\r
983 \r
984 \r
985                         switch (alt10) {\r
986                         case 1 :\r
987                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:254:10: resource\r
988                             {\r
989                             pushFollow(FOLLOW_resource_in_template1535);\r
990                             resource25=resource();\r
991 \r
992                             state._fsp--;\r
993                             if (state.failed) return retval;\r
994                             if ( state.backtracking==0 ) stream_resource.add(resource25.getTree());\r
995 \r
996                             }\r
997                             break;\r
998 \r
999                         default :\r
1000                             if ( cnt10 >= 1 ) break loop10;\r
1001                             if (state.backtracking>0) {state.failed=true; return retval;}\r
1002                                 EarlyExitException eee =\r
1003                                     new EarlyExitException(10, input);\r
1004                                 throw eee;\r
1005                         }\r
1006                         cnt10++;\r
1007                     } while (true);\r
1008 \r
1009                     INDENT26=(Token)match(input,INDENT,FOLLOW_INDENT_in_template1545); if (state.failed) return retval; \r
1010                     if ( state.backtracking==0 ) stream_INDENT.add(INDENT26);\r
1011 \r
1012                     pushFollow(FOLLOW_resourceDefinitions_in_template1547);\r
1013                     resourceDefinitions27=resourceDefinitions();\r
1014 \r
1015                     state._fsp--;\r
1016                     if (state.failed) return retval;\r
1017                     if ( state.backtracking==0 ) stream_resourceDefinitions.add(resourceDefinitions27.getTree());\r
1018                     DEDENT28=(Token)match(input,DEDENT,FOLLOW_DEDENT_in_template1549); if (state.failed) return retval; \r
1019                     if ( state.backtracking==0 ) stream_DEDENT.add(DEDENT28);\r
1020 \r
1021 \r
1022 \r
1023                     // AST REWRITE\r
1024                     // elements: resourceDefinitions, resource\r
1025                     // token labels: \r
1026                     // rule labels: retval\r
1027                     // token list labels: \r
1028                     // rule list labels: \r
1029                     // wildcard labels: \r
1030                     if ( state.backtracking==0 ) {\r
1031                     retval.tree = root_0;\r
1032                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1033 \r
1034                     root_0 = (CommonTree)adaptor.nil();\r
1035                     // 256:7: -> ^( TEMPLATE_DEFINITION ( resource )+ resourceDefinitions )\r
1036                     {\r
1037                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:256:10: ^( TEMPLATE_DEFINITION ( resource )+ resourceDefinitions )\r
1038                         {\r
1039                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
1040                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(TEMPLATE_DEFINITION, "TEMPLATE_DEFINITION"), root_1);\r
1041 \r
1042                         if ( !(stream_resource.hasNext()) ) {\r
1043                             throw new RewriteEarlyExitException();\r
1044                         }\r
1045                         while ( stream_resource.hasNext() ) {\r
1046                             adaptor.addChild(root_1, stream_resource.nextTree());\r
1047 \r
1048                         }\r
1049                         stream_resource.reset();\r
1050                         adaptor.addChild(root_1, stream_resourceDefinitions.nextTree());\r
1051 \r
1052                         adaptor.addChild(root_0, root_1);\r
1053                         }\r
1054 \r
1055                     }\r
1056 \r
1057                     retval.tree = root_0;}\r
1058                     }\r
1059                     break;\r
1060                 case 2 :\r
1061                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:257:7: ( resource )+ ( INDENT resourceDefinitions DEDENT )?\r
1062                     {\r
1063                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:257:7: ( resource )+\r
1064                     int cnt11=0;\r
1065                     loop11:\r
1066                     do {\r
1067                         int alt11=2;\r
1068                         int LA11_0 = input.LA(1);\r
1069 \r
1070                         if ( (LA11_0==ID||LA11_0==LPAREN||LA11_0==LBRACKET||LA11_0==LCURLY||LA11_0==INT||LA11_0==FLOAT||(LA11_0>=STRING && LA11_0<=URI)||(LA11_0>=75 && LA11_0<=76)||(LA11_0>=79 && LA11_0<=80)) ) {\r
1071                             alt11=1;\r
1072                         }\r
1073 \r
1074 \r
1075                         switch (alt11) {\r
1076                         case 1 :\r
1077                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:257:7: resource\r
1078                             {\r
1079                             pushFollow(FOLLOW_resource_in_template1574);\r
1080                             resource29=resource();\r
1081 \r
1082                             state._fsp--;\r
1083                             if (state.failed) return retval;\r
1084                             if ( state.backtracking==0 ) stream_resource.add(resource29.getTree());\r
1085 \r
1086                             }\r
1087                             break;\r
1088 \r
1089                         default :\r
1090                             if ( cnt11 >= 1 ) break loop11;\r
1091                             if (state.backtracking>0) {state.failed=true; return retval;}\r
1092                                 EarlyExitException eee =\r
1093                                     new EarlyExitException(11, input);\r
1094                                 throw eee;\r
1095                         }\r
1096                         cnt11++;\r
1097                     } while (true);\r
1098 \r
1099                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:258:7: ( INDENT resourceDefinitions DEDENT )?\r
1100                     int alt12=2;\r
1101                     int LA12_0 = input.LA(1);\r
1102 \r
1103                     if ( (LA12_0==INDENT) ) {\r
1104                         alt12=1;\r
1105                     }\r
1106                     switch (alt12) {\r
1107                         case 1 :\r
1108                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:258:8: INDENT resourceDefinitions DEDENT\r
1109                             {\r
1110                             INDENT30=(Token)match(input,INDENT,FOLLOW_INDENT_in_template1585); if (state.failed) return retval; \r
1111                             if ( state.backtracking==0 ) stream_INDENT.add(INDENT30);\r
1112 \r
1113                             pushFollow(FOLLOW_resourceDefinitions_in_template1587);\r
1114                             resourceDefinitions31=resourceDefinitions();\r
1115 \r
1116                             state._fsp--;\r
1117                             if (state.failed) return retval;\r
1118                             if ( state.backtracking==0 ) stream_resourceDefinitions.add(resourceDefinitions31.getTree());\r
1119                             DEDENT32=(Token)match(input,DEDENT,FOLLOW_DEDENT_in_template1589); if (state.failed) return retval; \r
1120                             if ( state.backtracking==0 ) stream_DEDENT.add(DEDENT32);\r
1121 \r
1122 \r
1123                             }\r
1124                             break;\r
1125 \r
1126                     }\r
1127 \r
1128 \r
1129 \r
1130                     // AST REWRITE\r
1131                     // elements: resource, resourceDefinitions\r
1132                     // token labels: \r
1133                     // rule labels: retval\r
1134                     // token list labels: \r
1135                     // rule list labels: \r
1136                     // wildcard labels: \r
1137                     if ( state.backtracking==0 ) {\r
1138                     retval.tree = root_0;\r
1139                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1140 \r
1141                     root_0 = (CommonTree)adaptor.nil();\r
1142                     // 259:7: -> ^( TEMPLATE_INSTANCE ( resource )+ ( resourceDefinitions )? )\r
1143                     {\r
1144                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:259:10: ^( TEMPLATE_INSTANCE ( resource )+ ( resourceDefinitions )? )\r
1145                         {\r
1146                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
1147                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(TEMPLATE_INSTANCE, "TEMPLATE_INSTANCE"), root_1);\r
1148 \r
1149                         if ( !(stream_resource.hasNext()) ) {\r
1150                             throw new RewriteEarlyExitException();\r
1151                         }\r
1152                         while ( stream_resource.hasNext() ) {\r
1153                             adaptor.addChild(root_1, stream_resource.nextTree());\r
1154 \r
1155                         }\r
1156                         stream_resource.reset();\r
1157                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:259:40: ( resourceDefinitions )?\r
1158                         if ( stream_resourceDefinitions.hasNext() ) {\r
1159                             adaptor.addChild(root_1, stream_resourceDefinitions.nextTree());\r
1160 \r
1161                         }\r
1162                         stream_resourceDefinitions.reset();\r
1163 \r
1164                         adaptor.addChild(root_0, root_1);\r
1165                         }\r
1166 \r
1167                     }\r
1168 \r
1169                     retval.tree = root_0;}\r
1170                     }\r
1171                     break;\r
1172 \r
1173             }\r
1174 \r
1175 \r
1176             }\r
1177 \r
1178             retval.stop = input.LT(-1);\r
1179 \r
1180             if ( state.backtracking==0 ) {\r
1181 \r
1182             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
1183             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
1184             }\r
1185         }\r
1186         catch (RecognitionException re) {\r
1187             reportError(re);\r
1188             recover(input,re);\r
1189         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
1190 \r
1191         }\r
1192         finally {\r
1193         }\r
1194         return retval;\r
1195     }\r
1196     // $ANTLR end "template"\r
1197 \r
1198     public static class relation_return extends ParserRuleReturnScope {\r
1199         CommonTree tree;\r
1200         public Object getTree() { return tree; }\r
1201     };\r
1202 \r
1203     // $ANTLR start "relation"\r
1204     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:267:1: relation : ( ( ID -> ID ) ( '.' ID -> ^( REF $relation ID ) )* | URI | '<T' -> INHERITS | '<R' -> SUBRELATION_OF | '<--' -> HAS_DOMAIN | '-->' -> HAS_RANGE | '==>' -> REQUIRES_VALUE_TYPE | '>--' -> DOMAIN_OF | ':' -> INSTANCE_OF | '=' -> EQUALS | '%' ID -> ^( VARIABLE ID ) );\r
1205     public final GraphParser.relation_return relation() throws RecognitionException {\r
1206         GraphParser.relation_return retval = new GraphParser.relation_return();\r
1207         retval.start = input.LT(1);\r
1208 \r
1209         CommonTree root_0 = null;\r
1210 \r
1211         Token ID33=null;\r
1212         Token char_literal34=null;\r
1213         Token ID35=null;\r
1214         Token URI36=null;\r
1215         Token string_literal37=null;\r
1216         Token string_literal38=null;\r
1217         Token string_literal39=null;\r
1218         Token string_literal40=null;\r
1219         Token string_literal41=null;\r
1220         Token string_literal42=null;\r
1221         Token char_literal43=null;\r
1222         Token char_literal44=null;\r
1223         Token char_literal45=null;\r
1224         Token ID46=null;\r
1225 \r
1226         CommonTree ID33_tree=null;\r
1227         CommonTree char_literal34_tree=null;\r
1228         CommonTree ID35_tree=null;\r
1229         CommonTree URI36_tree=null;\r
1230         CommonTree string_literal37_tree=null;\r
1231         CommonTree string_literal38_tree=null;\r
1232         CommonTree string_literal39_tree=null;\r
1233         CommonTree string_literal40_tree=null;\r
1234         CommonTree string_literal41_tree=null;\r
1235         CommonTree string_literal42_tree=null;\r
1236         CommonTree char_literal43_tree=null;\r
1237         CommonTree char_literal44_tree=null;\r
1238         CommonTree char_literal45_tree=null;\r
1239         CommonTree ID46_tree=null;\r
1240         RewriteRuleTokenStream stream_67=new RewriteRuleTokenStream(adaptor,"token 67");\r
1241         RewriteRuleTokenStream stream_66=new RewriteRuleTokenStream(adaptor,"token 66");\r
1242         RewriteRuleTokenStream stream_69=new RewriteRuleTokenStream(adaptor,"token 69");\r
1243         RewriteRuleTokenStream stream_68=new RewriteRuleTokenStream(adaptor,"token 68");\r
1244         RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");\r
1245         RewriteRuleTokenStream stream_70=new RewriteRuleTokenStream(adaptor,"token 70");\r
1246         RewriteRuleTokenStream stream_71=new RewriteRuleTokenStream(adaptor,"token 71");\r
1247         RewriteRuleTokenStream stream_72=new RewriteRuleTokenStream(adaptor,"token 72");\r
1248         RewriteRuleTokenStream stream_73=new RewriteRuleTokenStream(adaptor,"token 73");\r
1249         RewriteRuleTokenStream stream_74=new RewriteRuleTokenStream(adaptor,"token 74");\r
1250         RewriteRuleTokenStream stream_75=new RewriteRuleTokenStream(adaptor,"token 75");\r
1251 \r
1252         try {\r
1253             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:268:5: ( ( ID -> ID ) ( '.' ID -> ^( REF $relation ID ) )* | URI | '<T' -> INHERITS | '<R' -> SUBRELATION_OF | '<--' -> HAS_DOMAIN | '-->' -> HAS_RANGE | '==>' -> REQUIRES_VALUE_TYPE | '>--' -> DOMAIN_OF | ':' -> INSTANCE_OF | '=' -> EQUALS | '%' ID -> ^( VARIABLE ID ) )\r
1254             int alt15=11;\r
1255             switch ( input.LA(1) ) {\r
1256             case ID:\r
1257                 {\r
1258                 alt15=1;\r
1259                 }\r
1260                 break;\r
1261             case URI:\r
1262                 {\r
1263                 alt15=2;\r
1264                 }\r
1265                 break;\r
1266             case 67:\r
1267                 {\r
1268                 alt15=3;\r
1269                 }\r
1270                 break;\r
1271             case 68:\r
1272                 {\r
1273                 alt15=4;\r
1274                 }\r
1275                 break;\r
1276             case 69:\r
1277                 {\r
1278                 alt15=5;\r
1279                 }\r
1280                 break;\r
1281             case 70:\r
1282                 {\r
1283                 alt15=6;\r
1284                 }\r
1285                 break;\r
1286             case 71:\r
1287                 {\r
1288                 alt15=7;\r
1289                 }\r
1290                 break;\r
1291             case 72:\r
1292                 {\r
1293                 alt15=8;\r
1294                 }\r
1295                 break;\r
1296             case 73:\r
1297                 {\r
1298                 alt15=9;\r
1299                 }\r
1300                 break;\r
1301             case 74:\r
1302                 {\r
1303                 alt15=10;\r
1304                 }\r
1305                 break;\r
1306             case 75:\r
1307                 {\r
1308                 alt15=11;\r
1309                 }\r
1310                 break;\r
1311             default:\r
1312                 if (state.backtracking>0) {state.failed=true; return retval;}\r
1313                 NoViableAltException nvae =\r
1314                     new NoViableAltException("", 15, 0, input);\r
1315 \r
1316                 throw nvae;\r
1317             }\r
1318 \r
1319             switch (alt15) {\r
1320                 case 1 :\r
1321                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:268:7: ( ID -> ID ) ( '.' ID -> ^( REF $relation ID ) )*\r
1322                     {\r
1323                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:268:7: ( ID -> ID )\r
1324                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:268:9: ID\r
1325                     {\r
1326                     ID33=(Token)match(input,ID,FOLLOW_ID_in_relation1643); if (state.failed) return retval; \r
1327                     if ( state.backtracking==0 ) stream_ID.add(ID33);\r
1328 \r
1329 \r
1330 \r
1331                     // AST REWRITE\r
1332                     // elements: ID\r
1333                     // token labels: \r
1334                     // rule labels: retval\r
1335                     // token list labels: \r
1336                     // rule list labels: \r
1337                     // wildcard labels: \r
1338                     if ( state.backtracking==0 ) {\r
1339                     retval.tree = root_0;\r
1340                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1341 \r
1342                     root_0 = (CommonTree)adaptor.nil();\r
1343                     // 268:12: -> ID\r
1344                     {\r
1345                         adaptor.addChild(root_0, stream_ID.nextNode());\r
1346 \r
1347                     }\r
1348 \r
1349                     retval.tree = root_0;}\r
1350                     }\r
1351 \r
1352                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:269:7: ( '.' ID -> ^( REF $relation ID ) )*\r
1353                     loop14:\r
1354                     do {\r
1355                         int alt14=2;\r
1356                         int LA14_0 = input.LA(1);\r
1357 \r
1358                         if ( (LA14_0==66) ) {\r
1359                             alt14=1;\r
1360                         }\r
1361 \r
1362 \r
1363                         switch (alt14) {\r
1364                         case 1 :\r
1365                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:269:8: '.' ID\r
1366                             {\r
1367                             char_literal34=(Token)match(input,66,FOLLOW_66_in_relation1658); if (state.failed) return retval; \r
1368                             if ( state.backtracking==0 ) stream_66.add(char_literal34);\r
1369 \r
1370                             ID35=(Token)match(input,ID,FOLLOW_ID_in_relation1660); if (state.failed) return retval; \r
1371                             if ( state.backtracking==0 ) stream_ID.add(ID35);\r
1372 \r
1373 \r
1374 \r
1375                             // AST REWRITE\r
1376                             // elements: ID, relation\r
1377                             // token labels: \r
1378                             // rule labels: retval\r
1379                             // token list labels: \r
1380                             // rule list labels: \r
1381                             // wildcard labels: \r
1382                             if ( state.backtracking==0 ) {\r
1383                             retval.tree = root_0;\r
1384                             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1385 \r
1386                             root_0 = (CommonTree)adaptor.nil();\r
1387                             // 269:15: -> ^( REF $relation ID )\r
1388                             {\r
1389                                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:269:18: ^( REF $relation ID )\r
1390                                 {\r
1391                                 CommonTree root_1 = (CommonTree)adaptor.nil();\r
1392                                 root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(REF, "REF"), root_1);\r
1393 \r
1394                                 adaptor.addChild(root_1, stream_retval.nextTree());\r
1395                                 adaptor.addChild(root_1, stream_ID.nextNode());\r
1396 \r
1397                                 adaptor.addChild(root_0, root_1);\r
1398                                 }\r
1399 \r
1400                             }\r
1401 \r
1402                             retval.tree = root_0;}\r
1403                             }\r
1404                             break;\r
1405 \r
1406                         default :\r
1407                             break loop14;\r
1408                         }\r
1409                     } while (true);\r
1410 \r
1411 \r
1412                     }\r
1413                     break;\r
1414                 case 2 :\r
1415                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:270:7: URI\r
1416                     {\r
1417                     root_0 = (CommonTree)adaptor.nil();\r
1418 \r
1419                     URI36=(Token)match(input,URI,FOLLOW_URI_in_relation1681); if (state.failed) return retval;\r
1420                     if ( state.backtracking==0 ) {\r
1421                     URI36_tree = (CommonTree)adaptor.create(URI36);\r
1422                     adaptor.addChild(root_0, URI36_tree);\r
1423                     }\r
1424 \r
1425                     }\r
1426                     break;\r
1427                 case 3 :\r
1428                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:271:7: '<T'\r
1429                     {\r
1430                     string_literal37=(Token)match(input,67,FOLLOW_67_in_relation1689); if (state.failed) return retval; \r
1431                     if ( state.backtracking==0 ) stream_67.add(string_literal37);\r
1432 \r
1433 \r
1434 \r
1435                     // AST REWRITE\r
1436                     // elements: \r
1437                     // token labels: \r
1438                     // rule labels: retval\r
1439                     // token list labels: \r
1440                     // rule list labels: \r
1441                     // wildcard labels: \r
1442                     if ( state.backtracking==0 ) {\r
1443                     retval.tree = root_0;\r
1444                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1445 \r
1446                     root_0 = (CommonTree)adaptor.nil();\r
1447                     // 271:12: -> INHERITS\r
1448                     {\r
1449                         adaptor.addChild(root_0, (CommonTree)adaptor.create(INHERITS, "INHERITS"));\r
1450 \r
1451                     }\r
1452 \r
1453                     retval.tree = root_0;}\r
1454                     }\r
1455                     break;\r
1456                 case 4 :\r
1457                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:272:7: '<R'\r
1458                     {\r
1459                     string_literal38=(Token)match(input,68,FOLLOW_68_in_relation1701); if (state.failed) return retval; \r
1460                     if ( state.backtracking==0 ) stream_68.add(string_literal38);\r
1461 \r
1462 \r
1463 \r
1464                     // AST REWRITE\r
1465                     // elements: \r
1466                     // token labels: \r
1467                     // rule labels: retval\r
1468                     // token list labels: \r
1469                     // rule list labels: \r
1470                     // wildcard labels: \r
1471                     if ( state.backtracking==0 ) {\r
1472                     retval.tree = root_0;\r
1473                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1474 \r
1475                     root_0 = (CommonTree)adaptor.nil();\r
1476                     // 272:12: -> SUBRELATION_OF\r
1477                     {\r
1478                         adaptor.addChild(root_0, (CommonTree)adaptor.create(SUBRELATION_OF, "SUBRELATION_OF"));\r
1479 \r
1480                     }\r
1481 \r
1482                     retval.tree = root_0;}\r
1483                     }\r
1484                     break;\r
1485                 case 5 :\r
1486                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:273:7: '<--'\r
1487                     {\r
1488                     string_literal39=(Token)match(input,69,FOLLOW_69_in_relation1713); if (state.failed) return retval; \r
1489                     if ( state.backtracking==0 ) stream_69.add(string_literal39);\r
1490 \r
1491 \r
1492 \r
1493                     // AST REWRITE\r
1494                     // elements: \r
1495                     // token labels: \r
1496                     // rule labels: retval\r
1497                     // token list labels: \r
1498                     // rule list labels: \r
1499                     // wildcard labels: \r
1500                     if ( state.backtracking==0 ) {\r
1501                     retval.tree = root_0;\r
1502                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1503 \r
1504                     root_0 = (CommonTree)adaptor.nil();\r
1505                     // 273:13: -> HAS_DOMAIN\r
1506                     {\r
1507                         adaptor.addChild(root_0, (CommonTree)adaptor.create(HAS_DOMAIN, "HAS_DOMAIN"));\r
1508 \r
1509                     }\r
1510 \r
1511                     retval.tree = root_0;}\r
1512                     }\r
1513                     break;\r
1514                 case 6 :\r
1515                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:274:7: '-->'\r
1516                     {\r
1517                     string_literal40=(Token)match(input,70,FOLLOW_70_in_relation1725); if (state.failed) return retval; \r
1518                     if ( state.backtracking==0 ) stream_70.add(string_literal40);\r
1519 \r
1520 \r
1521 \r
1522                     // AST REWRITE\r
1523                     // elements: \r
1524                     // token labels: \r
1525                     // rule labels: retval\r
1526                     // token list labels: \r
1527                     // rule list labels: \r
1528                     // wildcard labels: \r
1529                     if ( state.backtracking==0 ) {\r
1530                     retval.tree = root_0;\r
1531                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1532 \r
1533                     root_0 = (CommonTree)adaptor.nil();\r
1534                     // 274:13: -> HAS_RANGE\r
1535                     {\r
1536                         adaptor.addChild(root_0, (CommonTree)adaptor.create(HAS_RANGE, "HAS_RANGE"));\r
1537 \r
1538                     }\r
1539 \r
1540                     retval.tree = root_0;}\r
1541                     }\r
1542                     break;\r
1543                 case 7 :\r
1544                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:275:7: '==>'\r
1545                     {\r
1546                     string_literal41=(Token)match(input,71,FOLLOW_71_in_relation1737); if (state.failed) return retval; \r
1547                     if ( state.backtracking==0 ) stream_71.add(string_literal41);\r
1548 \r
1549 \r
1550 \r
1551                     // AST REWRITE\r
1552                     // elements: \r
1553                     // token labels: \r
1554                     // rule labels: retval\r
1555                     // token list labels: \r
1556                     // rule list labels: \r
1557                     // wildcard labels: \r
1558                     if ( state.backtracking==0 ) {\r
1559                     retval.tree = root_0;\r
1560                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1561 \r
1562                     root_0 = (CommonTree)adaptor.nil();\r
1563                     // 275:13: -> REQUIRES_VALUE_TYPE\r
1564                     {\r
1565                         adaptor.addChild(root_0, (CommonTree)adaptor.create(REQUIRES_VALUE_TYPE, "REQUIRES_VALUE_TYPE"));\r
1566 \r
1567                     }\r
1568 \r
1569                     retval.tree = root_0;}\r
1570                     }\r
1571                     break;\r
1572                 case 8 :\r
1573                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:276:7: '>--'\r
1574                     {\r
1575                     string_literal42=(Token)match(input,72,FOLLOW_72_in_relation1749); if (state.failed) return retval; \r
1576                     if ( state.backtracking==0 ) stream_72.add(string_literal42);\r
1577 \r
1578 \r
1579 \r
1580                     // AST REWRITE\r
1581                     // elements: \r
1582                     // token labels: \r
1583                     // rule labels: retval\r
1584                     // token list labels: \r
1585                     // rule list labels: \r
1586                     // wildcard labels: \r
1587                     if ( state.backtracking==0 ) {\r
1588                     retval.tree = root_0;\r
1589                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1590 \r
1591                     root_0 = (CommonTree)adaptor.nil();\r
1592                     // 276:13: -> DOMAIN_OF\r
1593                     {\r
1594                         adaptor.addChild(root_0, (CommonTree)adaptor.create(DOMAIN_OF, "DOMAIN_OF"));\r
1595 \r
1596                     }\r
1597 \r
1598                     retval.tree = root_0;}\r
1599                     }\r
1600                     break;\r
1601                 case 9 :\r
1602                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:277:7: ':'\r
1603                     {\r
1604                     char_literal43=(Token)match(input,73,FOLLOW_73_in_relation1765); if (state.failed) return retval; \r
1605                     if ( state.backtracking==0 ) stream_73.add(char_literal43);\r
1606 \r
1607 \r
1608 \r
1609                     // AST REWRITE\r
1610                     // elements: \r
1611                     // token labels: \r
1612                     // rule labels: retval\r
1613                     // token list labels: \r
1614                     // rule list labels: \r
1615                     // wildcard labels: \r
1616                     if ( state.backtracking==0 ) {\r
1617                     retval.tree = root_0;\r
1618                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1619 \r
1620                     root_0 = (CommonTree)adaptor.nil();\r
1621                     // 277:11: -> INSTANCE_OF\r
1622                     {\r
1623                         adaptor.addChild(root_0, (CommonTree)adaptor.create(INSTANCE_OF, "INSTANCE_OF"));\r
1624 \r
1625                     }\r
1626 \r
1627                     retval.tree = root_0;}\r
1628                     }\r
1629                     break;\r
1630                 case 10 :\r
1631                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:278:7: '='\r
1632                     {\r
1633                     char_literal44=(Token)match(input,74,FOLLOW_74_in_relation1777); if (state.failed) return retval; \r
1634                     if ( state.backtracking==0 ) stream_74.add(char_literal44);\r
1635 \r
1636 \r
1637 \r
1638                     // AST REWRITE\r
1639                     // elements: \r
1640                     // token labels: \r
1641                     // rule labels: retval\r
1642                     // token list labels: \r
1643                     // rule list labels: \r
1644                     // wildcard labels: \r
1645                     if ( state.backtracking==0 ) {\r
1646                     retval.tree = root_0;\r
1647                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1648 \r
1649                     root_0 = (CommonTree)adaptor.nil();\r
1650                     // 278:11: -> EQUALS\r
1651                     {\r
1652                         adaptor.addChild(root_0, (CommonTree)adaptor.create(EQUALS, "EQUALS"));\r
1653 \r
1654                     }\r
1655 \r
1656                     retval.tree = root_0;}\r
1657                     }\r
1658                     break;\r
1659                 case 11 :\r
1660                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:279:7: '%' ID\r
1661                     {\r
1662                     char_literal45=(Token)match(input,75,FOLLOW_75_in_relation1789); if (state.failed) return retval; \r
1663                     if ( state.backtracking==0 ) stream_75.add(char_literal45);\r
1664 \r
1665                     ID46=(Token)match(input,ID,FOLLOW_ID_in_relation1791); if (state.failed) return retval; \r
1666                     if ( state.backtracking==0 ) stream_ID.add(ID46);\r
1667 \r
1668 \r
1669 \r
1670                     // AST REWRITE\r
1671                     // elements: ID\r
1672                     // token labels: \r
1673                     // rule labels: retval\r
1674                     // token list labels: \r
1675                     // rule list labels: \r
1676                     // wildcard labels: \r
1677                     if ( state.backtracking==0 ) {\r
1678                     retval.tree = root_0;\r
1679                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1680 \r
1681                     root_0 = (CommonTree)adaptor.nil();\r
1682                     // 279:14: -> ^( VARIABLE ID )\r
1683                     {\r
1684                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:279:17: ^( VARIABLE ID )\r
1685                         {\r
1686                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
1687                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(VARIABLE, "VARIABLE"), root_1);\r
1688 \r
1689                         adaptor.addChild(root_1, stream_ID.nextNode());\r
1690 \r
1691                         adaptor.addChild(root_0, root_1);\r
1692                         }\r
1693 \r
1694                     }\r
1695 \r
1696                     retval.tree = root_0;}\r
1697                     }\r
1698                     break;\r
1699 \r
1700             }\r
1701             retval.stop = input.LT(-1);\r
1702 \r
1703             if ( state.backtracking==0 ) {\r
1704 \r
1705             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
1706             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
1707             }\r
1708         }\r
1709         catch (RecognitionException re) {\r
1710             reportError(re);\r
1711             recover(input,re);\r
1712         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
1713 \r
1714         }\r
1715         finally {\r
1716         }\r
1717         return retval;\r
1718     }\r
1719     // $ANTLR end "relation"\r
1720 \r
1721     public static class resource_return extends ParserRuleReturnScope {\r
1722         CommonTree tree;\r
1723         public Object getTree() { return tree; }\r
1724     };\r
1725 \r
1726     // $ANTLR start "resource"\r
1727     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:282:1: resource : ( ({...}? => ID -> ^( BLANK ID ) | ID -> ID ) ( '.' ( ID -> ^( REF $resource ID ) | STRING -> ^( REF $resource STRING ) ) )* | URI | simpleValue -> ^( EMBEDDED_VALUE simpleValue ) | '$' basicType -> ^( EMBEDDED_TYPE basicType ) | '%' ID -> ^( VARIABLE ID ) );\r
1728     public final GraphParser.resource_return resource() throws RecognitionException {\r
1729         GraphParser.resource_return retval = new GraphParser.resource_return();\r
1730         retval.start = input.LT(1);\r
1731 \r
1732         CommonTree root_0 = null;\r
1733 \r
1734         Token ID47=null;\r
1735         Token ID48=null;\r
1736         Token char_literal49=null;\r
1737         Token ID50=null;\r
1738         Token STRING51=null;\r
1739         Token URI52=null;\r
1740         Token char_literal54=null;\r
1741         Token char_literal56=null;\r
1742         Token ID57=null;\r
1743         GraphParser.simpleValue_return simpleValue53 = null;\r
1744 \r
1745         GraphParser.basicType_return basicType55 = null;\r
1746 \r
1747 \r
1748         CommonTree ID47_tree=null;\r
1749         CommonTree ID48_tree=null;\r
1750         CommonTree char_literal49_tree=null;\r
1751         CommonTree ID50_tree=null;\r
1752         CommonTree STRING51_tree=null;\r
1753         CommonTree URI52_tree=null;\r
1754         CommonTree char_literal54_tree=null;\r
1755         CommonTree char_literal56_tree=null;\r
1756         CommonTree ID57_tree=null;\r
1757         RewriteRuleTokenStream stream_66=new RewriteRuleTokenStream(adaptor,"token 66");\r
1758         RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");\r
1759         RewriteRuleTokenStream stream_75=new RewriteRuleTokenStream(adaptor,"token 75");\r
1760         RewriteRuleTokenStream stream_STRING=new RewriteRuleTokenStream(adaptor,"token STRING");\r
1761         RewriteRuleTokenStream stream_76=new RewriteRuleTokenStream(adaptor,"token 76");\r
1762         RewriteRuleSubtreeStream stream_basicType=new RewriteRuleSubtreeStream(adaptor,"rule basicType");\r
1763         RewriteRuleSubtreeStream stream_simpleValue=new RewriteRuleSubtreeStream(adaptor,"rule simpleValue");\r
1764         try {\r
1765             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:283:5: ( ({...}? => ID -> ^( BLANK ID ) | ID -> ID ) ( '.' ( ID -> ^( REF $resource ID ) | STRING -> ^( REF $resource STRING ) ) )* | URI | simpleValue -> ^( EMBEDDED_VALUE simpleValue ) | '$' basicType -> ^( EMBEDDED_TYPE basicType ) | '%' ID -> ^( VARIABLE ID ) )\r
1766             int alt19=5;\r
1767             switch ( input.LA(1) ) {\r
1768             case ID:\r
1769                 {\r
1770                 alt19=1;\r
1771                 }\r
1772                 break;\r
1773             case URI:\r
1774                 {\r
1775                 alt19=2;\r
1776                 }\r
1777                 break;\r
1778             case LPAREN:\r
1779             case LBRACKET:\r
1780             case LCURLY:\r
1781             case INT:\r
1782             case FLOAT:\r
1783             case STRING:\r
1784             case 79:\r
1785             case 80:\r
1786                 {\r
1787                 alt19=3;\r
1788                 }\r
1789                 break;\r
1790             case 76:\r
1791                 {\r
1792                 alt19=4;\r
1793                 }\r
1794                 break;\r
1795             case 75:\r
1796                 {\r
1797                 alt19=5;\r
1798                 }\r
1799                 break;\r
1800             default:\r
1801                 if (state.backtracking>0) {state.failed=true; return retval;}\r
1802                 NoViableAltException nvae =\r
1803                     new NoViableAltException("", 19, 0, input);\r
1804 \r
1805                 throw nvae;\r
1806             }\r
1807 \r
1808             switch (alt19) {\r
1809                 case 1 :\r
1810                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:283:7: ({...}? => ID -> ^( BLANK ID ) | ID -> ID ) ( '.' ( ID -> ^( REF $resource ID ) | STRING -> ^( REF $resource STRING ) ) )*\r
1811                     {\r
1812                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:283:7: ({...}? => ID -> ^( BLANK ID ) | ID -> ID )\r
1813                     int alt16=2;\r
1814                     int LA16_0 = input.LA(1);\r
1815 \r
1816                     if ( (LA16_0==ID) ) {\r
1817                         int LA16_1 = input.LA(2);\r
1818 \r
1819                         if ( ((input.LT(1).getText().equals("_"))) ) {\r
1820                             alt16=1;\r
1821                         }\r
1822                         else if ( (true) ) {\r
1823                             alt16=2;\r
1824                         }\r
1825                         else {\r
1826                             if (state.backtracking>0) {state.failed=true; return retval;}\r
1827                             NoViableAltException nvae =\r
1828                                 new NoViableAltException("", 16, 1, input);\r
1829 \r
1830                             throw nvae;\r
1831                         }\r
1832                     }\r
1833                     else {\r
1834                         if (state.backtracking>0) {state.failed=true; return retval;}\r
1835                         NoViableAltException nvae =\r
1836                             new NoViableAltException("", 16, 0, input);\r
1837 \r
1838                         throw nvae;\r
1839                     }\r
1840                     switch (alt16) {\r
1841                         case 1 :\r
1842                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:283:9: {...}? => ID\r
1843                             {\r
1844                             if ( !((input.LT(1).getText().equals("_"))) ) {\r
1845                                 if (state.backtracking>0) {state.failed=true; return retval;}\r
1846                                 throw new FailedPredicateException(input, "resource", "input.LT(1).getText().equals(\"_\")");\r
1847                             }\r
1848                             ID47=(Token)match(input,ID,FOLLOW_ID_in_resource1821); if (state.failed) return retval; \r
1849                             if ( state.backtracking==0 ) stream_ID.add(ID47);\r
1850 \r
1851 \r
1852 \r
1853                             // AST REWRITE\r
1854                             // elements: ID\r
1855                             // token labels: \r
1856                             // rule labels: retval\r
1857                             // token list labels: \r
1858                             // rule list labels: \r
1859                             // wildcard labels: \r
1860                             if ( state.backtracking==0 ) {\r
1861                             retval.tree = root_0;\r
1862                             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1863 \r
1864                             root_0 = (CommonTree)adaptor.nil();\r
1865                             // 283:51: -> ^( BLANK ID )\r
1866                             {\r
1867                                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:283:54: ^( BLANK ID )\r
1868                                 {\r
1869                                 CommonTree root_1 = (CommonTree)adaptor.nil();\r
1870                                 root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(BLANK, "BLANK"), root_1);\r
1871 \r
1872                                 adaptor.addChild(root_1, stream_ID.nextNode());\r
1873 \r
1874                                 adaptor.addChild(root_0, root_1);\r
1875                                 }\r
1876 \r
1877                             }\r
1878 \r
1879                             retval.tree = root_0;}\r
1880                             }\r
1881                             break;\r
1882                         case 2 :\r
1883                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:284:9: ID\r
1884                             {\r
1885                             ID48=(Token)match(input,ID,FOLLOW_ID_in_resource1840); if (state.failed) return retval; \r
1886                             if ( state.backtracking==0 ) stream_ID.add(ID48);\r
1887 \r
1888 \r
1889 \r
1890                             // AST REWRITE\r
1891                             // elements: ID\r
1892                             // token labels: \r
1893                             // rule labels: retval\r
1894                             // token list labels: \r
1895                             // rule list labels: \r
1896                             // wildcard labels: \r
1897                             if ( state.backtracking==0 ) {\r
1898                             retval.tree = root_0;\r
1899                             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1900 \r
1901                             root_0 = (CommonTree)adaptor.nil();\r
1902                             // 284:12: -> ID\r
1903                             {\r
1904                                 adaptor.addChild(root_0, stream_ID.nextNode());\r
1905 \r
1906                             }\r
1907 \r
1908                             retval.tree = root_0;}\r
1909                             }\r
1910                             break;\r
1911 \r
1912                     }\r
1913 \r
1914                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:285:7: ( '.' ( ID -> ^( REF $resource ID ) | STRING -> ^( REF $resource STRING ) ) )*\r
1915                     loop18:\r
1916                     do {\r
1917                         int alt18=2;\r
1918                         int LA18_0 = input.LA(1);\r
1919 \r
1920                         if ( (LA18_0==66) ) {\r
1921                             alt18=1;\r
1922                         }\r
1923 \r
1924 \r
1925                         switch (alt18) {\r
1926                         case 1 :\r
1927                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:285:8: '.' ( ID -> ^( REF $resource ID ) | STRING -> ^( REF $resource STRING ) )\r
1928                             {\r
1929                             char_literal49=(Token)match(input,66,FOLLOW_66_in_resource1855); if (state.failed) return retval; \r
1930                             if ( state.backtracking==0 ) stream_66.add(char_literal49);\r
1931 \r
1932                             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:285:12: ( ID -> ^( REF $resource ID ) | STRING -> ^( REF $resource STRING ) )\r
1933                             int alt17=2;\r
1934                             int LA17_0 = input.LA(1);\r
1935 \r
1936                             if ( (LA17_0==ID) ) {\r
1937                                 alt17=1;\r
1938                             }\r
1939                             else if ( (LA17_0==STRING) ) {\r
1940                                 alt17=2;\r
1941                             }\r
1942                             else {\r
1943                                 if (state.backtracking>0) {state.failed=true; return retval;}\r
1944                                 NoViableAltException nvae =\r
1945                                     new NoViableAltException("", 17, 0, input);\r
1946 \r
1947                                 throw nvae;\r
1948                             }\r
1949                             switch (alt17) {\r
1950                                 case 1 :\r
1951                                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:285:13: ID\r
1952                                     {\r
1953                                     ID50=(Token)match(input,ID,FOLLOW_ID_in_resource1858); if (state.failed) return retval; \r
1954                                     if ( state.backtracking==0 ) stream_ID.add(ID50);\r
1955 \r
1956 \r
1957 \r
1958                                     // AST REWRITE\r
1959                                     // elements: ID, resource\r
1960                                     // token labels: \r
1961                                     // rule labels: retval\r
1962                                     // token list labels: \r
1963                                     // rule list labels: \r
1964                                     // wildcard labels: \r
1965                                     if ( state.backtracking==0 ) {\r
1966                                     retval.tree = root_0;\r
1967                                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
1968 \r
1969                                     root_0 = (CommonTree)adaptor.nil();\r
1970                                     // 285:16: -> ^( REF $resource ID )\r
1971                                     {\r
1972                                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:285:19: ^( REF $resource ID )\r
1973                                         {\r
1974                                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
1975                                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(REF, "REF"), root_1);\r
1976 \r
1977                                         adaptor.addChild(root_1, stream_retval.nextTree());\r
1978                                         adaptor.addChild(root_1, stream_ID.nextNode());\r
1979 \r
1980                                         adaptor.addChild(root_0, root_1);\r
1981                                         }\r
1982 \r
1983                                     }\r
1984 \r
1985                                     retval.tree = root_0;}\r
1986                                     }\r
1987                                     break;\r
1988                                 case 2 :\r
1989                                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:286:13: STRING\r
1990                                     {\r
1991                                     STRING51=(Token)match(input,STRING,FOLLOW_STRING_in_resource1883); if (state.failed) return retval; \r
1992                                     if ( state.backtracking==0 ) stream_STRING.add(STRING51);\r
1993 \r
1994 \r
1995 \r
1996                                     // AST REWRITE\r
1997                                     // elements: STRING, resource\r
1998                                     // token labels: \r
1999                                     // rule labels: retval\r
2000                                     // token list labels: \r
2001                                     // rule list labels: \r
2002                                     // wildcard labels: \r
2003                                     if ( state.backtracking==0 ) {\r
2004                                     retval.tree = root_0;\r
2005                                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
2006 \r
2007                                     root_0 = (CommonTree)adaptor.nil();\r
2008                                     // 286:20: -> ^( REF $resource STRING )\r
2009                                     {\r
2010                                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:286:23: ^( REF $resource STRING )\r
2011                                         {\r
2012                                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
2013                                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(REF, "REF"), root_1);\r
2014 \r
2015                                         adaptor.addChild(root_1, stream_retval.nextTree());\r
2016                                         adaptor.addChild(root_1, stream_STRING.nextNode());\r
2017 \r
2018                                         adaptor.addChild(root_0, root_1);\r
2019                                         }\r
2020 \r
2021                                     }\r
2022 \r
2023                                     retval.tree = root_0;}\r
2024                                     }\r
2025                                     break;\r
2026 \r
2027                             }\r
2028 \r
2029 \r
2030                             }\r
2031                             break;\r
2032 \r
2033                         default :\r
2034                             break loop18;\r
2035                         }\r
2036                     } while (true);\r
2037 \r
2038 \r
2039                     }\r
2040                     break;\r
2041                 case 2 :\r
2042                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:289:7: URI\r
2043                     {\r
2044                     root_0 = (CommonTree)adaptor.nil();\r
2045 \r
2046                     URI52=(Token)match(input,URI,FOLLOW_URI_in_resource1924); if (state.failed) return retval;\r
2047                     if ( state.backtracking==0 ) {\r
2048                     URI52_tree = (CommonTree)adaptor.create(URI52);\r
2049                     adaptor.addChild(root_0, URI52_tree);\r
2050                     }\r
2051 \r
2052                     }\r
2053                     break;\r
2054                 case 3 :\r
2055                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:290:7: simpleValue\r
2056                     {\r
2057                     pushFollow(FOLLOW_simpleValue_in_resource1932);\r
2058                     simpleValue53=simpleValue();\r
2059 \r
2060                     state._fsp--;\r
2061                     if (state.failed) return retval;\r
2062                     if ( state.backtracking==0 ) stream_simpleValue.add(simpleValue53.getTree());\r
2063 \r
2064 \r
2065                     // AST REWRITE\r
2066                     // elements: simpleValue\r
2067                     // token labels: \r
2068                     // rule labels: retval\r
2069                     // token list labels: \r
2070                     // rule list labels: \r
2071                     // wildcard labels: \r
2072                     if ( state.backtracking==0 ) {\r
2073                     retval.tree = root_0;\r
2074                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
2075 \r
2076                     root_0 = (CommonTree)adaptor.nil();\r
2077                     // 290:19: -> ^( EMBEDDED_VALUE simpleValue )\r
2078                     {\r
2079                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:290:22: ^( EMBEDDED_VALUE simpleValue )\r
2080                         {\r
2081                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
2082                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(EMBEDDED_VALUE, "EMBEDDED_VALUE"), root_1);\r
2083 \r
2084                         adaptor.addChild(root_1, stream_simpleValue.nextTree());\r
2085 \r
2086                         adaptor.addChild(root_0, root_1);\r
2087                         }\r
2088 \r
2089                     }\r
2090 \r
2091                     retval.tree = root_0;}\r
2092                     }\r
2093                     break;\r
2094                 case 4 :\r
2095                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:291:7: '$' basicType\r
2096                     {\r
2097                     char_literal54=(Token)match(input,76,FOLLOW_76_in_resource1948); if (state.failed) return retval; \r
2098                     if ( state.backtracking==0 ) stream_76.add(char_literal54);\r
2099 \r
2100                     pushFollow(FOLLOW_basicType_in_resource1950);\r
2101                     basicType55=basicType();\r
2102 \r
2103                     state._fsp--;\r
2104                     if (state.failed) return retval;\r
2105                     if ( state.backtracking==0 ) stream_basicType.add(basicType55.getTree());\r
2106 \r
2107 \r
2108                     // AST REWRITE\r
2109                     // elements: basicType\r
2110                     // token labels: \r
2111                     // rule labels: retval\r
2112                     // token list labels: \r
2113                     // rule list labels: \r
2114                     // wildcard labels: \r
2115                     if ( state.backtracking==0 ) {\r
2116                     retval.tree = root_0;\r
2117                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
2118 \r
2119                     root_0 = (CommonTree)adaptor.nil();\r
2120                     // 291:21: -> ^( EMBEDDED_TYPE basicType )\r
2121                     {\r
2122                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:291:24: ^( EMBEDDED_TYPE basicType )\r
2123                         {\r
2124                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
2125                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(EMBEDDED_TYPE, "EMBEDDED_TYPE"), root_1);\r
2126 \r
2127                         adaptor.addChild(root_1, stream_basicType.nextTree());\r
2128 \r
2129                         adaptor.addChild(root_0, root_1);\r
2130                         }\r
2131 \r
2132                     }\r
2133 \r
2134                     retval.tree = root_0;}\r
2135                     }\r
2136                     break;\r
2137                 case 5 :\r
2138                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:292:7: '%' ID\r
2139                     {\r
2140                     char_literal56=(Token)match(input,75,FOLLOW_75_in_resource1966); if (state.failed) return retval; \r
2141                     if ( state.backtracking==0 ) stream_75.add(char_literal56);\r
2142 \r
2143                     ID57=(Token)match(input,ID,FOLLOW_ID_in_resource1968); if (state.failed) return retval; \r
2144                     if ( state.backtracking==0 ) stream_ID.add(ID57);\r
2145 \r
2146 \r
2147 \r
2148                     // AST REWRITE\r
2149                     // elements: ID\r
2150                     // token labels: \r
2151                     // rule labels: retval\r
2152                     // token list labels: \r
2153                     // rule list labels: \r
2154                     // wildcard labels: \r
2155                     if ( state.backtracking==0 ) {\r
2156                     retval.tree = root_0;\r
2157                     RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
2158 \r
2159                     root_0 = (CommonTree)adaptor.nil();\r
2160                     // 292:14: -> ^( VARIABLE ID )\r
2161                     {\r
2162                         // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:292:17: ^( VARIABLE ID )\r
2163                         {\r
2164                         CommonTree root_1 = (CommonTree)adaptor.nil();\r
2165                         root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(VARIABLE, "VARIABLE"), root_1);\r
2166 \r
2167                         adaptor.addChild(root_1, stream_ID.nextNode());\r
2168 \r
2169                         adaptor.addChild(root_0, root_1);\r
2170                         }\r
2171 \r
2172                     }\r
2173 \r
2174                     retval.tree = root_0;}\r
2175                     }\r
2176                     break;\r
2177 \r
2178             }\r
2179             retval.stop = input.LT(-1);\r
2180 \r
2181             if ( state.backtracking==0 ) {\r
2182 \r
2183             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
2184             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
2185             }\r
2186         }\r
2187         catch (RecognitionException re) {\r
2188             reportError(re);\r
2189             recover(input,re);\r
2190         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
2191 \r
2192         }\r
2193         finally {\r
2194         }\r
2195         return retval;\r
2196     }\r
2197     // $ANTLR end "resource"\r
2198 \r
2199     public static class type_return extends ParserRuleReturnScope {\r
2200         CommonTree tree;\r
2201         public Object getTree() { return tree; }\r
2202     };\r
2203 \r
2204     // $ANTLR start "type"\r
2205     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:306:1: type : ( arrayType | unionType );\r
2206     public final GraphParser.type_return type() throws RecognitionException {\r
2207         GraphParser.type_return retval = new GraphParser.type_return();\r
2208         retval.start = input.LT(1);\r
2209 \r
2210         CommonTree root_0 = null;\r
2211 \r
2212         GraphParser.arrayType_return arrayType58 = null;\r
2213 \r
2214         GraphParser.unionType_return unionType59 = null;\r
2215 \r
2216 \r
2217 \r
2218         try {\r
2219             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:307:5: ( arrayType | unionType )\r
2220             int alt20=2;\r
2221             int LA20_0 = input.LA(1);\r
2222 \r
2223             if ( (LA20_0==ID||LA20_0==LPAREN||LA20_0==LCURLY) ) {\r
2224                 alt20=1;\r
2225             }\r
2226             else if ( (LA20_0==77) ) {\r
2227                 alt20=2;\r
2228             }\r
2229             else {\r
2230                 if (state.backtracking>0) {state.failed=true; return retval;}\r
2231                 NoViableAltException nvae =\r
2232                     new NoViableAltException("", 20, 0, input);\r
2233 \r
2234                 throw nvae;\r
2235             }\r
2236             switch (alt20) {\r
2237                 case 1 :\r
2238                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:307:7: arrayType\r
2239                     {\r
2240                     root_0 = (CommonTree)adaptor.nil();\r
2241 \r
2242                     pushFollow(FOLLOW_arrayType_in_type2004);\r
2243                     arrayType58=arrayType();\r
2244 \r
2245                     state._fsp--;\r
2246                     if (state.failed) return retval;\r
2247                     if ( state.backtracking==0 ) adaptor.addChild(root_0, arrayType58.getTree());\r
2248 \r
2249                     }\r
2250                     break;\r
2251                 case 2 :\r
2252                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:308:7: unionType\r
2253                     {\r
2254                     root_0 = (CommonTree)adaptor.nil();\r
2255 \r
2256                     pushFollow(FOLLOW_unionType_in_type2012);\r
2257                     unionType59=unionType();\r
2258 \r
2259                     state._fsp--;\r
2260                     if (state.failed) return retval;\r
2261                     if ( state.backtracking==0 ) adaptor.addChild(root_0, unionType59.getTree());\r
2262 \r
2263                     }\r
2264                     break;\r
2265 \r
2266             }\r
2267             retval.stop = input.LT(-1);\r
2268 \r
2269             if ( state.backtracking==0 ) {\r
2270 \r
2271             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
2272             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
2273             }\r
2274         }\r
2275         catch (RecognitionException re) {\r
2276             reportError(re);\r
2277             recover(input,re);\r
2278         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
2279 \r
2280         }\r
2281         finally {\r
2282         }\r
2283         return retval;\r
2284     }\r
2285     // $ANTLR end "type"\r
2286 \r
2287     public static class unionType_return extends ParserRuleReturnScope {\r
2288         CommonTree tree;\r
2289         public Object getTree() { return tree; }\r
2290     };\r
2291 \r
2292     // $ANTLR start "unionType"\r
2293     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:311:1: unionType : ( '|' unionComponent )+ -> ^( UNION_TYPE ( unionComponent )+ ) ;\r
2294     public final GraphParser.unionType_return unionType() throws RecognitionException {\r
2295         GraphParser.unionType_return retval = new GraphParser.unionType_return();\r
2296         retval.start = input.LT(1);\r
2297 \r
2298         CommonTree root_0 = null;\r
2299 \r
2300         Token char_literal60=null;\r
2301         GraphParser.unionComponent_return unionComponent61 = null;\r
2302 \r
2303 \r
2304         CommonTree char_literal60_tree=null;\r
2305         RewriteRuleTokenStream stream_77=new RewriteRuleTokenStream(adaptor,"token 77");\r
2306         RewriteRuleSubtreeStream stream_unionComponent=new RewriteRuleSubtreeStream(adaptor,"rule unionComponent");\r
2307         try {\r
2308             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:312:5: ( ( '|' unionComponent )+ -> ^( UNION_TYPE ( unionComponent )+ ) )\r
2309             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:313:6: ( '|' unionComponent )+\r
2310             {\r
2311             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:313:6: ( '|' unionComponent )+\r
2312             int cnt21=0;\r
2313             loop21:\r
2314             do {\r
2315                 int alt21=2;\r
2316                 int LA21_0 = input.LA(1);\r
2317 \r
2318                 if ( (LA21_0==77) ) {\r
2319                     alt21=1;\r
2320                 }\r
2321 \r
2322 \r
2323                 switch (alt21) {\r
2324                 case 1 :\r
2325                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:313:7: '|' unionComponent\r
2326                     {\r
2327                     char_literal60=(Token)match(input,77,FOLLOW_77_in_unionType2041); if (state.failed) return retval; \r
2328                     if ( state.backtracking==0 ) stream_77.add(char_literal60);\r
2329 \r
2330                     pushFollow(FOLLOW_unionComponent_in_unionType2043);\r
2331                     unionComponent61=unionComponent();\r
2332 \r
2333                     state._fsp--;\r
2334                     if (state.failed) return retval;\r
2335                     if ( state.backtracking==0 ) stream_unionComponent.add(unionComponent61.getTree());\r
2336 \r
2337                     }\r
2338                     break;\r
2339 \r
2340                 default :\r
2341                     if ( cnt21 >= 1 ) break loop21;\r
2342                     if (state.backtracking>0) {state.failed=true; return retval;}\r
2343                         EarlyExitException eee =\r
2344                             new EarlyExitException(21, input);\r
2345                         throw eee;\r
2346                 }\r
2347                 cnt21++;\r
2348             } while (true);\r
2349 \r
2350 \r
2351 \r
2352             // AST REWRITE\r
2353             // elements: unionComponent\r
2354             // token labels: \r
2355             // rule labels: retval\r
2356             // token list labels: \r
2357             // rule list labels: \r
2358             // wildcard labels: \r
2359             if ( state.backtracking==0 ) {\r
2360             retval.tree = root_0;\r
2361             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
2362 \r
2363             root_0 = (CommonTree)adaptor.nil();\r
2364             // 314:5: -> ^( UNION_TYPE ( unionComponent )+ )\r
2365             {\r
2366                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:314:8: ^( UNION_TYPE ( unionComponent )+ )\r
2367                 {\r
2368                 CommonTree root_1 = (CommonTree)adaptor.nil();\r
2369                 root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(UNION_TYPE, "UNION_TYPE"), root_1);\r
2370 \r
2371                 if ( !(stream_unionComponent.hasNext()) ) {\r
2372                     throw new RewriteEarlyExitException();\r
2373                 }\r
2374                 while ( stream_unionComponent.hasNext() ) {\r
2375                     adaptor.addChild(root_1, stream_unionComponent.nextTree());\r
2376 \r
2377                 }\r
2378                 stream_unionComponent.reset();\r
2379 \r
2380                 adaptor.addChild(root_0, root_1);\r
2381                 }\r
2382 \r
2383             }\r
2384 \r
2385             retval.tree = root_0;}\r
2386             }\r
2387 \r
2388             retval.stop = input.LT(-1);\r
2389 \r
2390             if ( state.backtracking==0 ) {\r
2391 \r
2392             retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);\r
2393             adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);\r
2394             }\r
2395         }\r
2396         catch (RecognitionException re) {\r
2397             reportError(re);\r
2398             recover(input,re);\r
2399         retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);\r
2400 \r
2401         }\r
2402         finally {\r
2403         }\r
2404         return retval;\r
2405     }\r
2406     // $ANTLR end "unionType"\r
2407 \r
2408     public static class unionComponent_return extends ParserRuleReturnScope {\r
2409         CommonTree tree;\r
2410         public Object getTree() { return tree; }\r
2411     };\r
2412 \r
2413     // $ANTLR start "unionComponent"\r
2414     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:317:1: unionComponent : ID ( ( arrayType )=> arrayType )? -> ^( TYPE_COMPONENT ID ( arrayType )? ) ;\r
2415     public final GraphParser.unionComponent_return unionComponent() throws RecognitionException {\r
2416         GraphParser.unionComponent_return retval = new GraphParser.unionComponent_return();\r
2417         retval.start = input.LT(1);\r
2418 \r
2419         CommonTree root_0 = null;\r
2420 \r
2421         Token ID62=null;\r
2422         GraphParser.arrayType_return arrayType63 = null;\r
2423 \r
2424 \r
2425         CommonTree ID62_tree=null;\r
2426         RewriteRuleTokenStream stream_ID=new RewriteRuleTokenStream(adaptor,"token ID");\r
2427         RewriteRuleSubtreeStream stream_arrayType=new RewriteRuleSubtreeStream(adaptor,"rule arrayType");\r
2428         try {\r
2429             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:317:16: ( ID ( ( arrayType )=> arrayType )? -> ^( TYPE_COMPONENT ID ( arrayType )? ) )\r
2430             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:317:18: ID ( ( arrayType )=> arrayType )?\r
2431             {\r
2432             ID62=(Token)match(input,ID,FOLLOW_ID_in_unionComponent2071); if (state.failed) return retval; \r
2433             if ( state.backtracking==0 ) stream_ID.add(ID62);\r
2434 \r
2435             // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:317:21: ( ( arrayType )=> arrayType )?\r
2436             int alt22=2;\r
2437             alt22 = dfa22.predict(input);\r
2438             switch (alt22) {\r
2439                 case 1 :\r
2440                     // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:317:22: ( arrayType )=> arrayType\r
2441                     {\r
2442                     pushFollow(FOLLOW_arrayType_in_unionComponent2080);\r
2443                     arrayType63=arrayType();\r
2444 \r
2445                     state._fsp--;\r
2446                     if (state.failed) return retval;\r
2447                     if ( state.backtracking==0 ) stream_arrayType.add(arrayType63.getTree());\r
2448 \r
2449                     }\r
2450                     break;\r
2451 \r
2452             }\r
2453 \r
2454 \r
2455 \r
2456             // AST REWRITE\r
2457             // elements: ID, arrayType\r
2458             // token labels: \r
2459             // rule labels: retval\r
2460             // token list labels: \r
2461             // rule list labels: \r
2462             // wildcard labels: \r
2463             if ( state.backtracking==0 ) {\r
2464             retval.tree = root_0;\r
2465             RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);\r
2466 \r
2467             root_0 = (CommonTree)adaptor.nil();\r
2468             // 317:49: -> ^( TYPE_COMPONENT ID ( arrayType )? )\r
2469             {\r
2470                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:317:52: ^( TYPE_COMPONENT ID ( arrayType )? )\r
2471                 {\r
2472                 CommonTree root_1 = (CommonTree)adaptor.nil();\r
2473                 root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(TYPE_COMPONENT, "TYPE_COMPONENT"), root_1);\r
2474 \r
2475                 adaptor.addChild(root_1, stream_ID.nextNode());\r
2476                 // src\\org\\simantics\\graph\\compiler\\internal\\parsing\\Graph.g:317:72: ( arrayType )?\r
2477                 if ( stream_arrayType.hasNext() ) {\r
2478                     adaptor.addChild(root_1, stream_arrayType.nextTree());