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 = 349;
17 private static final int TERMINAL_COUNT = 83;
18 private static final int NONTERMINAL_COUNT = 51;
19 private static final int PRODUCT_COUNT = 133;
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[6396];
24 private static final int[] ERROR_TABLE = new int[906];
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[1652];
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[] {
123 public static final String[] NONTERMINAL_NAMES = new String[] {
159 "symbolWithoutMinus",
179 DataInputStream input = new DataInputStream(SCLParser.class.getResourceAsStream("SCLParser.dat"));
180 for(int i=0;i<ACTION_ROW_ID.length;++i)
181 ACTION_ROW_ID[i] = input.readInt();
182 for(int i=0;i<ACTION_COLUMN_ID.length;++i)
183 ACTION_COLUMN_ID[i] = input.readInt();
184 for(int i=0;i<ACTION_TABLE.length;++i)
185 ACTION_TABLE[i] = input.readShort();
186 for(int i=0;i<ERROR_TABLE.length;++i)
187 ERROR_TABLE[i] = input.readInt();
188 for(int i=0;i<GOTO_ROW_ID.length;++i)
189 GOTO_ROW_ID[i] = input.readInt();
190 for(int i=0;i<GOTO_COLUMN_ID.length;++i)
191 GOTO_COLUMN_ID[i] = input.readInt();
192 for(int i=0;i<GOTO_TABLE.length;++i)
193 GOTO_TABLE[i] = input.readShort();
194 for(int i=0;i<PRODUCT_LHS.length;++i)
195 PRODUCT_LHS[i] = input.readInt();
197 } catch(IOException e) {
202 private static short getAction(int state, int symbol) {
203 int id = TERMINAL_COUNT*state + symbol;
204 if( ((ERROR_TABLE[id>>5] >> (id&31))&1) != 0 )
206 return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]];
209 private static short getGoto(int state, int symbol) {
210 return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]];
213 protected abstract Token nextToken();
215 private Object[] symbolStack = new Object[INITIAL_CAPACITY];
216 private int symbolStackLength = 0;
218 private int[] stateStack = new int[INITIAL_CAPACITY];
219 private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY];
220 private int stateStackLength = 0;
223 private int reductionLength;
225 protected int length() {
226 return reductionLength;
229 protected Object get(int i) {
230 if(i < 0 || i >= reductionLength)
231 throw new IndexOutOfBoundsException();
232 return symbolStack[symbolStackLength+i];
235 private String parseErrorDescription(int state, Token token, int tokenId) {
236 StringBuilder b = new StringBuilder();
237 b.append("Unexpected token '").append(token)
238 .append("' (").append(TERMINAL_NAMES[tokenId])
239 .append("). Expected one of ");
240 ArrayList<String> possibleTerminals = new ArrayList<String>();
241 for(int i=0;i<TERMINAL_COUNT;++i)
242 if(getAction(state, i) != ERROR_ACTION)
243 possibleTerminals.add(TERMINAL_NAMES[i]);
244 Collections.sort(possibleTerminals);
245 for(int i=0;i<possibleTerminals.size();++i) {
248 b.append(possibleTerminals.get(i));
254 protected abstract RuntimeException syntaxError(Token token, String description);
256 private static String describeAction(boolean isGoto, int action) {
257 if(action == ERROR_ACTION)
259 if(action == ACCEPT_ACTION)
261 StringBuilder b = new StringBuilder();
265 if((action & REDUCE_MASK) != 0) {
266 action ^= REDUCE_MASK;
272 if((action & POP_MASK) != 0) {
276 if((action & PUSH_MASK) != 0) {
280 b.append(' ').append(action);
284 private void printState(int state) {
285 System.out.print("state=" + state + ":");
286 for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) {
287 Object s = symbolStack[i];
288 if(s instanceof Token)
289 System.out.print(" " + TERMINAL_NAMES[((Token)s).id]);
291 System.out.print(" null");
293 System.out.print(" " + s.getClass().getSimpleName());
294 while(j>=0 && symbolStackPositionStack[j]==i)
295 System.out.print(" (" + stateStack[j--] + ")");
297 System.out.println();
300 private Object parse(int state) {
302 Token token = nextToken();
303 int tokenId = token.id;
305 System.out.println("---> token " + TERMINAL_NAMES[tokenId] + " \"" + token.text + "\" <---");
309 short action = getAction(state, tokenId);
311 System.out.println(" -> action=" + describeAction(false, action));
312 //System.out.println(STATE_DESCRIPTIONS[state]);
313 if((action & REDUCE_MASK) != 0) {
314 if(action == ACCEPT_ACTION)
315 return symbolStack[symbolStackLength-1];
316 if(action == ERROR_ACTION)
317 throw syntaxError(token, parseErrorDescription(state, token, tokenId));
318 int popAmount = (action >>> 13)&3;
321 System.out.println(" POP " + popAmount);
323 stateStackLength -= popAmount;
324 action &= STATE_MASK;
326 int reductionBegin = symbolStackPositionStack[--stateStackLength];
328 reductionLength = symbolStackLength-reductionBegin;
329 symbolStackLength = reductionBegin;
331 if(symbolStackLength == symbolStack.length)
332 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
333 Object symbol = reduce(action);
335 symbolStack[symbolStackLength] = symbol;
337 state = stateStack[stateStackLength];
342 System.out.println(" nonterminal=" + NONTERMINAL_NAMES[PRODUCT_LHS[action]]);
344 action = getGoto(state, PRODUCT_LHS[action]);
346 System.out.println(" -> action=" + describeAction(true, action));
349 if((action & POP_MASK) != 0) {
353 if((action & PUSH_MASK) != 0) {
354 if(stateStackLength == stateStack.length) {
355 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
356 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
358 symbolStackPositionStack[stateStackLength] = symbolStackLength;
359 stateStack[stateStackLength++] = state;
361 state = action & STATE_MASK;
366 if((action & POP_MASK) != 0) {
370 if((action & PUSH_MASK) != 0) {
371 if(stateStackLength == stateStack.length) {
372 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
373 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
375 symbolStackPositionStack[stateStackLength] = symbolStackLength;
376 stateStack[stateStackLength++] = state;
380 state = action & STATE_MASK;
383 if(symbolStackLength == symbolStack.length)
384 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
385 symbolStack[symbolStackLength++] = token;
392 public Object parseModule() {
395 public Object parseCommands() {
398 public Object parseImport() {
401 public Object parseType() {
404 public Object parseExp() {
407 public Object parseEquationBlock() {
412 protected Object reduce(int productionId) {
414 switch(productionId) {
416 return reduceModule();
418 return reduceOneCommand();
420 return reduceManyCommands();
422 return reduceImport();
424 return reduceArrow();
426 return reduceLocalTypeAnnotation();
428 return reduceEntityTypeAnnotation();
430 return reduceEquationBlock();
432 return reduceModuleHeader();
434 return reduceTypeAnnotation();
436 return reduceValueDefinition();
438 return reduceDataDefinition();
440 return reduceTypeDefinition();
442 return reduceClassDefinition();
444 return reduceInstanceDefinition();
446 return reduceDerivingInstanceDefinition();
448 return reduceDocumentationString();
450 return reduceAnnotation();
452 return reducePrecedenceDefinition();
454 return reduceJustImport();
456 return reduceImportJava();
458 return reduceEffectDefinition();
460 return reduceRuleDefinition();
462 return reduceMappingRelationDefinition();
464 return reduceRelationDefinition();
466 return reduceStatementCommand();
468 return reduceImportCommand();
470 return reduceGuardStatement();
472 return reduceLetStatement();
474 return reduceBindStatement();
476 return reduceRuleStatement();
478 return reduceCHRStatement();
480 return reduceVerboseCHRStatement();
482 return reduceConstraintStatement();
484 return reduceDeclarations();
486 return reduceField();
488 return reduceFieldShorthand();
490 return reduceVarId();
492 return reduceEscapedSymbol();
494 return reduceTupleConstructor();
496 return reduceBinary();
498 return reduceSimpleRhs();
500 return reduceGuardedRhs();
502 return reduceConstructor();
504 return reduceRecordConstructor();
506 return reduceContext();
508 return reduceFundeps();
510 return reduceTypeVar();
512 return reduceTupleType();
514 return reduceListType();
516 return reduceListTypeConstructor();
518 return reduceTupleTypeConstructor();
520 return reduceLambda();
522 return reduceLambdaMatch();
528 return reduceMatch();
532 return reduceSelect();
534 return reduceEnforce();
538 return reduceHashedId();
540 return reduceBlank();
542 return reduceInteger();
544 return reduceFloat();
546 return reduceString();
550 return reduceTuple();
552 return reduceViewPattern();
554 return reduceRightSection();
556 return reduceLeftSection();
558 return reduceListLiteral();
560 return reduceRange();
562 return reduceListComprehension();
566 return reduceRecord();
568 return reduceTransformation();
572 return reduceRuleDeclarations();
574 return reduceImportShowing();
576 return reduceImportHiding();
578 return reduceImportValueItem();
580 return reduceFieldDescription();
582 return reduceStatements();
584 return reduceGuardedExpEq();
586 return reduceFundep();
588 return reduceQueryRuleDeclaration();
590 return reduceAnnotation();
592 return reduceGuardQuery();
594 return reduceEqualsQuery();
596 return reduceBindQuery();
598 return reduceCompositeQuery();
600 return reduceQueryBlock();
602 return reduceApply();
604 return reduceSymbol();
606 return reduceEscapedId();
608 return reduceMinus();
612 return reduceGreater();
616 return reduceFieldAccess();
618 return reduceIdAccessor();
620 return reduceStringAccessor();
622 return reduceExpAccessor();
626 return reduceStringLiteral();
628 return reduceSymbol();
630 return reduceEscapedId();
634 return reduceGreater();
638 return reduceGuardQualifier();
640 return reduceLetQualifier();
642 return reduceBindQualifier();
644 return reduceThenQualifier();
646 return reduceCHRQuery();
648 return reduceVerboseCHRQuery();
650 return reduceSimpleCaseRhs();
652 return reduceGuardedCaseRhs();
654 return reduceGuardedExpArrow();
656 return reduceGuardEquation();
658 return reduceBasicEquation();
660 return reduceEffect();
662 return reduceJustEtype();
664 return reduceForAll();
666 return reduceApplyType();
668 return reduceDummy();
671 throw new RuntimeException("Internal parser error.");
673 } catch(SCLSyntaxErrorException e) {
674 StringBuilder b = new StringBuilder();
675 b.append("Failed to reduce");
676 for(int i=0;i<length();++i) {
678 b.append("\n (").append(i).append(") \"").append(obj).append('\"');
679 if(obj instanceof Token)
680 b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
682 b.append(" [").append(obj.getClass().getSimpleName()).append("]");
684 throw new RuntimeException(b.toString(), e);
689 * module ::= (declaration (SEMICOLON declaration)*)?
691 protected abstract Object reduceModule();
693 * commands ::= command?
695 protected abstract Object reduceOneCommand();
697 * commands ::= commands SEMICOLON command
699 protected abstract Object reduceManyCommands();
701 * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
703 protected abstract Object reduceImport();
705 * type ::= (etype (ARROW | IMPLIES))* etype
707 protected abstract Object reduceArrow();
709 * exp ::= bexp (HASTYPE type)?
711 protected abstract Object reduceLocalTypeAnnotation();
713 * exp ::= bexp COLON ID (queryBlock | WITH queryBlock?)?
715 protected abstract Object reduceEntityTypeAnnotation();
717 * equationBlock ::= (equation (SEMICOLON equation)*)?
719 protected abstract Object reduceEquationBlock();
721 * declaration ::= MODULE LBRACE (field (COMMA field)*)? RBRACE
723 protected abstract Object reduceModuleHeader();
725 * declaration ::= (var COMMA)* var HASTYPE type
727 protected abstract Object reduceTypeAnnotation();
729 * declaration ::= bexp rhs
731 protected abstract Object reduceValueDefinition();
733 * declaration ::= DATA ID ID* (EQUALS (constructor BAR)* constructor)?
735 protected abstract Object reduceDataDefinition();
737 * declaration ::= TYPE ID ID* EQUALS type
739 protected abstract Object reduceTypeDefinition();
741 * declaration ::= CLASS context? ID ID* (BAR fundeps | (BAR fundeps)? WHERE declarations)?
743 protected abstract Object reduceClassDefinition();
745 * declaration ::= INSTANCE context? ID atype atype* (WHERE declarations)?
747 protected abstract Object reduceInstanceDefinition();
749 * declaration ::= DERIVING INSTANCE context? ID atype atype*
751 protected abstract Object reduceDerivingInstanceDefinition();
753 * declaration ::= BEGIN_STRING END_STRING
755 protected abstract Object reduceDocumentationString();
757 * declaration ::= ANNOTATION_ID aexp*
759 protected abstract Object reduceAnnotation();
761 * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)* var
763 protected abstract Object reducePrecedenceDefinition();
765 * declaration ::= import
767 protected abstract Object reduceJustImport();
769 * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
771 protected abstract Object reduceImportJava();
773 * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
775 protected abstract Object reduceEffectDefinition();
777 * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)* ID)? WHERE ruleDeclarations
779 protected abstract Object reduceRuleDefinition();
781 * declaration ::= MAPPING_RELATION ID atype*
783 protected abstract Object reduceMappingRelationDefinition();
785 * declaration ::= bexp FOLLOWS ruleDeclarations
787 protected abstract Object reduceRelationDefinition();
789 * command ::= statement
791 protected abstract Object reduceStatementCommand();
795 protected abstract Object reduceImportCommand();
799 protected abstract Object reduceGuardStatement();
801 * statement ::= exp rhs
803 protected abstract Object reduceLetStatement();
805 * statement ::= exp BINDS exp
807 protected abstract Object reduceBindStatement();
809 * statement ::= exp FOLLOWS queryBlock
811 protected abstract Object reduceRuleStatement();
813 * statement ::= chrQuery IMPLIES chrQuery
815 protected abstract Object reduceCHRStatement();
817 * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
819 protected abstract Object reduceVerboseCHRStatement();
821 * statement ::= CONSTRAINT ID atype*
823 protected abstract Object reduceConstraintStatement();
825 * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)* declaration)?)? RBRACE
827 protected abstract Object reduceDeclarations();
829 * field ::= ID EQUALS exp
831 protected abstract Object reduceField();
835 protected abstract Object reduceFieldShorthand();
839 protected abstract Object reduceVarId();
841 * var ::= ESCAPED_SYMBOL
843 protected abstract Object reduceEscapedSymbol();
845 * var ::= LPAREN COMMA COMMA* RPAREN
847 protected abstract Object reduceTupleConstructor();
849 * bexp ::= MINUS? lexp (symbol lexp)*
851 protected abstract Object reduceBinary();
853 * rhs ::= EQUALS exp (WHERE statements)?
855 protected abstract Object reduceSimpleRhs();
857 * rhs ::= guardedExpEq guardedExpEq* (WHERE statements)?
859 protected abstract Object reduceGuardedRhs();
861 * constructor ::= (ANNOTATION_ID aexp)* ID atype*
863 protected abstract Object reduceConstructor();
865 * constructor ::= (ANNOTATION_ID aexp)* ID LBRACE fieldDeclaration (COMMA fieldDeclaration)* RBRACE
867 protected abstract Object reduceRecordConstructor();
869 * context ::= LPAREN type (COMMA type)* RPAREN IMPLIES
871 protected abstract Object reduceContext();
873 * fundeps ::= (fundep COMMA)* fundep
875 protected abstract Object reduceFundeps();
879 protected abstract Object reduceTypeVar();
881 * atype ::= LPAREN (type (COMMA (type COMMA)* type)?)? RPAREN
883 protected abstract Object reduceTupleType();
885 * atype ::= LBRACKET type RBRACKET
887 protected abstract Object reduceListType();
889 * atype ::= LBRACKET RBRACKET
891 protected abstract Object reduceListTypeConstructor();
893 * atype ::= LPAREN COMMA COMMA* RPAREN
895 protected abstract Object reduceTupleTypeConstructor();
897 * aexp ::= LAMBDA aexp aexp* ARROW exp
899 protected abstract Object reduceLambda();
901 * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE
903 protected abstract Object reduceLambdaMatch();
905 * aexp ::= LET statements IN exp
907 protected abstract Object reduceLet();
909 * aexp ::= IF exp THEN exp (ELSE exp)?
911 protected abstract Object reduceIf();
913 * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)* RBRACE
915 protected abstract Object reduceMatch();
917 * aexp ::= (DO | MDO) statements
919 protected abstract Object reduceDo();
921 * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
923 protected abstract Object reduceSelect();
925 * aexp ::= ENFORCE queryBlock
927 protected abstract Object reduceEnforce();
931 protected abstract Object reduceVar();
933 * aexp ::= ATTACHED_HASH ID
935 protected abstract Object reduceHashedId();
939 protected abstract Object reduceBlank();
943 protected abstract Object reduceInteger();
947 protected abstract Object reduceFloat();
949 * aexp ::= stringLiteral
951 protected abstract Object reduceString();
955 protected abstract Object reduceChar();
957 * aexp ::= LPAREN (exp (COMMA (exp COMMA)* exp)?)? RPAREN
959 protected abstract Object reduceTuple();
961 * aexp ::= LPAREN exp ARROW exp RPAREN
963 protected abstract Object reduceViewPattern();
965 * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
967 protected abstract Object reduceRightSection();
969 * aexp ::= LPAREN lexp symbol RPAREN
971 protected abstract Object reduceLeftSection();
973 * aexp ::= LBRACKET (exp (COMMA (exp COMMA)* exp)?)? RBRACKET
975 protected abstract Object reduceListLiteral();
977 * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
979 protected abstract Object reduceRange();
981 * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)* RBRACKET
983 protected abstract Object reduceListComprehension();
985 * aexp ::= ID AT aexp
987 protected abstract Object reduceAs();
989 * aexp ::= ID LBRACE (field (COMMA field)*)? RBRACE
991 protected abstract Object reduceRecord();
993 * aexp ::= TRANSFORMATION ID WHERE queryBlock
995 protected abstract Object reduceTransformation();
997 * aexp ::= EQ LBRACE equationBlock RBRACE
999 protected abstract Object reduceEq();
1001 * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)* ruleDeclaration)?)? RBRACE
1003 protected abstract Object reduceRuleDeclarations();
1005 * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)* importItem)?)? RPAREN
1007 protected abstract Object reduceImportShowing();
1009 * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN
1011 protected abstract Object reduceImportHiding();
1015 protected abstract Object reduceImportValueItem();
1017 * fieldDeclaration ::= ID HASTYPE type
1019 protected abstract Object reduceFieldDescription();
1021 * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)* statement)?)? RBRACE
1023 protected abstract Object reduceStatements();
1025 * guardedExpEq ::= BAR exp (COMMA exp)* EQUALS exp
1027 protected abstract Object reduceGuardedExpEq();
1029 * fundep ::= ID ID* ARROW ID
1031 protected abstract Object reduceFundep();
1033 * ruleDeclaration ::= query
1035 protected abstract Object reduceQueryRuleDeclaration();
1039 protected abstract Object reduceGuardQuery();
1041 * query ::= exp EQUALS exp
1043 protected abstract Object reduceEqualsQuery();
1045 * query ::= exp BINDS exp
1047 protected abstract Object reduceBindQuery();
1049 * query ::= QUERY_OP queryBlock
1051 protected abstract Object reduceCompositeQuery();
1053 * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)* query)?)? RBRACE
1055 protected abstract Object reduceQueryBlock();
1057 * lexp ::= faexp faexp*
1059 protected abstract Object reduceApply();
1063 protected abstract Object reduceSymbol();
1065 * symbol ::= ESCAPED_ID
1067 protected abstract Object reduceEscapedId();
1071 protected abstract Object reduceMinus();
1075 protected abstract Object reduceLess();
1077 * symbol ::= GREATER
1079 protected abstract Object reduceGreater();
1081 * symbol ::= SEPARATED_DOT
1083 protected abstract Object reduceDot();
1085 * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)*
1087 protected abstract Object reduceFieldAccess();
1091 protected abstract Object reduceIdAccessor();
1093 * accessor ::= BEGIN_STRING END_STRING
1095 protected abstract Object reduceStringAccessor();
1097 * accessor ::= LPAREN exp RPAREN
1099 protected abstract Object reduceExpAccessor();
1101 * case ::= exp caseRhs
1103 protected abstract Object reduceCase();
1105 * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING
1107 protected abstract Object reduceStringLiteral();
1109 * listQualifier ::= exp
1111 protected abstract Object reduceGuardQualifier();
1113 * listQualifier ::= exp EQUALS exp
1115 protected abstract Object reduceLetQualifier();
1117 * listQualifier ::= exp BINDS exp
1119 protected abstract Object reduceBindQualifier();
1121 * listQualifier ::= THEN exp (BY exp)?
1123 protected abstract Object reduceThenQualifier();
1125 * chrQuery ::= (listQualifier COMMA)* listQualifier
1127 protected abstract Object reduceCHRQuery();
1129 * verboseChrQuery ::= LBRACE listQualifier (SEMICOLON listQualifier)* RBRACE
1131 protected abstract Object reduceVerboseCHRQuery();
1133 * caseRhs ::= ARROW exp (WHERE statements)?
1135 protected abstract Object reduceSimpleCaseRhs();
1137 * caseRhs ::= guardedExpArrow guardedExpArrow* (WHERE statements)?
1139 protected abstract Object reduceGuardedCaseRhs();
1141 * guardedExpArrow ::= BAR exp (COMMA exp)* ARROW exp
1143 protected abstract Object reduceGuardedExpArrow();
1147 protected abstract Object reduceGuardEquation();
1149 * equation ::= exp EQUALS exp
1151 protected abstract Object reduceBasicEquation();
1153 * etype ::= LESS ID (COMMA ID)* GREATER btype
1155 protected abstract Object reduceEffect();
1159 protected abstract Object reduceJustEtype();
1161 * etype ::= FORALL ID ID* (SEPARATED_DOT | ATTACHED_DOT) type
1163 protected abstract Object reduceForAll();
1165 * btype ::= atype atype*
1167 protected abstract Object reduceApplyType();
1169 * dummy ::= COMMENT EOL
1171 protected abstract Object reduceDummy();
1173 protected void postReduce(Object reduced) {