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 = 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;
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];
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[] {
122 public static final String[] NONTERMINAL_NAMES = new String[] {
157 "symbolWithoutMinus",
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();
196 } catch(IOException e) {
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 )
205 return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]];
208 private static short getGoto(int state, int symbol) {
209 return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]];
212 protected abstract Token nextToken();
214 private Object[] symbolStack = new Object[INITIAL_CAPACITY];
215 private int symbolStackLength = 0;
217 private int[] stateStack = new int[INITIAL_CAPACITY];
218 private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY];
219 private int stateStackLength = 0;
222 private int reductionLength;
224 protected int length() {
225 return reductionLength;
228 protected Object get(int i) {
229 if(i < 0 || i >= reductionLength)
230 throw new IndexOutOfBoundsException();
231 return symbolStack[symbolStackLength+i];
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) {
247 b.append(possibleTerminals.get(i));
253 protected abstract RuntimeException syntaxError(Token token, String description);
255 private static String describeAction(boolean isGoto, int action) {
256 if(action == ERROR_ACTION)
258 if(action == ACCEPT_ACTION)
260 StringBuilder b = new StringBuilder();
264 if((action & REDUCE_MASK) != 0) {
265 action ^= REDUCE_MASK;
271 if((action & POP_MASK) != 0) {
275 if((action & PUSH_MASK) != 0) {
279 b.append(' ').append(action);
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]);
290 System.out.print(" null");
292 System.out.print(" " + s.getClass().getSimpleName());
293 while(j>=0 && symbolStackPositionStack[j]==i)
294 System.out.print(" (" + stateStack[j--] + ")");
296 System.out.println();
299 private Object parse(int state) {
301 Token token = nextToken();
302 int tokenId = token.id;
304 System.out.println("---> token " + TERMINAL_NAMES[tokenId] + " \"" + token.text + "\" <---");
308 short action = getAction(state, tokenId);
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;
320 System.out.println(" POP " + popAmount);
322 stateStackLength -= popAmount;
323 action &= STATE_MASK;
325 int reductionBegin = symbolStackPositionStack[--stateStackLength];
327 reductionLength = symbolStackLength-reductionBegin;
328 symbolStackLength = reductionBegin;
330 if(symbolStackLength == symbolStack.length)
331 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
332 Object symbol = reduce(action);
334 symbolStack[symbolStackLength] = symbol;
336 state = stateStack[stateStackLength];
341 System.out.println(" nonterminal=" + NONTERMINAL_NAMES[PRODUCT_LHS[action]]);
343 action = getGoto(state, PRODUCT_LHS[action]);
345 System.out.println(" -> action=" + describeAction(true, action));
348 if((action & POP_MASK) != 0) {
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);
357 symbolStackPositionStack[stateStackLength] = symbolStackLength;
358 stateStack[stateStackLength++] = state;
360 state = action & STATE_MASK;
365 if((action & POP_MASK) != 0) {
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);
374 symbolStackPositionStack[stateStackLength] = symbolStackLength;
375 stateStack[stateStackLength++] = state;
379 state = action & STATE_MASK;
382 if(symbolStackLength == symbolStack.length)
383 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
384 symbolStack[symbolStackLength++] = token;
391 public Object parseModule() {
394 public Object parseCommands() {
397 public Object parseImport() {
400 public Object parseType() {
403 public Object parseExp() {
406 public Object parseEquationBlock() {
411 protected Object reduce(int productionId) {
413 switch(productionId) {
415 return reduceModule();
417 return reduceOneCommand();
419 return reduceManyCommands();
421 return reduceImport();
423 return reduceArrow();
425 return reduceLocalTypeAnnotation();
427 return reduceEntityTypeAnnotation();
429 return reduceEquationBlock();
431 return reduceTypeAnnotation();
433 return reduceValueDefinition();
435 return reduceDataDefinition();
437 return reduceTypeDefinition();
439 return reduceClassDefinition();
441 return reduceInstanceDefinition();
443 return reduceDerivingInstanceDefinition();
445 return reduceDocumentationString();
447 return reduceAnnotation();
449 return reducePrecedenceDefinition();
451 return reduceJustImport();
453 return reduceImportJava();
455 return reduceEffectDefinition();
457 return reduceRuleDefinition();
459 return reduceMappingRelationDefinition();
461 return reduceRelationDefinition();
463 return reduceStatementCommand();
465 return reduceImportCommand();
467 return reduceGuardStatement();
469 return reduceLetStatement();
471 return reduceBindStatement();
473 return reduceRuleStatement();
475 return reduceCHRStatement();
477 return reduceVerboseCHRStatement();
479 return reduceConstraintStatement();
481 return reduceDeclarations();
483 return reduceVarId();
485 return reduceEscapedSymbol();
487 return reduceTupleConstructor();
489 return reduceBinary();
491 return reduceSimpleRhs();
493 return reduceGuardedRhs();
495 return reduceConstructor();
497 return reduceRecordConstructor();
499 return reduceContext();
501 return reduceFundeps();
503 return reduceTypeVar();
505 return reduceTupleType();
507 return reduceListType();
509 return reduceListTypeConstructor();
511 return reduceTupleTypeConstructor();
513 return reduceLambda();
515 return reduceLambdaMatch();
521 return reduceMatch();
525 return reduceSelect();
527 return reduceEnforce();
531 return reduceHashedId();
533 return reduceBlank();
535 return reduceInteger();
537 return reduceFloat();
539 return reduceString();
543 return reduceTuple();
545 return reduceViewPattern();
547 return reduceRightSection();
549 return reduceLeftSection();
551 return reduceListLiteral();
553 return reduceRange();
555 return reduceListComprehension();
559 return reduceRecord();
561 return reduceTransformation();
565 return reduceRuleDeclarations();
567 return reduceImportShowing();
569 return reduceImportHiding();
571 return reduceImportValueItem();
573 return reduceFieldDescription();
575 return reduceStatements();
577 return reduceGuardedExpEq();
579 return reduceFundep();
581 return reduceQueryRuleDeclaration();
583 return reduceAnnotation();
585 return reduceGuardQuery();
587 return reduceEqualsQuery();
589 return reduceBindQuery();
591 return reduceCompositeQuery();
593 return reduceQueryBlock();
595 return reduceApply();
597 return reduceSymbol();
599 return reduceEscapedId();
601 return reduceMinus();
605 return reduceGreater();
609 return reduceFieldAccess();
611 return reduceIdAccessor();
613 return reduceStringAccessor();
615 return reduceExpAccessor();
619 return reduceStringLiteral();
621 return reduceSymbol();
623 return reduceEscapedId();
627 return reduceGreater();
631 return reduceGuardQualifier();
633 return reduceLetQualifier();
635 return reduceBindQualifier();
637 return reduceThenQualifier();
639 return reduceField();
641 return reduceFieldShorthand();
643 return reduceCHRQuery();
645 return reduceVerboseCHRQuery();
647 return reduceSimpleCaseRhs();
649 return reduceGuardedCaseRhs();
651 return reduceGuardedExpArrow();
653 return reduceGuardEquation();
655 return reduceBasicEquation();
657 return reduceEffect();
659 return reduceJustEtype();
661 return reduceForAll();
663 return reduceApplyType();
665 return reduceDummy();
668 throw new RuntimeException("Internal parser error.");
670 } catch(SCLSyntaxErrorException e) {
671 StringBuilder b = new StringBuilder();
672 b.append("Failed to reduce");
673 for(int i=0;i<length();++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(")");
679 b.append(" [").append(obj.getClass().getSimpleName()).append("]");
681 throw new RuntimeException(b.toString(), e);
686 * module ::= (declaration (SEMICOLON declaration)*)?
688 protected abstract Object reduceModule();
690 * commands ::= command?
692 protected abstract Object reduceOneCommand();
694 * commands ::= commands SEMICOLON command
696 protected abstract Object reduceManyCommands();
698 * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
700 protected abstract Object reduceImport();
702 * type ::= (etype (ARROW | IMPLIES))* etype
704 protected abstract Object reduceArrow();
706 * exp ::= bexp (HASTYPE type)?
708 protected abstract Object reduceLocalTypeAnnotation();
710 * exp ::= bexp COLON ID (queryBlock | WITH queryBlock?)?
712 protected abstract Object reduceEntityTypeAnnotation();
714 * equationBlock ::= (equation (SEMICOLON equation)*)?
716 protected abstract Object reduceEquationBlock();
718 * declaration ::= (var COMMA)* var HASTYPE type
720 protected abstract Object reduceTypeAnnotation();
722 * declaration ::= bexp rhs
724 protected abstract Object reduceValueDefinition();
726 * declaration ::= DATA ID ID* (EQUALS (constructor BAR)* constructor)?
728 protected abstract Object reduceDataDefinition();
730 * declaration ::= TYPE ID ID* EQUALS type
732 protected abstract Object reduceTypeDefinition();
734 * declaration ::= CLASS context? ID ID* (BAR fundeps | (BAR fundeps)? WHERE declarations)?
736 protected abstract Object reduceClassDefinition();
738 * declaration ::= INSTANCE context? ID atype atype* (WHERE declarations)?
740 protected abstract Object reduceInstanceDefinition();
742 * declaration ::= DERIVING INSTANCE context? ID atype atype*
744 protected abstract Object reduceDerivingInstanceDefinition();
746 * declaration ::= BEGIN_STRING END_STRING
748 protected abstract Object reduceDocumentationString();
750 * declaration ::= ANNOTATION_ID aexp*
752 protected abstract Object reduceAnnotation();
754 * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)* var
756 protected abstract Object reducePrecedenceDefinition();
758 * declaration ::= import
760 protected abstract Object reduceJustImport();
762 * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
764 protected abstract Object reduceImportJava();
766 * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
768 protected abstract Object reduceEffectDefinition();
770 * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)* ID)? WHERE ruleDeclarations
772 protected abstract Object reduceRuleDefinition();
774 * declaration ::= MAPPING_RELATION ID atype*
776 protected abstract Object reduceMappingRelationDefinition();
778 * declaration ::= bexp FOLLOWS ruleDeclarations
780 protected abstract Object reduceRelationDefinition();
782 * command ::= statement
784 protected abstract Object reduceStatementCommand();
788 protected abstract Object reduceImportCommand();
792 protected abstract Object reduceGuardStatement();
794 * statement ::= exp rhs
796 protected abstract Object reduceLetStatement();
798 * statement ::= exp BINDS exp
800 protected abstract Object reduceBindStatement();
802 * statement ::= exp FOLLOWS queryBlock
804 protected abstract Object reduceRuleStatement();
806 * statement ::= chrQuery IMPLIES chrQuery
808 protected abstract Object reduceCHRStatement();
810 * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
812 protected abstract Object reduceVerboseCHRStatement();
814 * statement ::= CONSTRAINT ID atype*
816 protected abstract Object reduceConstraintStatement();
818 * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)* declaration)?)? RBRACE
820 protected abstract Object reduceDeclarations();
824 protected abstract Object reduceVarId();
826 * var ::= ESCAPED_SYMBOL
828 protected abstract Object reduceEscapedSymbol();
830 * var ::= LPAREN COMMA COMMA* RPAREN
832 protected abstract Object reduceTupleConstructor();
834 * bexp ::= MINUS? lexp (symbol lexp)*
836 protected abstract Object reduceBinary();
838 * rhs ::= EQUALS exp (WHERE statements)?
840 protected abstract Object reduceSimpleRhs();
842 * rhs ::= guardedExpEq guardedExpEq* (WHERE statements)?
844 protected abstract Object reduceGuardedRhs();
846 * constructor ::= (ANNOTATION_ID aexp)* ID atype*
848 protected abstract Object reduceConstructor();
850 * constructor ::= (ANNOTATION_ID aexp)* ID LBRACE fieldDeclaration (COMMA fieldDeclaration)* RBRACE
852 protected abstract Object reduceRecordConstructor();
854 * context ::= LPAREN type (COMMA type)* RPAREN IMPLIES
856 protected abstract Object reduceContext();
858 * fundeps ::= (fundep COMMA)* fundep
860 protected abstract Object reduceFundeps();
864 protected abstract Object reduceTypeVar();
866 * atype ::= LPAREN (type (COMMA (type COMMA)* type)?)? RPAREN
868 protected abstract Object reduceTupleType();
870 * atype ::= LBRACKET type RBRACKET
872 protected abstract Object reduceListType();
874 * atype ::= LBRACKET RBRACKET
876 protected abstract Object reduceListTypeConstructor();
878 * atype ::= LPAREN COMMA COMMA* RPAREN
880 protected abstract Object reduceTupleTypeConstructor();
882 * aexp ::= LAMBDA aexp aexp* ARROW exp
884 protected abstract Object reduceLambda();
886 * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE
888 protected abstract Object reduceLambdaMatch();
890 * aexp ::= LET statements IN exp
892 protected abstract Object reduceLet();
894 * aexp ::= IF exp THEN exp (ELSE exp)?
896 protected abstract Object reduceIf();
898 * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)* RBRACE
900 protected abstract Object reduceMatch();
902 * aexp ::= (DO | MDO) statements
904 protected abstract Object reduceDo();
906 * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
908 protected abstract Object reduceSelect();
910 * aexp ::= ENFORCE queryBlock
912 protected abstract Object reduceEnforce();
916 protected abstract Object reduceVar();
918 * aexp ::= ATTACHED_HASH ID
920 protected abstract Object reduceHashedId();
924 protected abstract Object reduceBlank();
928 protected abstract Object reduceInteger();
932 protected abstract Object reduceFloat();
934 * aexp ::= stringLiteral
936 protected abstract Object reduceString();
940 protected abstract Object reduceChar();
942 * aexp ::= LPAREN (exp (COMMA (exp COMMA)* exp)?)? RPAREN
944 protected abstract Object reduceTuple();
946 * aexp ::= LPAREN exp ARROW exp RPAREN
948 protected abstract Object reduceViewPattern();
950 * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
952 protected abstract Object reduceRightSection();
954 * aexp ::= LPAREN lexp symbol RPAREN
956 protected abstract Object reduceLeftSection();
958 * aexp ::= LBRACKET (exp (COMMA (exp COMMA)* exp)?)? RBRACKET
960 protected abstract Object reduceListLiteral();
962 * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
964 protected abstract Object reduceRange();
966 * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)* RBRACKET
968 protected abstract Object reduceListComprehension();
970 * aexp ::= ID AT aexp
972 protected abstract Object reduceAs();
974 * aexp ::= ID LBRACE (field (COMMA field)*)? RBRACE
976 protected abstract Object reduceRecord();
978 * aexp ::= TRANSFORMATION ID WHERE queryBlock
980 protected abstract Object reduceTransformation();
982 * aexp ::= EQ LBRACE equationBlock RBRACE
984 protected abstract Object reduceEq();
986 * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)* ruleDeclaration)?)? RBRACE
988 protected abstract Object reduceRuleDeclarations();
990 * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)* importItem)?)? RPAREN
992 protected abstract Object reduceImportShowing();
994 * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN
996 protected abstract Object reduceImportHiding();
1000 protected abstract Object reduceImportValueItem();
1002 * fieldDeclaration ::= ID HASTYPE type
1004 protected abstract Object reduceFieldDescription();
1006 * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)* statement)?)? RBRACE
1008 protected abstract Object reduceStatements();
1010 * guardedExpEq ::= BAR exp (COMMA exp)* EQUALS exp
1012 protected abstract Object reduceGuardedExpEq();
1014 * fundep ::= ID ID* ARROW ID
1016 protected abstract Object reduceFundep();
1018 * ruleDeclaration ::= query
1020 protected abstract Object reduceQueryRuleDeclaration();
1024 protected abstract Object reduceGuardQuery();
1026 * query ::= exp EQUALS exp
1028 protected abstract Object reduceEqualsQuery();
1030 * query ::= exp BINDS exp
1032 protected abstract Object reduceBindQuery();
1034 * query ::= QUERY_OP queryBlock
1036 protected abstract Object reduceCompositeQuery();
1038 * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)* query)?)? RBRACE
1040 protected abstract Object reduceQueryBlock();
1042 * lexp ::= faexp faexp*
1044 protected abstract Object reduceApply();
1048 protected abstract Object reduceSymbol();
1050 * symbol ::= ESCAPED_ID
1052 protected abstract Object reduceEscapedId();
1056 protected abstract Object reduceMinus();
1060 protected abstract Object reduceLess();
1062 * symbol ::= GREATER
1064 protected abstract Object reduceGreater();
1066 * symbol ::= SEPARATED_DOT
1068 protected abstract Object reduceDot();
1070 * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)*
1072 protected abstract Object reduceFieldAccess();
1076 protected abstract Object reduceIdAccessor();
1078 * accessor ::= BEGIN_STRING END_STRING
1080 protected abstract Object reduceStringAccessor();
1082 * accessor ::= LPAREN exp RPAREN
1084 protected abstract Object reduceExpAccessor();
1086 * case ::= exp caseRhs
1088 protected abstract Object reduceCase();
1090 * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING
1092 protected abstract Object reduceStringLiteral();
1094 * listQualifier ::= exp
1096 protected abstract Object reduceGuardQualifier();
1098 * listQualifier ::= exp EQUALS exp
1100 protected abstract Object reduceLetQualifier();
1102 * listQualifier ::= exp BINDS exp
1104 protected abstract Object reduceBindQualifier();
1106 * listQualifier ::= THEN exp (BY exp)?
1108 protected abstract Object reduceThenQualifier();
1110 * field ::= ID EQUALS exp
1112 protected abstract Object reduceField();
1116 protected abstract Object reduceFieldShorthand();
1118 * chrQuery ::= (listQualifier COMMA)* listQualifier
1120 protected abstract Object reduceCHRQuery();
1122 * verboseChrQuery ::= LBRACE listQualifier (SEMICOLON listQualifier)* RBRACE
1124 protected abstract Object reduceVerboseCHRQuery();
1126 * caseRhs ::= ARROW exp (WHERE statements)?
1128 protected abstract Object reduceSimpleCaseRhs();
1130 * caseRhs ::= guardedExpArrow guardedExpArrow* (WHERE statements)?
1132 protected abstract Object reduceGuardedCaseRhs();
1134 * guardedExpArrow ::= BAR exp (COMMA exp)* ARROW exp
1136 protected abstract Object reduceGuardedExpArrow();
1140 protected abstract Object reduceGuardEquation();
1142 * equation ::= exp EQUALS exp
1144 protected abstract Object reduceBasicEquation();
1146 * etype ::= LESS ID (COMMA ID)* GREATER btype
1148 protected abstract Object reduceEffect();
1152 protected abstract Object reduceJustEtype();
1154 * etype ::= FORALL ID ID* (SEPARATED_DOT | ATTACHED_DOT) type
1156 protected abstract Object reduceForAll();
1158 * btype ::= atype atype*
1160 protected abstract Object reduceApplyType();
1162 * dummy ::= COMMENT EOL
1164 protected abstract Object reduceDummy();
1166 protected void postReduce(Object reduced) {