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