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