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 = 345;
17 private static final int TERMINAL_COUNT = 83;
18 private static final int NONTERMINAL_COUNT = 51;
19 private static final int PRODUCT_COUNT = 132;
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[6360];
24 private static final int[] ERROR_TABLE = new int[895];
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[1711];
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 reduceEquationBlock();
430 return reduceModuleHeader();
432 return reduceTypeAnnotation();
434 return reduceValueDefinition();
436 return reduceDataDefinition();
438 return reduceTypeDefinition();
440 return reduceClassDefinition();
442 return reduceInstanceDefinition();
444 return reduceDerivingInstanceDefinition();
446 return reduceDocumentationString();
448 return reduceAnnotation();
450 return reducePrecedenceDefinition();
452 return reduceJustImport();
454 return reduceImportJava();
456 return reduceEffectDefinition();
458 return reduceRuleDefinition();
460 return reduceMappingRelationDefinition();
462 return reduceRelationDefinition();
464 return reduceStatementCommand();
466 return reduceImportCommand();
468 return reduceGuardStatement();
470 return reduceLetStatement();
472 return reduceBindStatement();
474 return reduceRuleStatement();
476 return reduceCHRStatement();
478 return reduceVerboseCHRStatement();
480 return reduceConstraintStatement();
482 return reduceDeclarations();
484 return reduceField();
486 return reduceFieldShorthand();
488 return reduceVarId();
490 return reduceEscapedSymbol();
492 return reduceTupleConstructor();
494 return reduceBinary();
496 return reduceSimpleRhs();
498 return reduceGuardedRhs();
500 return reduceConstructor();
502 return reduceRecordConstructor();
504 return reduceContext();
506 return reduceFundeps();
508 return reduceTypeVar();
510 return reduceTupleType();
512 return reduceListType();
514 return reduceListTypeConstructor();
516 return reduceTupleTypeConstructor();
518 return reduceLambda();
520 return reduceLambdaMatch();
526 return reduceMatch();
530 return reduceSelect();
532 return reduceEnforce();
536 return reduceHashedId();
538 return reduceBlank();
540 return reduceInteger();
542 return reduceFloat();
544 return reduceString();
548 return reduceTuple();
550 return reduceViewPattern();
552 return reduceRightSection();
554 return reduceLeftSection();
556 return reduceListLiteral();
558 return reduceRange();
560 return reduceListComprehension();
564 return reduceRecord();
566 return reduceTransformation();
570 return reduceRuleDeclarations();
572 return reduceImportShowing();
574 return reduceImportHiding();
576 return reduceImportValueItem();
578 return reduceFieldDescription();
580 return reduceStatements();
582 return reduceGuardedExpEq();
584 return reduceFundep();
586 return reduceQueryRuleDeclaration();
588 return reduceAnnotation();
590 return reduceGuardQuery();
592 return reduceEqualsQuery();
594 return reduceBindQuery();
596 return reduceCompositeQuery();
598 return reduceApply();
600 return reduceSymbol();
602 return reduceEscapedId();
604 return reduceMinus();
608 return reduceGreater();
612 return reduceFieldAccess();
614 return reduceIdAccessor();
616 return reduceStringAccessor();
618 return reduceExpAccessor();
622 return reduceQueryBlock();
624 return reduceStringLiteral();
626 return reduceSymbol();
628 return reduceEscapedId();
632 return reduceGreater();
636 return reduceGuardQualifier();
638 return reduceLetQualifier();
640 return reduceBindQualifier();
642 return reduceThenQualifier();
644 return reduceCHRQuery();
646 return reduceVerboseCHRQuery();
648 return reduceSimpleCaseRhs();
650 return reduceGuardedCaseRhs();
652 return reduceGuardedExpArrow();
654 return reduceGuardEquation();
656 return reduceBasicEquation();
658 return reduceEffect();
660 return reduceJustEtype();
662 return reduceForAll();
664 return reduceApplyType();
666 return reduceDummy();
669 throw new RuntimeException("Internal parser error.");
671 } catch(SCLSyntaxErrorException e) {
672 StringBuilder b = new StringBuilder();
673 b.append("Failed to reduce");
674 for(int i=0;i<length();++i) {
676 b.append("\n (").append(i).append(") \"").append(obj).append('\"');
677 if(obj instanceof Token)
678 b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
680 b.append(" [").append(obj.getClass().getSimpleName()).append("]");
682 throw new RuntimeException(b.toString(), e);
687 * module ::= (declaration (SEMICOLON declaration)*)?
689 protected abstract Object reduceModule();
691 * commands ::= command?
693 protected abstract Object reduceOneCommand();
695 * commands ::= commands SEMICOLON command
697 protected abstract Object reduceManyCommands();
699 * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
701 protected abstract Object reduceImport();
703 * type ::= (etype (ARROW | IMPLIES))* etype
705 protected abstract Object reduceArrow();
707 * exp ::= bexp (HASTYPE type)?
709 protected abstract Object reduceLocalTypeAnnotation();
711 * equationBlock ::= (equation (SEMICOLON equation)*)?
713 protected abstract Object reduceEquationBlock();
715 * declaration ::= MODULE LBRACE (field (COMMA field)*)? RBRACE
717 protected abstract Object reduceModuleHeader();
719 * declaration ::= (var COMMA)* var HASTYPE type
721 protected abstract Object reduceTypeAnnotation();
723 * declaration ::= bexp rhs
725 protected abstract Object reduceValueDefinition();
727 * declaration ::= DATA ID ID* (EQUALS (constructor BAR)* constructor)?
729 protected abstract Object reduceDataDefinition();
731 * declaration ::= TYPE ID ID* EQUALS type
733 protected abstract Object reduceTypeDefinition();
735 * declaration ::= CLASS context? ID ID* (BAR fundeps | (BAR fundeps)? WHERE declarations)?
737 protected abstract Object reduceClassDefinition();
739 * declaration ::= INSTANCE context? ID atype atype* (WHERE declarations)?
741 protected abstract Object reduceInstanceDefinition();
743 * declaration ::= DERIVING INSTANCE context? ID atype atype*
745 protected abstract Object reduceDerivingInstanceDefinition();
747 * declaration ::= BEGIN_STRING END_STRING
749 protected abstract Object reduceDocumentationString();
751 * declaration ::= ANNOTATION_ID aexp*
753 protected abstract Object reduceAnnotation();
755 * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)* var
757 protected abstract Object reducePrecedenceDefinition();
759 * declaration ::= import
761 protected abstract Object reduceJustImport();
763 * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
765 protected abstract Object reduceImportJava();
767 * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
769 protected abstract Object reduceEffectDefinition();
771 * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)* ID)? WHERE ruleDeclarations
773 protected abstract Object reduceRuleDefinition();
775 * declaration ::= MAPPING_RELATION ID atype*
777 protected abstract Object reduceMappingRelationDefinition();
779 * declaration ::= bexp FOLLOWS ruleDeclarations
781 protected abstract Object reduceRelationDefinition();
783 * command ::= statement
785 protected abstract Object reduceStatementCommand();
789 protected abstract Object reduceImportCommand();
793 protected abstract Object reduceGuardStatement();
795 * statement ::= exp rhs
797 protected abstract Object reduceLetStatement();
799 * statement ::= exp BINDS exp
801 protected abstract Object reduceBindStatement();
803 * statement ::= exp FOLLOWS queryBlock
805 protected abstract Object reduceRuleStatement();
807 * statement ::= chrQuery IMPLIES chrQuery
809 protected abstract Object reduceCHRStatement();
811 * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
813 protected abstract Object reduceVerboseCHRStatement();
815 * statement ::= CONSTRAINT ID atype*
817 protected abstract Object reduceConstraintStatement();
819 * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)* declaration)?)? RBRACE
821 protected abstract Object reduceDeclarations();
823 * field ::= ID EQUALS exp
825 protected abstract Object reduceField();
829 protected abstract Object reduceFieldShorthand();
833 protected abstract Object reduceVarId();
835 * var ::= ESCAPED_SYMBOL
837 protected abstract Object reduceEscapedSymbol();
839 * var ::= LPAREN COMMA COMMA* RPAREN
841 protected abstract Object reduceTupleConstructor();
843 * bexp ::= MINUS? lexp (symbol lexp)*
845 protected abstract Object reduceBinary();
847 * rhs ::= EQUALS exp (WHERE statements)?
849 protected abstract Object reduceSimpleRhs();
851 * rhs ::= guardedExpEq guardedExpEq* (WHERE statements)?
853 protected abstract Object reduceGuardedRhs();
855 * constructor ::= (ANNOTATION_ID aexp)* ID atype*
857 protected abstract Object reduceConstructor();
859 * constructor ::= (ANNOTATION_ID aexp)* ID LBRACE fieldDeclaration (COMMA fieldDeclaration)* RBRACE
861 protected abstract Object reduceRecordConstructor();
863 * context ::= LPAREN type (COMMA type)* RPAREN IMPLIES
865 protected abstract Object reduceContext();
867 * fundeps ::= (fundep COMMA)* fundep
869 protected abstract Object reduceFundeps();
873 protected abstract Object reduceTypeVar();
875 * atype ::= LPAREN (type (COMMA (type COMMA)* type)?)? RPAREN
877 protected abstract Object reduceTupleType();
879 * atype ::= LBRACKET type RBRACKET
881 protected abstract Object reduceListType();
883 * atype ::= LBRACKET RBRACKET
885 protected abstract Object reduceListTypeConstructor();
887 * atype ::= LPAREN COMMA COMMA* RPAREN
889 protected abstract Object reduceTupleTypeConstructor();
891 * aexp ::= LAMBDA aexp aexp* ARROW exp
893 protected abstract Object reduceLambda();
895 * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE
897 protected abstract Object reduceLambdaMatch();
899 * aexp ::= LET statements IN exp
901 protected abstract Object reduceLet();
903 * aexp ::= IF exp THEN exp (ELSE exp)?
905 protected abstract Object reduceIf();
907 * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)* RBRACE
909 protected abstract Object reduceMatch();
911 * aexp ::= (DO | MDO) statements
913 protected abstract Object reduceDo();
915 * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
917 protected abstract Object reduceSelect();
919 * aexp ::= ENFORCE queryBlock
921 protected abstract Object reduceEnforce();
925 protected abstract Object reduceVar();
927 * aexp ::= ATTACHED_HASH ID
929 protected abstract Object reduceHashedId();
933 protected abstract Object reduceBlank();
937 protected abstract Object reduceInteger();
941 protected abstract Object reduceFloat();
943 * aexp ::= stringLiteral
945 protected abstract Object reduceString();
949 protected abstract Object reduceChar();
951 * aexp ::= LPAREN (exp (COMMA (exp COMMA)* exp)?)? RPAREN
953 protected abstract Object reduceTuple();
955 * aexp ::= LPAREN exp ARROW exp RPAREN
957 protected abstract Object reduceViewPattern();
959 * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
961 protected abstract Object reduceRightSection();
963 * aexp ::= LPAREN lexp symbol RPAREN
965 protected abstract Object reduceLeftSection();
967 * aexp ::= LBRACKET (exp (COMMA (exp COMMA)* exp)?)? RBRACKET
969 protected abstract Object reduceListLiteral();
971 * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
973 protected abstract Object reduceRange();
975 * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)* RBRACKET
977 protected abstract Object reduceListComprehension();
979 * aexp ::= ID AT aexp
981 protected abstract Object reduceAs();
983 * aexp ::= ID LBRACE (field (COMMA field)*)? RBRACE
985 protected abstract Object reduceRecord();
987 * aexp ::= TRANSFORMATION ID WHERE queryBlock
989 protected abstract Object reduceTransformation();
991 * aexp ::= EQ LBRACE equationBlock RBRACE
993 protected abstract Object reduceEq();
995 * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)* ruleDeclaration)?)? RBRACE
997 protected abstract Object reduceRuleDeclarations();
999 * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)* importItem)?)? RPAREN
1001 protected abstract Object reduceImportShowing();
1003 * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN
1005 protected abstract Object reduceImportHiding();
1009 protected abstract Object reduceImportValueItem();
1011 * fieldDeclaration ::= ID HASTYPE type
1013 protected abstract Object reduceFieldDescription();
1015 * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)* statement)?)? RBRACE
1017 protected abstract Object reduceStatements();
1019 * guardedExpEq ::= BAR exp (COMMA exp)* EQUALS exp
1021 protected abstract Object reduceGuardedExpEq();
1023 * fundep ::= ID ID* ARROW ID
1025 protected abstract Object reduceFundep();
1027 * ruleDeclaration ::= query
1029 protected abstract Object reduceQueryRuleDeclaration();
1033 protected abstract Object reduceGuardQuery();
1035 * query ::= exp EQUALS exp
1037 protected abstract Object reduceEqualsQuery();
1039 * query ::= exp BINDS exp
1041 protected abstract Object reduceBindQuery();
1043 * query ::= QUERY_OP queryBlock
1045 protected abstract Object reduceCompositeQuery();
1047 * lexp ::= faexp faexp*
1049 protected abstract Object reduceApply();
1053 protected abstract Object reduceSymbol();
1055 * symbol ::= ESCAPED_ID
1057 protected abstract Object reduceEscapedId();
1061 protected abstract Object reduceMinus();
1065 protected abstract Object reduceLess();
1067 * symbol ::= GREATER
1069 protected abstract Object reduceGreater();
1071 * symbol ::= SEPARATED_DOT
1073 protected abstract Object reduceDot();
1075 * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)*
1077 protected abstract Object reduceFieldAccess();
1081 protected abstract Object reduceIdAccessor();
1083 * accessor ::= BEGIN_STRING END_STRING
1085 protected abstract Object reduceStringAccessor();
1087 * accessor ::= LPAREN exp RPAREN
1089 protected abstract Object reduceExpAccessor();
1091 * case ::= exp caseRhs
1093 protected abstract Object reduceCase();
1095 * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)* query)?)? RBRACE
1097 protected abstract Object reduceQueryBlock();
1099 * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING
1101 protected abstract Object reduceStringLiteral();
1103 * listQualifier ::= exp
1105 protected abstract Object reduceGuardQualifier();
1107 * listQualifier ::= exp EQUALS exp
1109 protected abstract Object reduceLetQualifier();
1111 * listQualifier ::= exp BINDS exp
1113 protected abstract Object reduceBindQualifier();
1115 * listQualifier ::= THEN exp (BY exp)?
1117 protected abstract Object reduceThenQualifier();
1119 * chrQuery ::= (listQualifier COMMA)* listQualifier
1121 protected abstract Object reduceCHRQuery();
1123 * verboseChrQuery ::= LBRACE listQualifier (SEMICOLON listQualifier)* RBRACE
1125 protected abstract Object reduceVerboseCHRQuery();
1127 * caseRhs ::= ARROW exp (WHERE statements)?
1129 protected abstract Object reduceSimpleCaseRhs();
1131 * caseRhs ::= guardedExpArrow guardedExpArrow* (WHERE statements)?
1133 protected abstract Object reduceGuardedCaseRhs();
1135 * guardedExpArrow ::= BAR exp (COMMA exp)* ARROW exp
1137 protected abstract Object reduceGuardedExpArrow();
1141 protected abstract Object reduceGuardEquation();
1143 * equation ::= exp EQUALS exp
1145 protected abstract Object reduceBasicEquation();
1147 * etype ::= LESS ID (COMMA ID)* GREATER btype
1149 protected abstract Object reduceEffect();
1153 protected abstract Object reduceJustEtype();
1155 * etype ::= FORALL ID ID* (SEPARATED_DOT | ATTACHED_DOT) type
1157 protected abstract Object reduceForAll();
1159 * btype ::= atype atype*
1161 protected abstract Object reduceApplyType();
1163 * dummy ::= COMMENT EOL
1165 protected abstract Object reduceDummy();
1167 protected void postReduce(Object reduced) {