]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java
(refs #7601) Wildcard syntax for SCL records
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / parsing / parser / SCLParser.java
1 package org.simantics.scl.compiler.internal.parsing.parser;
2
3 import java.io.DataInputStream;
4 import java.io.IOException;
5 import java.util.ArrayList;
6 import java.util.Arrays;
7 import java.util.Collections;
8 import org.simantics.scl.compiler.internal.parsing.exceptions.SCLSyntaxErrorException;
9
10 import org.simantics.scl.compiler.internal.parsing.Token;
11
12 public abstract class SCLParser {    
13     public static final boolean TRACE = false;
14
15     private static final int INITIAL_CAPACITY = 16;
16     private static final int STATE_COUNT = 363;
17     private static final int TERMINAL_COUNT = 86;
18     private static final int NONTERMINAL_COUNT = 52;
19     private static final int PRODUCT_COUNT = 139;
20     
21     private static final int[] ACTION_ROW_ID = new int[STATE_COUNT];
22     private static final int[] ACTION_COLUMN_ID = new int[TERMINAL_COUNT];
23     private static final short[] ACTION_TABLE = new short[6765];
24     private static final int[] ERROR_TABLE = new int[976];
25     private static final int[] GOTO_ROW_ID = new int[STATE_COUNT];
26     private static final int[] GOTO_COLUMN_ID = new int[NONTERMINAL_COUNT];
27     private static final short[] GOTO_TABLE = new short[1953];
28     private static final int[] PRODUCT_LHS = new int[PRODUCT_COUNT];
29
30     private static final short STATE_MASK = (short)0x0fff;
31     private static final short REDUCE_MASK = (short)0x8000;
32     private static final short POP_MASK = (short)0x4000;
33     private static final short PUSH_MASK = (short)0x2000;
34     private static final short ERROR_ACTION = (short)0xffff;
35     private static final short ACCEPT_ACTION = (short)0xfffe;
36     
37     public static final String[] TERMINAL_NAMES = new String[] {
38         "SEMICOLON",
39         "LBRACE",
40         "RBRACE",
41         "MODULE",
42         "COMMA",
43         "HASTYPE",
44         "DATA",
45         "ID",
46         "EQUALS",
47         "BAR",
48         "TYPE",
49         "CLASS",
50         "WHERE",
51         "INSTANCE",
52         "DERIVING",
53         "BEGIN_STRING",
54         "END_STRING",
55         "ANNOTATION_ID",
56         "INFIX",
57         "INFIXL",
58         "INFIXR",
59         "INTEGER",
60         "IMPORTJAVA",
61         "EFFECT",
62         "RULE",
63         "ABSTRACT_RULE",
64         "EXTENDS",
65         "MAPPING_RELATION",
66         "FOLLOWS",
67         "RULESET",
68         "IMPORT",
69         "INCLUDE",
70         "AS",
71         "LPAREN",
72         "RPAREN",
73         "HIDING",
74         "ARROW",
75         "COLON",
76         "MINUS",
77         "SYMBOL",
78         "LESS",
79         "GREATER",
80         "SEPARATED_DOT",
81         "ESCAPED_ID",
82         "LAMBDA",
83         "LAMBDA_MATCH",
84         "LET",
85         "IF",
86         "MATCH",
87         "DO",
88         "MDO",
89         "EDO",
90         "ENFORCE",
91         "BLANK",
92         "FLOAT",
93         "LBRACKET",
94         "ESCAPED_SYMBOL",
95         "CHAR",
96         "WHEN",
97         "ATTACHED_HASH",
98         "SELECT",
99         "SELECT_FIRST",
100         "SELECT_DISTINCT",
101         "TRANSFORMATION",
102         "EQ",
103         "CHR_SELECT",
104         "ATTACHED_DOT",
105         "IN",
106         "THEN",
107         "ELSE",
108         "WITH",
109         "RBRACKET",
110         "DOTDOT",
111         "AT",
112         "SUSPEND_STRING",
113         "CONTINUE_STRING",
114         "BINDS",
115         "IMPLIES",
116         "THEN_AFTER_WHEN",
117         "CONSTRAINT",
118         "BY",
119         "QUERY_OP",
120         "FORALL",
121         "COMMENT",
122         "EOL",
123         "EOF"
124     };
125
126     public static final String[] NONTERMINAL_NAMES = new String[] {
127         "module",
128         "commands",
129         "import",
130         "type",
131         "exp",
132         "equationBlock",
133         "declaration",
134         "command",
135         "statement",
136         "declarations",
137         "field",
138         "var",
139         "bexp",
140         "rhs",
141         "constructor",
142         "context",
143         "fundeps",
144         "atype",
145         "aexp",
146         "ruleDeclarations",
147         "statements",
148         "importSpec",
149         "importItem",
150         "fieldDeclaration",
151         "guardedExpEq",
152         "fundep",
153         "ruleDeclaration",
154         "query",
155         "lexp",
156         "symbol",
157         "faexp",
158         "accessor",
159         "case",
160         "queryBlock",
161         "verboseChrQuery",
162         "stringLiteral",
163         "symbolWithoutMinus",
164         "listQualifier",
165         "chrQuery",
166         "chrQueryPart",
167         "caseRhs",
168         "guardedExpArrow",
169         "equation",
170         "etype",
171         "btype",
172         "dummy",
173         "init$6",
174         "init$5",
175         "init$4",
176         "init$3",
177         "init$2",
178         "init$1"
179     };
180         
181     static {
182         try {
183             DataInputStream input = new DataInputStream(SCLParser.class.getResourceAsStream("SCLParser.dat"));
184             for(int i=0;i<ACTION_ROW_ID.length;++i)
185                 ACTION_ROW_ID[i] = input.readInt();
186             for(int i=0;i<ACTION_COLUMN_ID.length;++i)
187                 ACTION_COLUMN_ID[i] = input.readInt();    
188             for(int i=0;i<ACTION_TABLE.length;++i)
189                 ACTION_TABLE[i] = input.readShort();
190             for(int i=0;i<ERROR_TABLE.length;++i)
191                 ERROR_TABLE[i] = input.readInt();
192             for(int i=0;i<GOTO_ROW_ID.length;++i)
193                 GOTO_ROW_ID[i] = input.readInt();
194             for(int i=0;i<GOTO_COLUMN_ID.length;++i)
195                 GOTO_COLUMN_ID[i] = input.readInt();    
196             for(int i=0;i<GOTO_TABLE.length;++i)
197                 GOTO_TABLE[i] = input.readShort();
198             for(int i=0;i<PRODUCT_LHS.length;++i)
199                 PRODUCT_LHS[i] = input.readInt();
200             input.close();
201         } catch(IOException e) {
202             e.printStackTrace();
203         }
204     }
205     
206     private static short getAction(int state, int symbol) {
207         int id = TERMINAL_COUNT*state + symbol;
208         if( ((ERROR_TABLE[id>>5] >> (id&31))&1) != 0 )
209             return ERROR_ACTION;
210         return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]];
211     }
212     
213     private static short getGoto(int state, int symbol) {
214         return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]];
215     }
216     
217     protected abstract Token nextToken();
218     
219     private Object[] symbolStack = new Object[INITIAL_CAPACITY];
220     private int symbolStackLength = 0;
221     
222     private int[] stateStack = new int[INITIAL_CAPACITY];
223     private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY];
224     private int stateStackLength = 0;
225     
226     // For reduce
227     private int reductionLength;
228     
229     protected int length() {
230         return reductionLength;
231     }
232     
233     protected Object get(int i) {
234         if(i < 0 || i >= reductionLength)
235             throw new IndexOutOfBoundsException();
236         return symbolStack[symbolStackLength+i];
237     }
238     
239     private String parseErrorDescription(int state, Token token, int tokenId) {
240         StringBuilder b = new StringBuilder();
241         b.append("Unexpected token '").append(token)
242          .append("' (").append(TERMINAL_NAMES[tokenId])
243          .append("). Expected one of ");
244         ArrayList<String> possibleTerminals = new ArrayList<String>();
245         for(int i=0;i<TERMINAL_COUNT;++i)
246             if(getAction(state, i) != ERROR_ACTION)
247                 possibleTerminals.add(TERMINAL_NAMES[i]);
248         Collections.sort(possibleTerminals);
249         for(int i=0;i<possibleTerminals.size();++i) {
250             if(i > 0)
251                 b.append(", ");
252             b.append(possibleTerminals.get(i));
253         }
254         b.append('.');
255         return b.toString();
256     }
257     
258     protected abstract RuntimeException syntaxError(Token token, String description);
259     
260     private static String describeAction(boolean isGoto, int action) {
261         if(action == ERROR_ACTION)
262             return "ERROR";
263         if(action == ACCEPT_ACTION)
264             return "ACCEPT";
265         StringBuilder b = new StringBuilder();
266         if(isGoto)
267             b.append("GOTO ");
268         else {
269             if((action & REDUCE_MASK) != 0) {
270                 action ^= REDUCE_MASK;
271                 b.append("REDUCE");
272             }
273             else
274                 b.append("SHIFT");
275         }
276         if((action & POP_MASK) != 0) {
277             action ^= POP_MASK;
278             b.append(" POP");
279         }
280         if((action & PUSH_MASK) != 0) {
281             action ^= PUSH_MASK;
282             b.append(" PUSH");
283         }
284         b.append(' ').append(action);
285         return b.toString();
286     }
287     
288     private void printState(int state) {
289         System.out.print("state=" + state + ":");
290         for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) {
291             Object s = symbolStack[i];
292             if(s instanceof Token)
293                 System.out.print(" " + TERMINAL_NAMES[((Token)s).id]);
294             else if(s == null)
295                 System.out.print(" null");
296             else
297                 System.out.print(" " + s.getClass().getSimpleName());
298             while(j>=0 && symbolStackPositionStack[j]==i)
299                 System.out.print(" (" + stateStack[j--] + ")");
300         }
301         System.out.println();
302     }
303     
304     private Object parse(int state) {
305         while(true) {
306             Token token = nextToken();
307             int tokenId = token.id;
308             if(TRACE)
309                 System.out.println("---> token " + TERMINAL_NAMES[tokenId] + " \"" + token.text + "\" <---");
310             while(true) {
311                 if(TRACE)
312                     printState(state);
313                 short action = getAction(state, tokenId);
314                 if(TRACE)
315                     System.out.println("    -> action=" + describeAction(false, action));
316                 //System.out.println(STATE_DESCRIPTIONS[state]);
317                 if((action & REDUCE_MASK) != 0) {
318                     if(action == ACCEPT_ACTION)
319                         return symbolStack[symbolStackLength-1];
320                     if(action == ERROR_ACTION)
321                         throw syntaxError(token, parseErrorDescription(state, token, tokenId));
322                     int popAmount = (action >>> 13)&3;
323                     if(TRACE) {
324                         if(popAmount > 0)
325                             System.out.println("    POP " + popAmount);
326                     }
327                     stateStackLength -= popAmount;
328                     action &= STATE_MASK;
329                     
330                     int reductionBegin = symbolStackPositionStack[--stateStackLength];
331                     
332                     reductionLength = symbolStackLength-reductionBegin;
333                     symbolStackLength = reductionBegin;
334                     
335                     if(symbolStackLength == symbolStack.length)
336                         symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
337                     Object symbol = reduce(action);
338                     postReduce(symbol);
339                     symbolStack[symbolStackLength] = symbol;
340                     
341                     state = stateStack[stateStackLength];
342                     if(TRACE) {
343                         ++symbolStackLength;
344                         printState(state);
345                         --symbolStackLength;
346                         System.out.println("    nonterminal=" + NONTERMINAL_NAMES[PRODUCT_LHS[action]]);
347                     }
348                     action = getGoto(state, PRODUCT_LHS[action]);
349                     if(TRACE)
350                         System.out.println("    -> action=" + describeAction(true, action));
351                         
352                     // Pop state
353                     if((action & POP_MASK) != 0) {
354                         --stateStackLength;
355                     }
356                     // Push state
357                     if((action & PUSH_MASK) != 0) {
358                         if(stateStackLength == stateStack.length) {
359                             stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
360                             symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
361                         }
362                         symbolStackPositionStack[stateStackLength] = symbolStackLength;
363                         stateStack[stateStackLength++] = state;
364                     }
365                     state = action & STATE_MASK;
366                     ++symbolStackLength;
367                 }
368                 else {
369                     // Pop state
370                     if((action & POP_MASK) != 0) {
371                         --stateStackLength;
372                     }
373                     // Push state
374                     if((action & PUSH_MASK) != 0) {
375                         if(stateStackLength == stateStack.length) {
376                             stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
377                             symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
378                         }
379                         symbolStackPositionStack[stateStackLength] = symbolStackLength;
380                         stateStack[stateStackLength++] = state;
381                     }
382                     
383                     // New state
384                     state = action & STATE_MASK;
385                     
386                     // Push symbol
387                     if(symbolStackLength == symbolStack.length)
388                         symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
389                     symbolStack[symbolStackLength++] = token;
390                     break;
391                 }
392             }
393         }
394     }
395     
396     public Object parseModule() {
397         return parse(0);
398     }
399     public Object parseCommands() {
400         return parse(347);
401     }
402     public Object parseImport() {
403         return parse(355);
404     }
405     public Object parseType() {
406         return parse(357);
407     }
408     public Object parseExp() {
409         return parse(359);
410     }
411     public Object parseEquationBlock() {
412         return parse(361);
413     }
414
415
416     protected Object reduce(int productionId) {
417         try {
418         switch(productionId) {
419         case 0:
420             return reduceModule();
421         case 1:
422             return reduceOneCommand();
423         case 2:
424             return reduceManyCommands();
425         case 3:
426             return reduceImport();
427         case 4:
428             return reduceArrow();
429         case 5:
430             return reduceLocalTypeAnnotation();
431         case 6:
432             return reduceEquationBlock();
433         case 7:
434             return reduceModuleHeader();
435         case 8:
436             return reduceTypeAnnotation();
437         case 9:
438             return reduceValueDefinition();
439         case 10:
440             return reduceDataDefinition();
441         case 11:
442             return reduceTypeDefinition();
443         case 12:
444             return reduceClassDefinition();
445         case 13:
446             return reduceInstanceDefinition();
447         case 14:
448             return reduceDerivingInstanceDefinition();
449         case 15:
450             return reduceDocumentationString();
451         case 16:
452             return reduceAnnotation();
453         case 17:
454             return reducePrecedenceDefinition();
455         case 18:
456             return reduceJustImport();
457         case 19:
458             return reduceImportJava();
459         case 20:
460             return reduceEffectDefinition();
461         case 21:
462             return reduceRuleDefinition();
463         case 22:
464             return reduceMappingRelationDefinition();
465         case 23:
466             return reduceRelationDefinition();
467         case 24:
468             return reduceRulesetDefinition();
469         case 25:
470             return reduceStatementCommand();
471         case 26:
472             return reduceImportCommand();
473         case 27:
474             return reduceGuardStatement();
475         case 28:
476             return reduceLetStatement();
477         case 29:
478             return reduceBindStatement();
479         case 30:
480             return reduceRuleStatement();
481         case 31:
482             return reduceCHRStatement();
483         case 32:
484             return reduceVerboseCHRStatement();
485         case 33:
486             return reduceConstraintStatement();
487         case 34:
488             return reduceLocalInclude();
489         case 35:
490             return reduceDeclarations();
491         case 36:
492             return reduceField();
493         case 37:
494             return reduceFieldShorthand();
495         case 38:
496             return reduceWildcard();
497         case 39:
498             return reduceVarId();
499         case 40:
500             return reduceEscapedSymbol();
501         case 41:
502             return reduceTupleConstructor();
503         case 42:
504             return reduceBinary();
505         case 43:
506             return reduceSimpleRhs();
507         case 44:
508             return reduceGuardedRhs();
509         case 45:
510             return reduceConstructor();
511         case 46:
512             return reduceRecordConstructor();
513         case 47:
514             return reduceContext();
515         case 48:
516             return reduceFundeps();
517         case 49:
518             return reduceTypeVar();
519         case 50:
520             return reduceTupleType();
521         case 51:
522             return reduceListType();
523         case 52:
524             return reduceListTypeConstructor();
525         case 53:
526             return reduceTupleTypeConstructor();
527         case 54:
528             return reduceLambda();
529         case 55:
530             return reduceLambdaMatch();
531         case 56:
532             return reduceLet();
533         case 57:
534             return reduceIf();
535         case 58:
536             return reduceMatch();
537         case 59:
538             return reduceDo();
539         case 60:
540             return reduceSelect();
541         case 61:
542             return reduceCHRSelect();
543         case 62:
544             return reduceEnforce();
545         case 63:
546             return reduceVar();
547         case 64:
548             return reduceHashedId();
549         case 65:
550             return reduceBlank();
551         case 66:
552             return reduceInteger();
553         case 67:
554             return reduceFloat();
555         case 68:
556             return reduceString();
557         case 69:
558             return reduceChar();
559         case 70:
560             return reduceTuple();
561         case 71:
562             return reduceViewPattern();
563         case 72:
564             return reduceRightSection();
565         case 73:
566             return reduceLeftSection();
567         case 74:
568             return reduceListLiteral();
569         case 75:
570             return reduceRange();
571         case 76:
572             return reduceListComprehension();
573         case 77:
574             return reduceAs();
575         case 78:
576             return reduceRecord();
577         case 79:
578             return reduceTransformation();
579         case 80:
580             return reduceEq();
581         case 81:
582             return reduceRuleDeclarations();
583         case 82:
584             return reduceStatements();
585         case 83:
586             return reduceImportShowing();
587         case 84:
588             return reduceImportHiding();
589         case 85:
590             return reduceImportValueItem();
591         case 86:
592             return reduceFieldDescription();
593         case 87:
594             return reduceGuardedExpEq();
595         case 88:
596             return reduceFundep();
597         case 89:
598             return reduceQueryRuleDeclaration();
599         case 90:
600             return reduceAnnotation();
601         case 91:
602             return reduceGuardQuery();
603         case 92:
604             return reduceEqualsQuery();
605         case 93:
606             return reduceBindQuery();
607         case 94:
608             return reduceCompositeQuery();
609         case 95:
610             return reduceApply();
611         case 96:
612             return reduceSymbol();
613         case 97:
614             return reduceEscapedId();
615         case 98:
616             return reduceMinus();
617         case 99:
618             return reduceLess();
619         case 100:
620             return reduceGreater();
621         case 101:
622             return reduceDot();
623         case 102:
624             return reduceFieldAccess();
625         case 103:
626             return reduceIdAccessor();
627         case 104:
628             return reduceStringAccessor();
629         case 105:
630             return reduceExpAccessor();
631         case 106:
632             return reduceCase();
633         case 107:
634             return reduceQueryBlock();
635         case 108:
636             return reduceVerboseCHRConjunction();
637         case 109:
638             return reduceStringLiteral();
639         case 110:
640             return reduceSymbol();
641         case 111:
642             return reduceEscapedId();
643         case 112:
644             return reduceLess();
645         case 113:
646             return reduceGreater();
647         case 114:
648             return reduceDot();
649         case 115:
650             return reduceGuardQualifier();
651         case 116:
652             return reduceLetQualifier();
653         case 117:
654             return reduceBindQualifier();
655         case 118:
656             return reduceThenQualifier();
657         case 119:
658             return reduceCHRConjunction();
659         case 120:
660             return reduceCHRAtom();
661         case 121:
662             return reduceCHREquals();
663         case 122:
664             return reduceCHRBinds();
665         case 123:
666             return reduceSimpleCaseRhs();
667         case 124:
668             return reduceGuardedCaseRhs();
669         case 125:
670             return reduceGuardedExpArrow();
671         case 126:
672             return reduceGuardEquation();
673         case 127:
674             return reduceBasicEquation();
675         case 128:
676             return reduceEffect();
677         case 129:
678             return reduceJustEtype();
679         case 130:
680             return reduceForAll();
681         case 131:
682             return reduceApplyType();
683         case 132:
684             return reduceDummy();
685
686         default:
687             throw new RuntimeException("Internal parser error.");
688         }
689         } catch(SCLSyntaxErrorException e) {
690             StringBuilder b = new StringBuilder();
691             b.append("Failed to reduce");
692             for(int i=0;i<length();++i) {
693                 Object obj = get(i);
694                 b.append("\n    (").append(i).append(") \"").append(obj).append('\"');
695                 if(obj instanceof Token)
696                     b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
697                 else
698                     b.append(" [").append(obj.getClass().getSimpleName()).append("]");
699             }
700             throw new RuntimeException(b.toString(), e);
701         } 
702     }
703
704     /**
705      * module ::= (declaration (SEMICOLON declaration)&#42;)?
706      */
707     protected abstract Object reduceModule();
708     /**
709      * commands ::= command?
710      */
711     protected abstract Object reduceOneCommand();
712     /**
713      * commands ::= commands SEMICOLON command
714      */
715     protected abstract Object reduceManyCommands();
716     /**
717      * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
718      */
719     protected abstract Object reduceImport();
720     /**
721      * type ::= (etype (ARROW | IMPLIES))&#42; etype
722      */
723     protected abstract Object reduceArrow();
724     /**
725      * exp ::= bexp (HASTYPE type)?
726      */
727     protected abstract Object reduceLocalTypeAnnotation();
728     /**
729      * equationBlock ::= (equation (SEMICOLON equation)&#42;)?
730      */
731     protected abstract Object reduceEquationBlock();
732     /**
733      * declaration ::= MODULE LBRACE (field (COMMA field)&#42;)? RBRACE
734      */
735     protected abstract Object reduceModuleHeader();
736     /**
737      * declaration ::= (var COMMA)&#42; var HASTYPE type
738      */
739     protected abstract Object reduceTypeAnnotation();
740     /**
741      * declaration ::= bexp rhs
742      */
743     protected abstract Object reduceValueDefinition();
744     /**
745      * declaration ::= DATA ID ID&#42; (EQUALS (constructor BAR)&#42; constructor)?
746      */
747     protected abstract Object reduceDataDefinition();
748     /**
749      * declaration ::= TYPE ID ID&#42; EQUALS type
750      */
751     protected abstract Object reduceTypeDefinition();
752     /**
753      * declaration ::= CLASS context? ID ID&#42; (BAR fundeps | (BAR fundeps)? WHERE declarations)?
754      */
755     protected abstract Object reduceClassDefinition();
756     /**
757      * declaration ::= INSTANCE context? ID atype atype&#42; (WHERE declarations)?
758      */
759     protected abstract Object reduceInstanceDefinition();
760     /**
761      * declaration ::= DERIVING INSTANCE context? ID atype atype&#42;
762      */
763     protected abstract Object reduceDerivingInstanceDefinition();
764     /**
765      * declaration ::= BEGIN_STRING END_STRING
766      */
767     protected abstract Object reduceDocumentationString();
768     /**
769      * declaration ::= ANNOTATION_ID aexp&#42;
770      */
771     protected abstract Object reduceAnnotation();
772     /**
773      * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)&#42; var
774      */
775     protected abstract Object reducePrecedenceDefinition();
776     /**
777      * declaration ::= import
778      */
779     protected abstract Object reduceJustImport();
780     /**
781      * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
782      */
783     protected abstract Object reduceImportJava();
784     /**
785      * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
786      */
787     protected abstract Object reduceEffectDefinition();
788     /**
789      * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)&#42; ID)? WHERE ruleDeclarations
790      */
791     protected abstract Object reduceRuleDefinition();
792     /**
793      * declaration ::= MAPPING_RELATION ID atype&#42;
794      */
795     protected abstract Object reduceMappingRelationDefinition();
796     /**
797      * declaration ::= bexp FOLLOWS ruleDeclarations
798      */
799     protected abstract Object reduceRelationDefinition();
800     /**
801      * declaration ::= RULESET ID WHERE statements
802      */
803     protected abstract Object reduceRulesetDefinition();
804     /**
805      * command ::= statement
806      */
807     protected abstract Object reduceStatementCommand();
808     /**
809      * command ::= import
810      */
811     protected abstract Object reduceImportCommand();
812     /**
813      * statement ::= exp
814      */
815     protected abstract Object reduceGuardStatement();
816     /**
817      * statement ::= exp rhs
818      */
819     protected abstract Object reduceLetStatement();
820     /**
821      * statement ::= exp BINDS exp
822      */
823     protected abstract Object reduceBindStatement();
824     /**
825      * statement ::= exp FOLLOWS queryBlock
826      */
827     protected abstract Object reduceRuleStatement();
828     /**
829      * statement ::= chrQuery IMPLIES chrQuery
830      */
831     protected abstract Object reduceCHRStatement();
832     /**
833      * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
834      */
835     protected abstract Object reduceVerboseCHRStatement();
836     /**
837      * statement ::= CONSTRAINT constructor
838      */
839     protected abstract Object reduceConstraintStatement();
840     /**
841      * statement ::= INCLUDE ID aexp
842      */
843     protected abstract Object reduceLocalInclude();
844     /**
845      * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)&#42; declaration)?)? RBRACE
846      */
847     protected abstract Object reduceDeclarations();
848     /**
849      * field ::= ID EQUALS exp
850      */
851     protected abstract Object reduceField();
852     /**
853      * field ::= ID
854      */
855     protected abstract Object reduceFieldShorthand();
856     /**
857      * field ::= DOTDOT
858      */
859     protected abstract Object reduceWildcard();
860     /**
861      * var ::= ID
862      */
863     protected abstract Object reduceVarId();
864     /**
865      * var ::= ESCAPED_SYMBOL
866      */
867     protected abstract Object reduceEscapedSymbol();
868     /**
869      * var ::= LPAREN COMMA COMMA&#42; RPAREN
870      */
871     protected abstract Object reduceTupleConstructor();
872     /**
873      * bexp ::= MINUS? lexp (symbol lexp)&#42;
874      */
875     protected abstract Object reduceBinary();
876     /**
877      * rhs ::= EQUALS exp (WHERE statements)?
878      */
879     protected abstract Object reduceSimpleRhs();
880     /**
881      * rhs ::= guardedExpEq guardedExpEq&#42; (WHERE statements)?
882      */
883     protected abstract Object reduceGuardedRhs();
884     /**
885      * constructor ::= (ANNOTATION_ID aexp)&#42; ID atype&#42;
886      */
887     protected abstract Object reduceConstructor();
888     /**
889      * constructor ::= (ANNOTATION_ID aexp)&#42; ID LBRACE fieldDeclaration (COMMA fieldDeclaration)&#42; RBRACE
890      */
891     protected abstract Object reduceRecordConstructor();
892     /**
893      * context ::= LPAREN type (COMMA type)&#42; RPAREN IMPLIES
894      */
895     protected abstract Object reduceContext();
896     /**
897      * fundeps ::= (fundep COMMA)&#42; fundep
898      */
899     protected abstract Object reduceFundeps();
900     /**
901      * atype ::= ID
902      */
903     protected abstract Object reduceTypeVar();
904     /**
905      * atype ::= LPAREN (type (COMMA (type COMMA)&#42; type)?)? RPAREN
906      */
907     protected abstract Object reduceTupleType();
908     /**
909      * atype ::= LBRACKET type RBRACKET
910      */
911     protected abstract Object reduceListType();
912     /**
913      * atype ::= LBRACKET RBRACKET
914      */
915     protected abstract Object reduceListTypeConstructor();
916     /**
917      * atype ::= LPAREN COMMA COMMA&#42; RPAREN
918      */
919     protected abstract Object reduceTupleTypeConstructor();
920     /**
921      * aexp ::= LAMBDA aexp aexp&#42; ARROW exp
922      */
923     protected abstract Object reduceLambda();
924     /**
925      * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)&#42; RBRACE
926      */
927     protected abstract Object reduceLambdaMatch();
928     /**
929      * aexp ::= LET statements IN exp
930      */
931     protected abstract Object reduceLet();
932     /**
933      * aexp ::= IF exp THEN exp (ELSE exp)?
934      */
935     protected abstract Object reduceIf();
936     /**
937      * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)&#42; RBRACE
938      */
939     protected abstract Object reduceMatch();
940     /**
941      * aexp ::= (DO | MDO | EDO) statements
942      */
943     protected abstract Object reduceDo();
944     /**
945      * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
946      */
947     protected abstract Object reduceSelect();
948     /**
949      * aexp ::= CHR_SELECT exp WHERE verboseChrQuery
950      */
951     protected abstract Object reduceCHRSelect();
952     /**
953      * aexp ::= ENFORCE queryBlock
954      */
955     protected abstract Object reduceEnforce();
956     /**
957      * aexp ::= var
958      */
959     protected abstract Object reduceVar();
960     /**
961      * aexp ::= ATTACHED_HASH ID
962      */
963     protected abstract Object reduceHashedId();
964     /**
965      * aexp ::= BLANK
966      */
967     protected abstract Object reduceBlank();
968     /**
969      * aexp ::= INTEGER
970      */
971     protected abstract Object reduceInteger();
972     /**
973      * aexp ::= FLOAT
974      */
975     protected abstract Object reduceFloat();
976     /**
977      * aexp ::= stringLiteral
978      */
979     protected abstract Object reduceString();
980     /**
981      * aexp ::= CHAR
982      */
983     protected abstract Object reduceChar();
984     /**
985      * aexp ::= LPAREN (exp (COMMA (exp COMMA)&#42; exp)?)? RPAREN
986      */
987     protected abstract Object reduceTuple();
988     /**
989      * aexp ::= LPAREN exp ARROW exp RPAREN
990      */
991     protected abstract Object reduceViewPattern();
992     /**
993      * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
994      */
995     protected abstract Object reduceRightSection();
996     /**
997      * aexp ::= LPAREN lexp symbol RPAREN
998      */
999     protected abstract Object reduceLeftSection();
1000     /**
1001      * aexp ::= LBRACKET (exp (COMMA (exp COMMA)&#42; exp)?)? RBRACKET
1002      */
1003     protected abstract Object reduceListLiteral();
1004     /**
1005      * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
1006      */
1007     protected abstract Object reduceRange();
1008     /**
1009      * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)&#42; RBRACKET
1010      */
1011     protected abstract Object reduceListComprehension();
1012     /**
1013      * aexp ::= ID AT aexp
1014      */
1015     protected abstract Object reduceAs();
1016     /**
1017      * aexp ::= ID LBRACE (field (COMMA field)&#42;)? RBRACE
1018      */
1019     protected abstract Object reduceRecord();
1020     /**
1021      * aexp ::= TRANSFORMATION ID WHERE queryBlock
1022      */
1023     protected abstract Object reduceTransformation();
1024     /**
1025      * aexp ::= EQ LBRACE equationBlock RBRACE
1026      */
1027     protected abstract Object reduceEq();
1028     /**
1029      * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)&#42; ruleDeclaration)?)? RBRACE
1030      */
1031     protected abstract Object reduceRuleDeclarations();
1032     /**
1033      * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)&#42; statement)?)? RBRACE
1034      */
1035     protected abstract Object reduceStatements();
1036     /**
1037      * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)&#42; importItem)?)? RPAREN
1038      */
1039     protected abstract Object reduceImportShowing();
1040     /**
1041      * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)&#42;)? RPAREN
1042      */
1043     protected abstract Object reduceImportHiding();
1044     /**
1045      * importItem ::= ID
1046      */
1047     protected abstract Object reduceImportValueItem();
1048     /**
1049      * fieldDeclaration ::= ID HASTYPE type
1050      */
1051     protected abstract Object reduceFieldDescription();
1052     /**
1053      * guardedExpEq ::= BAR exp (COMMA exp)&#42; EQUALS exp
1054      */
1055     protected abstract Object reduceGuardedExpEq();
1056     /**
1057      * fundep ::= ID ID&#42; ARROW ID
1058      */
1059     protected abstract Object reduceFundep();
1060     /**
1061      * ruleDeclaration ::= query
1062      */
1063     protected abstract Object reduceQueryRuleDeclaration();
1064     /**
1065      * query ::= exp
1066      */
1067     protected abstract Object reduceGuardQuery();
1068     /**
1069      * query ::= exp EQUALS exp
1070      */
1071     protected abstract Object reduceEqualsQuery();
1072     /**
1073      * query ::= exp BINDS exp
1074      */
1075     protected abstract Object reduceBindQuery();
1076     /**
1077      * query ::= QUERY_OP queryBlock
1078      */
1079     protected abstract Object reduceCompositeQuery();
1080     /**
1081      * lexp ::= faexp faexp&#42;
1082      */
1083     protected abstract Object reduceApply();
1084     /**
1085      * symbol ::= SYMBOL
1086      */
1087     protected abstract Object reduceSymbol();
1088     /**
1089      * symbol ::= ESCAPED_ID
1090      */
1091     protected abstract Object reduceEscapedId();
1092     /**
1093      * symbol ::= MINUS
1094      */
1095     protected abstract Object reduceMinus();
1096     /**
1097      * symbol ::= LESS
1098      */
1099     protected abstract Object reduceLess();
1100     /**
1101      * symbol ::= GREATER
1102      */
1103     protected abstract Object reduceGreater();
1104     /**
1105      * symbol ::= SEPARATED_DOT
1106      */
1107     protected abstract Object reduceDot();
1108     /**
1109      * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)&#42;
1110      */
1111     protected abstract Object reduceFieldAccess();
1112     /**
1113      * accessor ::= ID
1114      */
1115     protected abstract Object reduceIdAccessor();
1116     /**
1117      * accessor ::= BEGIN_STRING END_STRING
1118      */
1119     protected abstract Object reduceStringAccessor();
1120     /**
1121      * accessor ::= LPAREN exp RPAREN
1122      */
1123     protected abstract Object reduceExpAccessor();
1124     /**
1125      * case ::= exp caseRhs
1126      */
1127     protected abstract Object reduceCase();
1128     /**
1129      * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)&#42; query)?)? RBRACE
1130      */
1131     protected abstract Object reduceQueryBlock();
1132     /**
1133      * verboseChrQuery ::= LBRACE chrQuery (SEMICOLON chrQuery)&#42; RBRACE
1134      */
1135     protected abstract Object reduceVerboseCHRConjunction();
1136     /**
1137      * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)&#42; END_STRING
1138      */
1139     protected abstract Object reduceStringLiteral();
1140     /**
1141      * listQualifier ::= exp
1142      */
1143     protected abstract Object reduceGuardQualifier();
1144     /**
1145      * listQualifier ::= exp EQUALS exp
1146      */
1147     protected abstract Object reduceLetQualifier();
1148     /**
1149      * listQualifier ::= exp BINDS exp
1150      */
1151     protected abstract Object reduceBindQualifier();
1152     /**
1153      * listQualifier ::= THEN exp (BY exp)?
1154      */
1155     protected abstract Object reduceThenQualifier();
1156     /**
1157      * chrQuery ::= (chrQueryPart COMMA)&#42; chrQueryPart
1158      */
1159     protected abstract Object reduceCHRConjunction();
1160     /**
1161      * chrQueryPart ::= exp
1162      */
1163     protected abstract Object reduceCHRAtom();
1164     /**
1165      * chrQueryPart ::= exp EQUALS exp
1166      */
1167     protected abstract Object reduceCHREquals();
1168     /**
1169      * chrQueryPart ::= exp BINDS exp
1170      */
1171     protected abstract Object reduceCHRBinds();
1172     /**
1173      * caseRhs ::= ARROW exp (WHERE statements)?
1174      */
1175     protected abstract Object reduceSimpleCaseRhs();
1176     /**
1177      * caseRhs ::= guardedExpArrow guardedExpArrow&#42; (WHERE statements)?
1178      */
1179     protected abstract Object reduceGuardedCaseRhs();
1180     /**
1181      * guardedExpArrow ::= BAR exp (COMMA exp)&#42; ARROW exp
1182      */
1183     protected abstract Object reduceGuardedExpArrow();
1184     /**
1185      * equation ::= exp
1186      */
1187     protected abstract Object reduceGuardEquation();
1188     /**
1189      * equation ::= exp EQUALS exp
1190      */
1191     protected abstract Object reduceBasicEquation();
1192     /**
1193      * etype ::= LESS ID (COMMA ID)&#42; GREATER btype
1194      */
1195     protected abstract Object reduceEffect();
1196     /**
1197      * etype ::= btype
1198      */
1199     protected abstract Object reduceJustEtype();
1200     /**
1201      * etype ::= FORALL ID ID&#42; (SEPARATED_DOT | ATTACHED_DOT) type
1202      */
1203     protected abstract Object reduceForAll();
1204     /**
1205      * btype ::= atype atype&#42;
1206      */
1207     protected abstract Object reduceApplyType();
1208     /**
1209      * dummy ::= COMMENT EOL
1210      */
1211     protected abstract Object reduceDummy();
1212
1213     protected void postReduce(Object reduced) {
1214     }
1215
1216 }