1 package org.simantics.scl.compiler.internal.parsing.parser;
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;
10 import org.simantics.scl.compiler.internal.parsing.Token;
12 public abstract class SCLParser {
13 public static final boolean TRACE = false;
15 private static final int INITIAL_CAPACITY = 16;
16 private static final int STATE_COUNT = 353;
17 private static final int TERMINAL_COUNT = 84;
18 private static final int NONTERMINAL_COUNT = 51;
19 private static final int PRODUCT_COUNT = 134;
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[6588];
24 private static final int[] ERROR_TABLE = new int[927];
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[1620];
28 private static final int[] PRODUCT_LHS = new int[PRODUCT_COUNT];
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;
37 public static final String[] TERMINAL_NAMES = new String[] {
124 public static final String[] NONTERMINAL_NAMES = new String[] {
160 "symbolWithoutMinus",
180 DataInputStream input = new DataInputStream(SCLParser.class.getResourceAsStream("SCLParser.dat"));
181 for(int i=0;i<ACTION_ROW_ID.length;++i)
182 ACTION_ROW_ID[i] = input.readInt();
183 for(int i=0;i<ACTION_COLUMN_ID.length;++i)
184 ACTION_COLUMN_ID[i] = input.readInt();
185 for(int i=0;i<ACTION_TABLE.length;++i)
186 ACTION_TABLE[i] = input.readShort();
187 for(int i=0;i<ERROR_TABLE.length;++i)
188 ERROR_TABLE[i] = input.readInt();
189 for(int i=0;i<GOTO_ROW_ID.length;++i)
190 GOTO_ROW_ID[i] = input.readInt();
191 for(int i=0;i<GOTO_COLUMN_ID.length;++i)
192 GOTO_COLUMN_ID[i] = input.readInt();
193 for(int i=0;i<GOTO_TABLE.length;++i)
194 GOTO_TABLE[i] = input.readShort();
195 for(int i=0;i<PRODUCT_LHS.length;++i)
196 PRODUCT_LHS[i] = input.readInt();
198 } catch(IOException e) {
203 private static short getAction(int state, int symbol) {
204 int id = TERMINAL_COUNT*state + symbol;
205 if( ((ERROR_TABLE[id>>5] >> (id&31))&1) != 0 )
207 return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]];
210 private static short getGoto(int state, int symbol) {
211 return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]];
214 protected abstract Token nextToken();
216 private Object[] symbolStack = new Object[INITIAL_CAPACITY];
217 private int symbolStackLength = 0;
219 private int[] stateStack = new int[INITIAL_CAPACITY];
220 private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY];
221 private int stateStackLength = 0;
224 private int reductionLength;
226 protected int length() {
227 return reductionLength;
230 protected Object get(int i) {
231 if(i < 0 || i >= reductionLength)
232 throw new IndexOutOfBoundsException();
233 return symbolStack[symbolStackLength+i];
236 private String parseErrorDescription(int state, Token token, int tokenId) {
237 StringBuilder b = new StringBuilder();
238 b.append("Unexpected token '").append(token)
239 .append("' (").append(TERMINAL_NAMES[tokenId])
240 .append("). Expected one of ");
241 ArrayList<String> possibleTerminals = new ArrayList<String>();
242 for(int i=0;i<TERMINAL_COUNT;++i)
243 if(getAction(state, i) != ERROR_ACTION)
244 possibleTerminals.add(TERMINAL_NAMES[i]);
245 Collections.sort(possibleTerminals);
246 for(int i=0;i<possibleTerminals.size();++i) {
249 b.append(possibleTerminals.get(i));
255 protected abstract RuntimeException syntaxError(Token token, String description);
257 private static String describeAction(boolean isGoto, int action) {
258 if(action == ERROR_ACTION)
260 if(action == ACCEPT_ACTION)
262 StringBuilder b = new StringBuilder();
266 if((action & REDUCE_MASK) != 0) {
267 action ^= REDUCE_MASK;
273 if((action & POP_MASK) != 0) {
277 if((action & PUSH_MASK) != 0) {
281 b.append(' ').append(action);
285 private void printState(int state) {
286 System.out.print("state=" + state + ":");
287 for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) {
288 Object s = symbolStack[i];
289 if(s instanceof Token)
290 System.out.print(" " + TERMINAL_NAMES[((Token)s).id]);
292 System.out.print(" null");
294 System.out.print(" " + s.getClass().getSimpleName());
295 while(j>=0 && symbolStackPositionStack[j]==i)
296 System.out.print(" (" + stateStack[j--] + ")");
298 System.out.println();
301 private Object parse(int state) {
303 Token token = nextToken();
304 int tokenId = token.id;
306 System.out.println("---> token " + TERMINAL_NAMES[tokenId] + " \"" + token.text + "\" <---");
310 short action = getAction(state, tokenId);
312 System.out.println(" -> action=" + describeAction(false, action));
313 //System.out.println(STATE_DESCRIPTIONS[state]);
314 if((action & REDUCE_MASK) != 0) {
315 if(action == ACCEPT_ACTION)
316 return symbolStack[symbolStackLength-1];
317 if(action == ERROR_ACTION)
318 throw syntaxError(token, parseErrorDescription(state, token, tokenId));
319 int popAmount = (action >>> 13)&3;
322 System.out.println(" POP " + popAmount);
324 stateStackLength -= popAmount;
325 action &= STATE_MASK;
327 int reductionBegin = symbolStackPositionStack[--stateStackLength];
329 reductionLength = symbolStackLength-reductionBegin;
330 symbolStackLength = reductionBegin;
332 if(symbolStackLength == symbolStack.length)
333 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
334 Object symbol = reduce(action);
336 symbolStack[symbolStackLength] = symbol;
338 state = stateStack[stateStackLength];
343 System.out.println(" nonterminal=" + NONTERMINAL_NAMES[PRODUCT_LHS[action]]);
345 action = getGoto(state, PRODUCT_LHS[action]);
347 System.out.println(" -> action=" + describeAction(true, action));
350 if((action & POP_MASK) != 0) {
354 if((action & PUSH_MASK) != 0) {
355 if(stateStackLength == stateStack.length) {
356 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
357 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
359 symbolStackPositionStack[stateStackLength] = symbolStackLength;
360 stateStack[stateStackLength++] = state;
362 state = action & STATE_MASK;
367 if((action & POP_MASK) != 0) {
371 if((action & PUSH_MASK) != 0) {
372 if(stateStackLength == stateStack.length) {
373 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
374 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
376 symbolStackPositionStack[stateStackLength] = symbolStackLength;
377 stateStack[stateStackLength++] = state;
381 state = action & STATE_MASK;
384 if(symbolStackLength == symbolStack.length)
385 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
386 symbolStack[symbolStackLength++] = token;
393 public Object parseModule() {
396 public Object parseCommands() {
399 public Object parseImport() {
402 public Object parseType() {
405 public Object parseExp() {
408 public Object parseEquationBlock() {
413 protected Object reduce(int productionId) {
415 switch(productionId) {
417 return reduceModule();
419 return reduceOneCommand();
421 return reduceManyCommands();
423 return reduceImport();
425 return reduceArrow();
427 return reduceLocalTypeAnnotation();
429 return reduceEquationBlock();
431 return reduceModuleHeader();
433 return reduceTypeAnnotation();
435 return reduceValueDefinition();
437 return reduceDataDefinition();
439 return reduceTypeDefinition();
441 return reduceClassDefinition();
443 return reduceInstanceDefinition();
445 return reduceDerivingInstanceDefinition();
447 return reduceDocumentationString();
449 return reduceAnnotation();
451 return reducePrecedenceDefinition();
453 return reduceJustImport();
455 return reduceImportJava();
457 return reduceEffectDefinition();
459 return reduceRuleDefinition();
461 return reduceMappingRelationDefinition();
463 return reduceRelationDefinition();
465 return reduceRulesetDefinition();
467 return reduceStatementCommand();
469 return reduceImportCommand();
471 return reduceGuardStatement();
473 return reduceLetStatement();
475 return reduceBindStatement();
477 return reduceRuleStatement();
479 return reduceCHRStatement();
481 return reduceVerboseCHRStatement();
483 return reduceConstraintStatement();
485 return reduceLocalInclude();
487 return reduceDeclarations();
489 return reduceField();
491 return reduceFieldShorthand();
493 return reduceVarId();
495 return reduceEscapedSymbol();
497 return reduceTupleConstructor();
499 return reduceBinary();
501 return reduceSimpleRhs();
503 return reduceGuardedRhs();
505 return reduceConstructor();
507 return reduceRecordConstructor();
509 return reduceContext();
511 return reduceFundeps();
513 return reduceTypeVar();
515 return reduceTupleType();
517 return reduceListType();
519 return reduceListTypeConstructor();
521 return reduceTupleTypeConstructor();
523 return reduceLambda();
525 return reduceLambdaMatch();
531 return reduceMatch();
535 return reduceSelect();
537 return reduceEnforce();
541 return reduceHashedId();
543 return reduceBlank();
545 return reduceInteger();
547 return reduceFloat();
549 return reduceString();
553 return reduceTuple();
555 return reduceViewPattern();
557 return reduceRightSection();
559 return reduceLeftSection();
561 return reduceListLiteral();
563 return reduceRange();
565 return reduceListComprehension();
569 return reduceRecord();
571 return reduceTransformation();
575 return reduceRuleDeclarations();
577 return reduceStatements();
579 return reduceImportShowing();
581 return reduceImportHiding();
583 return reduceImportValueItem();
585 return reduceFieldDescription();
587 return reduceGuardedExpEq();
589 return reduceFundep();
591 return reduceQueryRuleDeclaration();
593 return reduceAnnotation();
595 return reduceGuardQuery();
597 return reduceEqualsQuery();
599 return reduceBindQuery();
601 return reduceCompositeQuery();
603 return reduceApply();
605 return reduceSymbol();
607 return reduceEscapedId();
609 return reduceMinus();
613 return reduceGreater();
617 return reduceFieldAccess();
619 return reduceIdAccessor();
621 return reduceStringAccessor();
623 return reduceExpAccessor();
627 return reduceQueryBlock();
629 return reduceStringLiteral();
631 return reduceSymbol();
633 return reduceEscapedId();
637 return reduceGreater();
641 return reduceGuardQualifier();
643 return reduceLetQualifier();
645 return reduceBindQualifier();
647 return reduceThenQualifier();
649 return reduceCHRQuery();
651 return reduceVerboseCHRQuery();
653 return reduceSimpleCaseRhs();
655 return reduceGuardedCaseRhs();
657 return reduceGuardedExpArrow();
659 return reduceGuardEquation();
661 return reduceBasicEquation();
663 return reduceEffect();
665 return reduceJustEtype();
667 return reduceForAll();
669 return reduceApplyType();
671 return reduceDummy();
674 throw new RuntimeException("Internal parser error.");
676 } catch(SCLSyntaxErrorException e) {
677 StringBuilder b = new StringBuilder();
678 b.append("Failed to reduce");
679 for(int i=0;i<length();++i) {
681 b.append("\n (").append(i).append(") \"").append(obj).append('\"');
682 if(obj instanceof Token)
683 b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
685 b.append(" [").append(obj.getClass().getSimpleName()).append("]");
687 throw new RuntimeException(b.toString(), e);
692 * module ::= (declaration (SEMICOLON declaration)*)?
694 protected abstract Object reduceModule();
696 * commands ::= command?
698 protected abstract Object reduceOneCommand();
700 * commands ::= commands SEMICOLON command
702 protected abstract Object reduceManyCommands();
704 * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
706 protected abstract Object reduceImport();
708 * type ::= (etype (ARROW | IMPLIES))* etype
710 protected abstract Object reduceArrow();
712 * exp ::= bexp (HASTYPE type)?
714 protected abstract Object reduceLocalTypeAnnotation();
716 * equationBlock ::= (equation (SEMICOLON equation)*)?
718 protected abstract Object reduceEquationBlock();
720 * declaration ::= MODULE LBRACE (field (COMMA field)*)? RBRACE
722 protected abstract Object reduceModuleHeader();
724 * declaration ::= (var COMMA)* var HASTYPE type
726 protected abstract Object reduceTypeAnnotation();
728 * declaration ::= bexp rhs
730 protected abstract Object reduceValueDefinition();
732 * declaration ::= DATA ID ID* (EQUALS (constructor BAR)* constructor)?
734 protected abstract Object reduceDataDefinition();
736 * declaration ::= TYPE ID ID* EQUALS type
738 protected abstract Object reduceTypeDefinition();
740 * declaration ::= CLASS context? ID ID* (BAR fundeps | (BAR fundeps)? WHERE declarations)?
742 protected abstract Object reduceClassDefinition();
744 * declaration ::= INSTANCE context? ID atype atype* (WHERE declarations)?
746 protected abstract Object reduceInstanceDefinition();
748 * declaration ::= DERIVING INSTANCE context? ID atype atype*
750 protected abstract Object reduceDerivingInstanceDefinition();
752 * declaration ::= BEGIN_STRING END_STRING
754 protected abstract Object reduceDocumentationString();
756 * declaration ::= ANNOTATION_ID aexp*
758 protected abstract Object reduceAnnotation();
760 * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)* var
762 protected abstract Object reducePrecedenceDefinition();
764 * declaration ::= import
766 protected abstract Object reduceJustImport();
768 * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
770 protected abstract Object reduceImportJava();
772 * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
774 protected abstract Object reduceEffectDefinition();
776 * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)* ID)? WHERE ruleDeclarations
778 protected abstract Object reduceRuleDefinition();
780 * declaration ::= MAPPING_RELATION ID atype*
782 protected abstract Object reduceMappingRelationDefinition();
784 * declaration ::= bexp FOLLOWS ruleDeclarations
786 protected abstract Object reduceRelationDefinition();
788 * declaration ::= RULESET ID WHERE statements
790 protected abstract Object reduceRulesetDefinition();
792 * command ::= statement
794 protected abstract Object reduceStatementCommand();
798 protected abstract Object reduceImportCommand();
802 protected abstract Object reduceGuardStatement();
804 * statement ::= exp rhs
806 protected abstract Object reduceLetStatement();
808 * statement ::= exp BINDS exp
810 protected abstract Object reduceBindStatement();
812 * statement ::= exp FOLLOWS queryBlock
814 protected abstract Object reduceRuleStatement();
816 * statement ::= chrQuery IMPLIES chrQuery
818 protected abstract Object reduceCHRStatement();
820 * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
822 protected abstract Object reduceVerboseCHRStatement();
824 * statement ::= CONSTRAINT ID atype*
826 protected abstract Object reduceConstraintStatement();
828 * statement ::= INCLUDE ID aexp
830 protected abstract Object reduceLocalInclude();
832 * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)* declaration)?)? RBRACE
834 protected abstract Object reduceDeclarations();
836 * field ::= ID EQUALS exp
838 protected abstract Object reduceField();
842 protected abstract Object reduceFieldShorthand();
846 protected abstract Object reduceVarId();
848 * var ::= ESCAPED_SYMBOL
850 protected abstract Object reduceEscapedSymbol();
852 * var ::= LPAREN COMMA COMMA* RPAREN
854 protected abstract Object reduceTupleConstructor();
856 * bexp ::= MINUS? lexp (symbol lexp)*
858 protected abstract Object reduceBinary();
860 * rhs ::= EQUALS exp (WHERE statements)?
862 protected abstract Object reduceSimpleRhs();
864 * rhs ::= guardedExpEq guardedExpEq* (WHERE statements)?
866 protected abstract Object reduceGuardedRhs();
868 * constructor ::= (ANNOTATION_ID aexp)* ID atype*
870 protected abstract Object reduceConstructor();
872 * constructor ::= (ANNOTATION_ID aexp)* ID LBRACE fieldDeclaration (COMMA fieldDeclaration)* RBRACE
874 protected abstract Object reduceRecordConstructor();
876 * context ::= LPAREN type (COMMA type)* RPAREN IMPLIES
878 protected abstract Object reduceContext();
880 * fundeps ::= (fundep COMMA)* fundep
882 protected abstract Object reduceFundeps();
886 protected abstract Object reduceTypeVar();
888 * atype ::= LPAREN (type (COMMA (type COMMA)* type)?)? RPAREN
890 protected abstract Object reduceTupleType();
892 * atype ::= LBRACKET type RBRACKET
894 protected abstract Object reduceListType();
896 * atype ::= LBRACKET RBRACKET
898 protected abstract Object reduceListTypeConstructor();
900 * atype ::= LPAREN COMMA COMMA* RPAREN
902 protected abstract Object reduceTupleTypeConstructor();
904 * aexp ::= LAMBDA aexp aexp* ARROW exp
906 protected abstract Object reduceLambda();
908 * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE
910 protected abstract Object reduceLambdaMatch();
912 * aexp ::= LET statements IN exp
914 protected abstract Object reduceLet();
916 * aexp ::= IF exp THEN exp (ELSE exp)?
918 protected abstract Object reduceIf();
920 * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)* RBRACE
922 protected abstract Object reduceMatch();
924 * aexp ::= (DO | MDO) statements
926 protected abstract Object reduceDo();
928 * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
930 protected abstract Object reduceSelect();
932 * aexp ::= ENFORCE queryBlock
934 protected abstract Object reduceEnforce();
938 protected abstract Object reduceVar();
940 * aexp ::= ATTACHED_HASH ID
942 protected abstract Object reduceHashedId();
946 protected abstract Object reduceBlank();
950 protected abstract Object reduceInteger();
954 protected abstract Object reduceFloat();
956 * aexp ::= stringLiteral
958 protected abstract Object reduceString();
962 protected abstract Object reduceChar();
964 * aexp ::= LPAREN (exp (COMMA (exp COMMA)* exp)?)? RPAREN
966 protected abstract Object reduceTuple();
968 * aexp ::= LPAREN exp ARROW exp RPAREN
970 protected abstract Object reduceViewPattern();
972 * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
974 protected abstract Object reduceRightSection();
976 * aexp ::= LPAREN lexp symbol RPAREN
978 protected abstract Object reduceLeftSection();
980 * aexp ::= LBRACKET (exp (COMMA (exp COMMA)* exp)?)? RBRACKET
982 protected abstract Object reduceListLiteral();
984 * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
986 protected abstract Object reduceRange();
988 * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)* RBRACKET
990 protected abstract Object reduceListComprehension();
992 * aexp ::= ID AT aexp
994 protected abstract Object reduceAs();
996 * aexp ::= ID LBRACE (field (COMMA field)*)? RBRACE
998 protected abstract Object reduceRecord();
1000 * aexp ::= TRANSFORMATION ID WHERE queryBlock
1002 protected abstract Object reduceTransformation();
1004 * aexp ::= EQ LBRACE equationBlock RBRACE
1006 protected abstract Object reduceEq();
1008 * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)* ruleDeclaration)?)? RBRACE
1010 protected abstract Object reduceRuleDeclarations();
1012 * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)* statement)?)? RBRACE
1014 protected abstract Object reduceStatements();
1016 * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)* importItem)?)? RPAREN
1018 protected abstract Object reduceImportShowing();
1020 * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN
1022 protected abstract Object reduceImportHiding();
1026 protected abstract Object reduceImportValueItem();
1028 * fieldDeclaration ::= ID HASTYPE type
1030 protected abstract Object reduceFieldDescription();
1032 * guardedExpEq ::= BAR exp (COMMA exp)* EQUALS exp
1034 protected abstract Object reduceGuardedExpEq();
1036 * fundep ::= ID ID* ARROW ID
1038 protected abstract Object reduceFundep();
1040 * ruleDeclaration ::= query
1042 protected abstract Object reduceQueryRuleDeclaration();
1046 protected abstract Object reduceGuardQuery();
1048 * query ::= exp EQUALS exp
1050 protected abstract Object reduceEqualsQuery();
1052 * query ::= exp BINDS exp
1054 protected abstract Object reduceBindQuery();
1056 * query ::= QUERY_OP queryBlock
1058 protected abstract Object reduceCompositeQuery();
1060 * lexp ::= faexp faexp*
1062 protected abstract Object reduceApply();
1066 protected abstract Object reduceSymbol();
1068 * symbol ::= ESCAPED_ID
1070 protected abstract Object reduceEscapedId();
1074 protected abstract Object reduceMinus();
1078 protected abstract Object reduceLess();
1080 * symbol ::= GREATER
1082 protected abstract Object reduceGreater();
1084 * symbol ::= SEPARATED_DOT
1086 protected abstract Object reduceDot();
1088 * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)*
1090 protected abstract Object reduceFieldAccess();
1094 protected abstract Object reduceIdAccessor();
1096 * accessor ::= BEGIN_STRING END_STRING
1098 protected abstract Object reduceStringAccessor();
1100 * accessor ::= LPAREN exp RPAREN
1102 protected abstract Object reduceExpAccessor();
1104 * case ::= exp caseRhs
1106 protected abstract Object reduceCase();
1108 * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)* query)?)? RBRACE
1110 protected abstract Object reduceQueryBlock();
1112 * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING
1114 protected abstract Object reduceStringLiteral();
1116 * listQualifier ::= exp
1118 protected abstract Object reduceGuardQualifier();
1120 * listQualifier ::= exp EQUALS exp
1122 protected abstract Object reduceLetQualifier();
1124 * listQualifier ::= exp BINDS exp
1126 protected abstract Object reduceBindQualifier();
1128 * listQualifier ::= THEN exp (BY exp)?
1130 protected abstract Object reduceThenQualifier();
1132 * chrQuery ::= (listQualifier COMMA)* listQualifier
1134 protected abstract Object reduceCHRQuery();
1136 * verboseChrQuery ::= LBRACE listQualifier (SEMICOLON listQualifier)* RBRACE
1138 protected abstract Object reduceVerboseCHRQuery();
1140 * caseRhs ::= ARROW exp (WHERE statements)?
1142 protected abstract Object reduceSimpleCaseRhs();
1144 * caseRhs ::= guardedExpArrow guardedExpArrow* (WHERE statements)?
1146 protected abstract Object reduceGuardedCaseRhs();
1148 * guardedExpArrow ::= BAR exp (COMMA exp)* ARROW exp
1150 protected abstract Object reduceGuardedExpArrow();
1154 protected abstract Object reduceGuardEquation();
1156 * equation ::= exp EQUALS exp
1158 protected abstract Object reduceBasicEquation();
1160 * etype ::= LESS ID (COMMA ID)* GREATER btype
1162 protected abstract Object reduceEffect();
1166 protected abstract Object reduceJustEtype();
1168 * etype ::= FORALL ID ID* (SEPARATED_DOT | ATTACHED_DOT) type
1170 protected abstract Object reduceForAll();
1172 * btype ::= atype atype*
1174 protected abstract Object reduceApplyType();
1176 * dummy ::= COMMENT EOL
1178 protected abstract Object reduceDummy();
1180 protected void postReduce(Object reduced) {