]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java
New type class MonadE and corresponding monad syntax with edo keyword
[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 = 362;
17     private static final int TERMINAL_COUNT = 86;
18     private static final int NONTERMINAL_COUNT = 52;
19     private static final int PRODUCT_COUNT = 138;
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[6832];
24     private static final int[] ERROR_TABLE = new int[973];
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(346);
401     }
402     public Object parseImport() {
403         return parse(354);
404     }
405     public Object parseType() {
406         return parse(356);
407     }
408     public Object parseExp() {
409         return parse(358);
410     }
411     public Object parseEquationBlock() {
412         return parse(360);
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 reduceVarId();
497         case 39:
498             return reduceEscapedSymbol();
499         case 40:
500             return reduceTupleConstructor();
501         case 41:
502             return reduceBinary();
503         case 42:
504             return reduceSimpleRhs();
505         case 43:
506             return reduceGuardedRhs();
507         case 44:
508             return reduceConstructor();
509         case 45:
510             return reduceRecordConstructor();
511         case 46:
512             return reduceContext();
513         case 47:
514             return reduceFundeps();
515         case 48:
516             return reduceTypeVar();
517         case 49:
518             return reduceTupleType();
519         case 50:
520             return reduceListType();
521         case 51:
522             return reduceListTypeConstructor();
523         case 52:
524             return reduceTupleTypeConstructor();
525         case 53:
526             return reduceLambda();
527         case 54:
528             return reduceLambdaMatch();
529         case 55:
530             return reduceLet();
531         case 56:
532             return reduceIf();
533         case 57:
534             return reduceMatch();
535         case 58:
536             return reduceDo();
537         case 59:
538             return reduceSelect();
539         case 60:
540             return reduceCHRSelect();
541         case 61:
542             return reduceEnforce();
543         case 62:
544             return reduceVar();
545         case 63:
546             return reduceHashedId();
547         case 64:
548             return reduceBlank();
549         case 65:
550             return reduceInteger();
551         case 66:
552             return reduceFloat();
553         case 67:
554             return reduceString();
555         case 68:
556             return reduceChar();
557         case 69:
558             return reduceTuple();
559         case 70:
560             return reduceViewPattern();
561         case 71:
562             return reduceRightSection();
563         case 72:
564             return reduceLeftSection();
565         case 73:
566             return reduceListLiteral();
567         case 74:
568             return reduceRange();
569         case 75:
570             return reduceListComprehension();
571         case 76:
572             return reduceAs();
573         case 77:
574             return reduceRecord();
575         case 78:
576             return reduceTransformation();
577         case 79:
578             return reduceEq();
579         case 80:
580             return reduceRuleDeclarations();
581         case 81:
582             return reduceStatements();
583         case 82:
584             return reduceImportShowing();
585         case 83:
586             return reduceImportHiding();
587         case 84:
588             return reduceImportValueItem();
589         case 85:
590             return reduceFieldDescription();
591         case 86:
592             return reduceGuardedExpEq();
593         case 87:
594             return reduceFundep();
595         case 88:
596             return reduceQueryRuleDeclaration();
597         case 89:
598             return reduceAnnotation();
599         case 90:
600             return reduceGuardQuery();
601         case 91:
602             return reduceEqualsQuery();
603         case 92:
604             return reduceBindQuery();
605         case 93:
606             return reduceCompositeQuery();
607         case 94:
608             return reduceApply();
609         case 95:
610             return reduceSymbol();
611         case 96:
612             return reduceEscapedId();
613         case 97:
614             return reduceMinus();
615         case 98:
616             return reduceLess();
617         case 99:
618             return reduceGreater();
619         case 100:
620             return reduceDot();
621         case 101:
622             return reduceFieldAccess();
623         case 102:
624             return reduceIdAccessor();
625         case 103:
626             return reduceStringAccessor();
627         case 104:
628             return reduceExpAccessor();
629         case 105:
630             return reduceCase();
631         case 106:
632             return reduceQueryBlock();
633         case 107:
634             return reduceVerboseCHRConjunction();
635         case 108:
636             return reduceStringLiteral();
637         case 109:
638             return reduceSymbol();
639         case 110:
640             return reduceEscapedId();
641         case 111:
642             return reduceLess();
643         case 112:
644             return reduceGreater();
645         case 113:
646             return reduceDot();
647         case 114:
648             return reduceGuardQualifier();
649         case 115:
650             return reduceLetQualifier();
651         case 116:
652             return reduceBindQualifier();
653         case 117:
654             return reduceThenQualifier();
655         case 118:
656             return reduceCHRConjunction();
657         case 119:
658             return reduceCHRAtom();
659         case 120:
660             return reduceCHREquals();
661         case 121:
662             return reduceCHRBinds();
663         case 122:
664             return reduceSimpleCaseRhs();
665         case 123:
666             return reduceGuardedCaseRhs();
667         case 124:
668             return reduceGuardedExpArrow();
669         case 125:
670             return reduceGuardEquation();
671         case 126:
672             return reduceBasicEquation();
673         case 127:
674             return reduceEffect();
675         case 128:
676             return reduceJustEtype();
677         case 129:
678             return reduceForAll();
679         case 130:
680             return reduceApplyType();
681         case 131:
682             return reduceDummy();
683
684         default:
685             throw new RuntimeException("Internal parser error.");
686         }
687         } catch(SCLSyntaxErrorException e) {
688             StringBuilder b = new StringBuilder();
689             b.append("Failed to reduce");
690             for(int i=0;i<length();++i) {
691                 Object obj = get(i);
692                 b.append("\n    (").append(i).append(") \"").append(obj).append('\"');
693                 if(obj instanceof Token)
694                     b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
695                 else
696                     b.append(" [").append(obj.getClass().getSimpleName()).append("]");
697             }
698             throw new RuntimeException(b.toString(), e);
699         } 
700     }
701
702     /**
703      * module ::= (declaration (SEMICOLON declaration)&#42;)?
704      */
705     protected abstract Object reduceModule();
706     /**
707      * commands ::= command?
708      */
709     protected abstract Object reduceOneCommand();
710     /**
711      * commands ::= commands SEMICOLON command
712      */
713     protected abstract Object reduceManyCommands();
714     /**
715      * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
716      */
717     protected abstract Object reduceImport();
718     /**
719      * type ::= (etype (ARROW | IMPLIES))&#42; etype
720      */
721     protected abstract Object reduceArrow();
722     /**
723      * exp ::= bexp (HASTYPE type)?
724      */
725     protected abstract Object reduceLocalTypeAnnotation();
726     /**
727      * equationBlock ::= (equation (SEMICOLON equation)&#42;)?
728      */
729     protected abstract Object reduceEquationBlock();
730     /**
731      * declaration ::= MODULE LBRACE (field (COMMA field)&#42;)? RBRACE
732      */
733     protected abstract Object reduceModuleHeader();
734     /**
735      * declaration ::= (var COMMA)&#42; var HASTYPE type
736      */
737     protected abstract Object reduceTypeAnnotation();
738     /**
739      * declaration ::= bexp rhs
740      */
741     protected abstract Object reduceValueDefinition();
742     /**
743      * declaration ::= DATA ID ID&#42; (EQUALS (constructor BAR)&#42; constructor)?
744      */
745     protected abstract Object reduceDataDefinition();
746     /**
747      * declaration ::= TYPE ID ID&#42; EQUALS type
748      */
749     protected abstract Object reduceTypeDefinition();
750     /**
751      * declaration ::= CLASS context? ID ID&#42; (BAR fundeps | (BAR fundeps)? WHERE declarations)?
752      */
753     protected abstract Object reduceClassDefinition();
754     /**
755      * declaration ::= INSTANCE context? ID atype atype&#42; (WHERE declarations)?
756      */
757     protected abstract Object reduceInstanceDefinition();
758     /**
759      * declaration ::= DERIVING INSTANCE context? ID atype atype&#42;
760      */
761     protected abstract Object reduceDerivingInstanceDefinition();
762     /**
763      * declaration ::= BEGIN_STRING END_STRING
764      */
765     protected abstract Object reduceDocumentationString();
766     /**
767      * declaration ::= ANNOTATION_ID aexp&#42;
768      */
769     protected abstract Object reduceAnnotation();
770     /**
771      * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)&#42; var
772      */
773     protected abstract Object reducePrecedenceDefinition();
774     /**
775      * declaration ::= import
776      */
777     protected abstract Object reduceJustImport();
778     /**
779      * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
780      */
781     protected abstract Object reduceImportJava();
782     /**
783      * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
784      */
785     protected abstract Object reduceEffectDefinition();
786     /**
787      * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)&#42; ID)? WHERE ruleDeclarations
788      */
789     protected abstract Object reduceRuleDefinition();
790     /**
791      * declaration ::= MAPPING_RELATION ID atype&#42;
792      */
793     protected abstract Object reduceMappingRelationDefinition();
794     /**
795      * declaration ::= bexp FOLLOWS ruleDeclarations
796      */
797     protected abstract Object reduceRelationDefinition();
798     /**
799      * declaration ::= RULESET ID WHERE statements
800      */
801     protected abstract Object reduceRulesetDefinition();
802     /**
803      * command ::= statement
804      */
805     protected abstract Object reduceStatementCommand();
806     /**
807      * command ::= import
808      */
809     protected abstract Object reduceImportCommand();
810     /**
811      * statement ::= exp
812      */
813     protected abstract Object reduceGuardStatement();
814     /**
815      * statement ::= exp rhs
816      */
817     protected abstract Object reduceLetStatement();
818     /**
819      * statement ::= exp BINDS exp
820      */
821     protected abstract Object reduceBindStatement();
822     /**
823      * statement ::= exp FOLLOWS queryBlock
824      */
825     protected abstract Object reduceRuleStatement();
826     /**
827      * statement ::= chrQuery IMPLIES chrQuery
828      */
829     protected abstract Object reduceCHRStatement();
830     /**
831      * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
832      */
833     protected abstract Object reduceVerboseCHRStatement();
834     /**
835      * statement ::= CONSTRAINT constructor
836      */
837     protected abstract Object reduceConstraintStatement();
838     /**
839      * statement ::= INCLUDE ID aexp
840      */
841     protected abstract Object reduceLocalInclude();
842     /**
843      * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)&#42; declaration)?)? RBRACE
844      */
845     protected abstract Object reduceDeclarations();
846     /**
847      * field ::= ID EQUALS exp
848      */
849     protected abstract Object reduceField();
850     /**
851      * field ::= ID
852      */
853     protected abstract Object reduceFieldShorthand();
854     /**
855      * var ::= ID
856      */
857     protected abstract Object reduceVarId();
858     /**
859      * var ::= ESCAPED_SYMBOL
860      */
861     protected abstract Object reduceEscapedSymbol();
862     /**
863      * var ::= LPAREN COMMA COMMA&#42; RPAREN
864      */
865     protected abstract Object reduceTupleConstructor();
866     /**
867      * bexp ::= MINUS? lexp (symbol lexp)&#42;
868      */
869     protected abstract Object reduceBinary();
870     /**
871      * rhs ::= EQUALS exp (WHERE statements)?
872      */
873     protected abstract Object reduceSimpleRhs();
874     /**
875      * rhs ::= guardedExpEq guardedExpEq&#42; (WHERE statements)?
876      */
877     protected abstract Object reduceGuardedRhs();
878     /**
879      * constructor ::= (ANNOTATION_ID aexp)&#42; ID atype&#42;
880      */
881     protected abstract Object reduceConstructor();
882     /**
883      * constructor ::= (ANNOTATION_ID aexp)&#42; ID LBRACE fieldDeclaration (COMMA fieldDeclaration)&#42; RBRACE
884      */
885     protected abstract Object reduceRecordConstructor();
886     /**
887      * context ::= LPAREN type (COMMA type)&#42; RPAREN IMPLIES
888      */
889     protected abstract Object reduceContext();
890     /**
891      * fundeps ::= (fundep COMMA)&#42; fundep
892      */
893     protected abstract Object reduceFundeps();
894     /**
895      * atype ::= ID
896      */
897     protected abstract Object reduceTypeVar();
898     /**
899      * atype ::= LPAREN (type (COMMA (type COMMA)&#42; type)?)? RPAREN
900      */
901     protected abstract Object reduceTupleType();
902     /**
903      * atype ::= LBRACKET type RBRACKET
904      */
905     protected abstract Object reduceListType();
906     /**
907      * atype ::= LBRACKET RBRACKET
908      */
909     protected abstract Object reduceListTypeConstructor();
910     /**
911      * atype ::= LPAREN COMMA COMMA&#42; RPAREN
912      */
913     protected abstract Object reduceTupleTypeConstructor();
914     /**
915      * aexp ::= LAMBDA aexp aexp&#42; ARROW exp
916      */
917     protected abstract Object reduceLambda();
918     /**
919      * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)&#42; RBRACE
920      */
921     protected abstract Object reduceLambdaMatch();
922     /**
923      * aexp ::= LET statements IN exp
924      */
925     protected abstract Object reduceLet();
926     /**
927      * aexp ::= IF exp THEN exp (ELSE exp)?
928      */
929     protected abstract Object reduceIf();
930     /**
931      * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)&#42; RBRACE
932      */
933     protected abstract Object reduceMatch();
934     /**
935      * aexp ::= (DO | MDO | EDO) statements
936      */
937     protected abstract Object reduceDo();
938     /**
939      * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
940      */
941     protected abstract Object reduceSelect();
942     /**
943      * aexp ::= CHR_SELECT exp WHERE verboseChrQuery
944      */
945     protected abstract Object reduceCHRSelect();
946     /**
947      * aexp ::= ENFORCE queryBlock
948      */
949     protected abstract Object reduceEnforce();
950     /**
951      * aexp ::= var
952      */
953     protected abstract Object reduceVar();
954     /**
955      * aexp ::= ATTACHED_HASH ID
956      */
957     protected abstract Object reduceHashedId();
958     /**
959      * aexp ::= BLANK
960      */
961     protected abstract Object reduceBlank();
962     /**
963      * aexp ::= INTEGER
964      */
965     protected abstract Object reduceInteger();
966     /**
967      * aexp ::= FLOAT
968      */
969     protected abstract Object reduceFloat();
970     /**
971      * aexp ::= stringLiteral
972      */
973     protected abstract Object reduceString();
974     /**
975      * aexp ::= CHAR
976      */
977     protected abstract Object reduceChar();
978     /**
979      * aexp ::= LPAREN (exp (COMMA (exp COMMA)&#42; exp)?)? RPAREN
980      */
981     protected abstract Object reduceTuple();
982     /**
983      * aexp ::= LPAREN exp ARROW exp RPAREN
984      */
985     protected abstract Object reduceViewPattern();
986     /**
987      * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
988      */
989     protected abstract Object reduceRightSection();
990     /**
991      * aexp ::= LPAREN lexp symbol RPAREN
992      */
993     protected abstract Object reduceLeftSection();
994     /**
995      * aexp ::= LBRACKET (exp (COMMA (exp COMMA)&#42; exp)?)? RBRACKET
996      */
997     protected abstract Object reduceListLiteral();
998     /**
999      * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
1000      */
1001     protected abstract Object reduceRange();
1002     /**
1003      * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)&#42; RBRACKET
1004      */
1005     protected abstract Object reduceListComprehension();
1006     /**
1007      * aexp ::= ID AT aexp
1008      */
1009     protected abstract Object reduceAs();
1010     /**
1011      * aexp ::= ID LBRACE (field (COMMA field)&#42;)? RBRACE
1012      */
1013     protected abstract Object reduceRecord();
1014     /**
1015      * aexp ::= TRANSFORMATION ID WHERE queryBlock
1016      */
1017     protected abstract Object reduceTransformation();
1018     /**
1019      * aexp ::= EQ LBRACE equationBlock RBRACE
1020      */
1021     protected abstract Object reduceEq();
1022     /**
1023      * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)&#42; ruleDeclaration)?)? RBRACE
1024      */
1025     protected abstract Object reduceRuleDeclarations();
1026     /**
1027      * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)&#42; statement)?)? RBRACE
1028      */
1029     protected abstract Object reduceStatements();
1030     /**
1031      * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)&#42; importItem)?)? RPAREN
1032      */
1033     protected abstract Object reduceImportShowing();
1034     /**
1035      * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)&#42;)? RPAREN
1036      */
1037     protected abstract Object reduceImportHiding();
1038     /**
1039      * importItem ::= ID
1040      */
1041     protected abstract Object reduceImportValueItem();
1042     /**
1043      * fieldDeclaration ::= ID HASTYPE type
1044      */
1045     protected abstract Object reduceFieldDescription();
1046     /**
1047      * guardedExpEq ::= BAR exp (COMMA exp)&#42; EQUALS exp
1048      */
1049     protected abstract Object reduceGuardedExpEq();
1050     /**
1051      * fundep ::= ID ID&#42; ARROW ID
1052      */
1053     protected abstract Object reduceFundep();
1054     /**
1055      * ruleDeclaration ::= query
1056      */
1057     protected abstract Object reduceQueryRuleDeclaration();
1058     /**
1059      * query ::= exp
1060      */
1061     protected abstract Object reduceGuardQuery();
1062     /**
1063      * query ::= exp EQUALS exp
1064      */
1065     protected abstract Object reduceEqualsQuery();
1066     /**
1067      * query ::= exp BINDS exp
1068      */
1069     protected abstract Object reduceBindQuery();
1070     /**
1071      * query ::= QUERY_OP queryBlock
1072      */
1073     protected abstract Object reduceCompositeQuery();
1074     /**
1075      * lexp ::= faexp faexp&#42;
1076      */
1077     protected abstract Object reduceApply();
1078     /**
1079      * symbol ::= SYMBOL
1080      */
1081     protected abstract Object reduceSymbol();
1082     /**
1083      * symbol ::= ESCAPED_ID
1084      */
1085     protected abstract Object reduceEscapedId();
1086     /**
1087      * symbol ::= MINUS
1088      */
1089     protected abstract Object reduceMinus();
1090     /**
1091      * symbol ::= LESS
1092      */
1093     protected abstract Object reduceLess();
1094     /**
1095      * symbol ::= GREATER
1096      */
1097     protected abstract Object reduceGreater();
1098     /**
1099      * symbol ::= SEPARATED_DOT
1100      */
1101     protected abstract Object reduceDot();
1102     /**
1103      * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)&#42;
1104      */
1105     protected abstract Object reduceFieldAccess();
1106     /**
1107      * accessor ::= ID
1108      */
1109     protected abstract Object reduceIdAccessor();
1110     /**
1111      * accessor ::= BEGIN_STRING END_STRING
1112      */
1113     protected abstract Object reduceStringAccessor();
1114     /**
1115      * accessor ::= LPAREN exp RPAREN
1116      */
1117     protected abstract Object reduceExpAccessor();
1118     /**
1119      * case ::= exp caseRhs
1120      */
1121     protected abstract Object reduceCase();
1122     /**
1123      * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)&#42; query)?)? RBRACE
1124      */
1125     protected abstract Object reduceQueryBlock();
1126     /**
1127      * verboseChrQuery ::= LBRACE chrQuery (SEMICOLON chrQuery)&#42; RBRACE
1128      */
1129     protected abstract Object reduceVerboseCHRConjunction();
1130     /**
1131      * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)&#42; END_STRING
1132      */
1133     protected abstract Object reduceStringLiteral();
1134     /**
1135      * listQualifier ::= exp
1136      */
1137     protected abstract Object reduceGuardQualifier();
1138     /**
1139      * listQualifier ::= exp EQUALS exp
1140      */
1141     protected abstract Object reduceLetQualifier();
1142     /**
1143      * listQualifier ::= exp BINDS exp
1144      */
1145     protected abstract Object reduceBindQualifier();
1146     /**
1147      * listQualifier ::= THEN exp (BY exp)?
1148      */
1149     protected abstract Object reduceThenQualifier();
1150     /**
1151      * chrQuery ::= (chrQueryPart COMMA)&#42; chrQueryPart
1152      */
1153     protected abstract Object reduceCHRConjunction();
1154     /**
1155      * chrQueryPart ::= exp
1156      */
1157     protected abstract Object reduceCHRAtom();
1158     /**
1159      * chrQueryPart ::= exp EQUALS exp
1160      */
1161     protected abstract Object reduceCHREquals();
1162     /**
1163      * chrQueryPart ::= exp BINDS exp
1164      */
1165     protected abstract Object reduceCHRBinds();
1166     /**
1167      * caseRhs ::= ARROW exp (WHERE statements)?
1168      */
1169     protected abstract Object reduceSimpleCaseRhs();
1170     /**
1171      * caseRhs ::= guardedExpArrow guardedExpArrow&#42; (WHERE statements)?
1172      */
1173     protected abstract Object reduceGuardedCaseRhs();
1174     /**
1175      * guardedExpArrow ::= BAR exp (COMMA exp)&#42; ARROW exp
1176      */
1177     protected abstract Object reduceGuardedExpArrow();
1178     /**
1179      * equation ::= exp
1180      */
1181     protected abstract Object reduceGuardEquation();
1182     /**
1183      * equation ::= exp EQUALS exp
1184      */
1185     protected abstract Object reduceBasicEquation();
1186     /**
1187      * etype ::= LESS ID (COMMA ID)&#42; GREATER btype
1188      */
1189     protected abstract Object reduceEffect();
1190     /**
1191      * etype ::= btype
1192      */
1193     protected abstract Object reduceJustEtype();
1194     /**
1195      * etype ::= FORALL ID ID&#42; (SEPARATED_DOT | ATTACHED_DOT) type
1196      */
1197     protected abstract Object reduceForAll();
1198     /**
1199      * btype ::= atype atype&#42;
1200      */
1201     protected abstract Object reduceApplyType();
1202     /**
1203      * dummy ::= COMMENT EOL
1204      */
1205     protected abstract Object reduceDummy();
1206
1207     protected void postReduce(Object reduced) {
1208     }
1209
1210 }