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