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