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 = 362;
17 private static final int TERMINAL_COUNT = 86;
18 private static final int NONTERMINAL_COUNT = 52;
19 private static final int PRODUCT_COUNT = 138;
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[6832];
24 private static final int[] ERROR_TABLE = new int[973];
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[1953];
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[] {
126 public static final String[] NONTERMINAL_NAMES = new String[] {
163 "symbolWithoutMinus",
183 DataInputStream input = new DataInputStream(SCLParser.class.getResourceAsStream("SCLParser.dat"));
184 for(int i=0;i<ACTION_ROW_ID.length;++i)
185 ACTION_ROW_ID[i] = input.readInt();
186 for(int i=0;i<ACTION_COLUMN_ID.length;++i)
187 ACTION_COLUMN_ID[i] = input.readInt();
188 for(int i=0;i<ACTION_TABLE.length;++i)
189 ACTION_TABLE[i] = input.readShort();
190 for(int i=0;i<ERROR_TABLE.length;++i)
191 ERROR_TABLE[i] = input.readInt();
192 for(int i=0;i<GOTO_ROW_ID.length;++i)
193 GOTO_ROW_ID[i] = input.readInt();
194 for(int i=0;i<GOTO_COLUMN_ID.length;++i)
195 GOTO_COLUMN_ID[i] = input.readInt();
196 for(int i=0;i<GOTO_TABLE.length;++i)
197 GOTO_TABLE[i] = input.readShort();
198 for(int i=0;i<PRODUCT_LHS.length;++i)
199 PRODUCT_LHS[i] = input.readInt();
201 } catch(IOException e) {
206 private static short getAction(int state, int symbol) {
207 int id = TERMINAL_COUNT*state + symbol;
208 if( ((ERROR_TABLE[id>>5] >> (id&31))&1) != 0 )
210 return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]];
213 private static short getGoto(int state, int symbol) {
214 return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]];
217 protected abstract Token nextToken();
219 private Object[] symbolStack = new Object[INITIAL_CAPACITY];
220 private int symbolStackLength = 0;
222 private int[] stateStack = new int[INITIAL_CAPACITY];
223 private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY];
224 private int stateStackLength = 0;
227 private int reductionLength;
229 protected int length() {
230 return reductionLength;
233 protected Object get(int i) {
234 if(i < 0 || i >= reductionLength)
235 throw new IndexOutOfBoundsException();
236 return symbolStack[symbolStackLength+i];
239 private String parseErrorDescription(int state, Token token, int tokenId) {
240 StringBuilder b = new StringBuilder();
241 b.append("Unexpected token '").append(token)
242 .append("' (").append(TERMINAL_NAMES[tokenId])
243 .append("). Expected one of ");
244 ArrayList<String> possibleTerminals = new ArrayList<String>();
245 for(int i=0;i<TERMINAL_COUNT;++i)
246 if(getAction(state, i) != ERROR_ACTION)
247 possibleTerminals.add(TERMINAL_NAMES[i]);
248 Collections.sort(possibleTerminals);
249 for(int i=0;i<possibleTerminals.size();++i) {
252 b.append(possibleTerminals.get(i));
258 protected abstract RuntimeException syntaxError(Token token, String description);
260 private static String describeAction(boolean isGoto, int action) {
261 if(action == ERROR_ACTION)
263 if(action == ACCEPT_ACTION)
265 StringBuilder b = new StringBuilder();
269 if((action & REDUCE_MASK) != 0) {
270 action ^= REDUCE_MASK;
276 if((action & POP_MASK) != 0) {
280 if((action & PUSH_MASK) != 0) {
284 b.append(' ').append(action);
288 private void printState(int state) {
289 System.out.print("state=" + state + ":");
290 for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) {
291 Object s = symbolStack[i];
292 if(s instanceof Token)
293 System.out.print(" " + TERMINAL_NAMES[((Token)s).id]);
295 System.out.print(" null");
297 System.out.print(" " + s.getClass().getSimpleName());
298 while(j>=0 && symbolStackPositionStack[j]==i)
299 System.out.print(" (" + stateStack[j--] + ")");
301 System.out.println();
304 private Object parse(int state) {
306 Token token = nextToken();
307 int tokenId = token.id;
309 System.out.println("---> token " + TERMINAL_NAMES[tokenId] + " \"" + token.text + "\" <---");
313 short action = getAction(state, tokenId);
315 System.out.println(" -> action=" + describeAction(false, action));
316 //System.out.println(STATE_DESCRIPTIONS[state]);
317 if((action & REDUCE_MASK) != 0) {
318 if(action == ACCEPT_ACTION)
319 return symbolStack[symbolStackLength-1];
320 if(action == ERROR_ACTION)
321 throw syntaxError(token, parseErrorDescription(state, token, tokenId));
322 int popAmount = (action >>> 13)&3;
325 System.out.println(" POP " + popAmount);
327 stateStackLength -= popAmount;
328 action &= STATE_MASK;
330 int reductionBegin = symbolStackPositionStack[--stateStackLength];
332 reductionLength = symbolStackLength-reductionBegin;
333 symbolStackLength = reductionBegin;
335 if(symbolStackLength == symbolStack.length)
336 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
337 Object symbol = reduce(action);
339 symbolStack[symbolStackLength] = symbol;
341 state = stateStack[stateStackLength];
346 System.out.println(" nonterminal=" + NONTERMINAL_NAMES[PRODUCT_LHS[action]]);
348 action = getGoto(state, PRODUCT_LHS[action]);
350 System.out.println(" -> action=" + describeAction(true, action));
353 if((action & POP_MASK) != 0) {
357 if((action & PUSH_MASK) != 0) {
358 if(stateStackLength == stateStack.length) {
359 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
360 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
362 symbolStackPositionStack[stateStackLength] = symbolStackLength;
363 stateStack[stateStackLength++] = state;
365 state = action & STATE_MASK;
370 if((action & POP_MASK) != 0) {
374 if((action & PUSH_MASK) != 0) {
375 if(stateStackLength == stateStack.length) {
376 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
377 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
379 symbolStackPositionStack[stateStackLength] = symbolStackLength;
380 stateStack[stateStackLength++] = state;
384 state = action & STATE_MASK;
387 if(symbolStackLength == symbolStack.length)
388 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
389 symbolStack[symbolStackLength++] = token;
396 public Object parseModule() {
399 public Object parseCommands() {
402 public Object parseImport() {
405 public Object parseType() {
408 public Object parseExp() {
411 public Object parseEquationBlock() {
416 protected Object reduce(int productionId) {
418 switch(productionId) {
420 return reduceModule();
422 return reduceOneCommand();
424 return reduceManyCommands();
426 return reduceImport();
428 return reduceArrow();
430 return reduceLocalTypeAnnotation();
432 return reduceEquationBlock();
434 return reduceModuleHeader();
436 return reduceTypeAnnotation();
438 return reduceValueDefinition();
440 return reduceDataDefinition();
442 return reduceTypeDefinition();
444 return reduceClassDefinition();
446 return reduceInstanceDefinition();
448 return reduceDerivingInstanceDefinition();
450 return reduceDocumentationString();
452 return reduceAnnotation();
454 return reducePrecedenceDefinition();
456 return reduceJustImport();
458 return reduceImportJava();
460 return reduceEffectDefinition();
462 return reduceRuleDefinition();
464 return reduceMappingRelationDefinition();
466 return reduceRelationDefinition();
468 return reduceRulesetDefinition();
470 return reduceStatementCommand();
472 return reduceImportCommand();
474 return reduceGuardStatement();
476 return reduceLetStatement();
478 return reduceBindStatement();
480 return reduceRuleStatement();
482 return reduceCHRStatement();
484 return reduceVerboseCHRStatement();
486 return reduceConstraintStatement();
488 return reduceLocalInclude();
490 return reduceDeclarations();
492 return reduceField();
494 return reduceFieldShorthand();
496 return reduceVarId();
498 return reduceEscapedSymbol();
500 return reduceTupleConstructor();
502 return reduceBinary();
504 return reduceSimpleRhs();
506 return reduceGuardedRhs();
508 return reduceConstructor();
510 return reduceRecordConstructor();
512 return reduceContext();
514 return reduceFundeps();
516 return reduceTypeVar();
518 return reduceTupleType();
520 return reduceListType();
522 return reduceListTypeConstructor();
524 return reduceTupleTypeConstructor();
526 return reduceLambda();
528 return reduceLambdaMatch();
534 return reduceMatch();
538 return reduceSelect();
540 return reduceCHRSelect();
542 return reduceEnforce();
546 return reduceHashedId();
548 return reduceBlank();
550 return reduceInteger();
552 return reduceFloat();
554 return reduceString();
558 return reduceTuple();
560 return reduceViewPattern();
562 return reduceRightSection();
564 return reduceLeftSection();
566 return reduceListLiteral();
568 return reduceRange();
570 return reduceListComprehension();
574 return reduceRecord();
576 return reduceTransformation();
580 return reduceRuleDeclarations();
582 return reduceStatements();
584 return reduceImportShowing();
586 return reduceImportHiding();
588 return reduceImportValueItem();
590 return reduceFieldDescription();
592 return reduceGuardedExpEq();
594 return reduceFundep();
596 return reduceQueryRuleDeclaration();
598 return reduceAnnotation();
600 return reduceGuardQuery();
602 return reduceEqualsQuery();
604 return reduceBindQuery();
606 return reduceCompositeQuery();
608 return reduceApply();
610 return reduceSymbol();
612 return reduceEscapedId();
614 return reduceMinus();
618 return reduceGreater();
622 return reduceFieldAccess();
624 return reduceIdAccessor();
626 return reduceStringAccessor();
628 return reduceExpAccessor();
632 return reduceQueryBlock();
634 return reduceVerboseCHRConjunction();
636 return reduceStringLiteral();
638 return reduceSymbol();
640 return reduceEscapedId();
644 return reduceGreater();
648 return reduceGuardQualifier();
650 return reduceLetQualifier();
652 return reduceBindQualifier();
654 return reduceThenQualifier();
656 return reduceCHRConjunction();
658 return reduceCHRAtom();
660 return reduceCHREquals();
662 return reduceCHRBinds();
664 return reduceSimpleCaseRhs();
666 return reduceGuardedCaseRhs();
668 return reduceGuardedExpArrow();
670 return reduceGuardEquation();
672 return reduceBasicEquation();
674 return reduceEffect();
676 return reduceJustEtype();
678 return reduceForAll();
680 return reduceApplyType();
682 return reduceDummy();
685 throw new RuntimeException("Internal parser error.");
687 } catch(SCLSyntaxErrorException e) {
688 StringBuilder b = new StringBuilder();
689 b.append("Failed to reduce");
690 for(int i=0;i<length();++i) {
692 b.append("\n (").append(i).append(") \"").append(obj).append('\"');
693 if(obj instanceof Token)
694 b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
696 b.append(" [").append(obj.getClass().getSimpleName()).append("]");
698 throw new RuntimeException(b.toString(), e);
703 * module ::= (declaration (SEMICOLON declaration)*)?
705 protected abstract Object reduceModule();
707 * commands ::= command?
709 protected abstract Object reduceOneCommand();
711 * commands ::= commands SEMICOLON command
713 protected abstract Object reduceManyCommands();
715 * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
717 protected abstract Object reduceImport();
719 * type ::= (etype (ARROW | IMPLIES))* etype
721 protected abstract Object reduceArrow();
723 * exp ::= bexp (HASTYPE type)?
725 protected abstract Object reduceLocalTypeAnnotation();
727 * equationBlock ::= (equation (SEMICOLON equation)*)?
729 protected abstract Object reduceEquationBlock();
731 * declaration ::= MODULE LBRACE (field (COMMA field)*)? RBRACE
733 protected abstract Object reduceModuleHeader();
735 * declaration ::= (var COMMA)* var HASTYPE type
737 protected abstract Object reduceTypeAnnotation();
739 * declaration ::= bexp rhs
741 protected abstract Object reduceValueDefinition();
743 * declaration ::= DATA ID ID* (EQUALS (constructor BAR)* constructor)?
745 protected abstract Object reduceDataDefinition();
747 * declaration ::= TYPE ID ID* EQUALS type
749 protected abstract Object reduceTypeDefinition();
751 * declaration ::= CLASS context? ID ID* (BAR fundeps | (BAR fundeps)? WHERE declarations)?
753 protected abstract Object reduceClassDefinition();
755 * declaration ::= INSTANCE context? ID atype atype* (WHERE declarations)?
757 protected abstract Object reduceInstanceDefinition();
759 * declaration ::= DERIVING INSTANCE context? ID atype atype*
761 protected abstract Object reduceDerivingInstanceDefinition();
763 * declaration ::= BEGIN_STRING END_STRING
765 protected abstract Object reduceDocumentationString();
767 * declaration ::= ANNOTATION_ID aexp*
769 protected abstract Object reduceAnnotation();
771 * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)* var
773 protected abstract Object reducePrecedenceDefinition();
775 * declaration ::= import
777 protected abstract Object reduceJustImport();
779 * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
781 protected abstract Object reduceImportJava();
783 * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
785 protected abstract Object reduceEffectDefinition();
787 * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)* ID)? WHERE ruleDeclarations
789 protected abstract Object reduceRuleDefinition();
791 * declaration ::= MAPPING_RELATION ID atype*
793 protected abstract Object reduceMappingRelationDefinition();
795 * declaration ::= bexp FOLLOWS ruleDeclarations
797 protected abstract Object reduceRelationDefinition();
799 * declaration ::= RULESET ID WHERE statements
801 protected abstract Object reduceRulesetDefinition();
803 * command ::= statement
805 protected abstract Object reduceStatementCommand();
809 protected abstract Object reduceImportCommand();
813 protected abstract Object reduceGuardStatement();
815 * statement ::= exp rhs
817 protected abstract Object reduceLetStatement();
819 * statement ::= exp BINDS exp
821 protected abstract Object reduceBindStatement();
823 * statement ::= exp FOLLOWS queryBlock
825 protected abstract Object reduceRuleStatement();
827 * statement ::= chrQuery IMPLIES chrQuery
829 protected abstract Object reduceCHRStatement();
831 * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
833 protected abstract Object reduceVerboseCHRStatement();
835 * statement ::= CONSTRAINT constructor
837 protected abstract Object reduceConstraintStatement();
839 * statement ::= INCLUDE ID aexp
841 protected abstract Object reduceLocalInclude();
843 * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)* declaration)?)? RBRACE
845 protected abstract Object reduceDeclarations();
847 * field ::= ID EQUALS exp
849 protected abstract Object reduceField();
853 protected abstract Object reduceFieldShorthand();
857 protected abstract Object reduceVarId();
859 * var ::= ESCAPED_SYMBOL
861 protected abstract Object reduceEscapedSymbol();
863 * var ::= LPAREN COMMA COMMA* RPAREN
865 protected abstract Object reduceTupleConstructor();
867 * bexp ::= MINUS? lexp (symbol lexp)*
869 protected abstract Object reduceBinary();
871 * rhs ::= EQUALS exp (WHERE statements)?
873 protected abstract Object reduceSimpleRhs();
875 * rhs ::= guardedExpEq guardedExpEq* (WHERE statements)?
877 protected abstract Object reduceGuardedRhs();
879 * constructor ::= (ANNOTATION_ID aexp)* ID atype*
881 protected abstract Object reduceConstructor();
883 * constructor ::= (ANNOTATION_ID aexp)* ID LBRACE fieldDeclaration (COMMA fieldDeclaration)* RBRACE
885 protected abstract Object reduceRecordConstructor();
887 * context ::= LPAREN type (COMMA type)* RPAREN IMPLIES
889 protected abstract Object reduceContext();
891 * fundeps ::= (fundep COMMA)* fundep
893 protected abstract Object reduceFundeps();
897 protected abstract Object reduceTypeVar();
899 * atype ::= LPAREN (type (COMMA (type COMMA)* type)?)? RPAREN
901 protected abstract Object reduceTupleType();
903 * atype ::= LBRACKET type RBRACKET
905 protected abstract Object reduceListType();
907 * atype ::= LBRACKET RBRACKET
909 protected abstract Object reduceListTypeConstructor();
911 * atype ::= LPAREN COMMA COMMA* RPAREN
913 protected abstract Object reduceTupleTypeConstructor();
915 * aexp ::= LAMBDA aexp aexp* ARROW exp
917 protected abstract Object reduceLambda();
919 * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE
921 protected abstract Object reduceLambdaMatch();
923 * aexp ::= LET statements IN exp
925 protected abstract Object reduceLet();
927 * aexp ::= IF exp THEN exp (ELSE exp)?
929 protected abstract Object reduceIf();
931 * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)* RBRACE
933 protected abstract Object reduceMatch();
935 * aexp ::= (DO | MDO | EDO) statements
937 protected abstract Object reduceDo();
939 * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
941 protected abstract Object reduceSelect();
943 * aexp ::= CHR_SELECT exp WHERE verboseChrQuery
945 protected abstract Object reduceCHRSelect();
947 * aexp ::= ENFORCE queryBlock
949 protected abstract Object reduceEnforce();
953 protected abstract Object reduceVar();
955 * aexp ::= ATTACHED_HASH ID
957 protected abstract Object reduceHashedId();
961 protected abstract Object reduceBlank();
965 protected abstract Object reduceInteger();
969 protected abstract Object reduceFloat();
971 * aexp ::= stringLiteral
973 protected abstract Object reduceString();
977 protected abstract Object reduceChar();
979 * aexp ::= LPAREN (exp (COMMA (exp COMMA)* exp)?)? RPAREN
981 protected abstract Object reduceTuple();
983 * aexp ::= LPAREN exp ARROW exp RPAREN
985 protected abstract Object reduceViewPattern();
987 * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
989 protected abstract Object reduceRightSection();
991 * aexp ::= LPAREN lexp symbol RPAREN
993 protected abstract Object reduceLeftSection();
995 * aexp ::= LBRACKET (exp (COMMA (exp COMMA)* exp)?)? RBRACKET
997 protected abstract Object reduceListLiteral();
999 * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
1001 protected abstract Object reduceRange();
1003 * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)* RBRACKET
1005 protected abstract Object reduceListComprehension();
1007 * aexp ::= ID AT aexp
1009 protected abstract Object reduceAs();
1011 * aexp ::= ID LBRACE (field (COMMA field)*)? RBRACE
1013 protected abstract Object reduceRecord();
1015 * aexp ::= TRANSFORMATION ID WHERE queryBlock
1017 protected abstract Object reduceTransformation();
1019 * aexp ::= EQ LBRACE equationBlock RBRACE
1021 protected abstract Object reduceEq();
1023 * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)* ruleDeclaration)?)? RBRACE
1025 protected abstract Object reduceRuleDeclarations();
1027 * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)* statement)?)? RBRACE
1029 protected abstract Object reduceStatements();
1031 * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)* importItem)?)? RPAREN
1033 protected abstract Object reduceImportShowing();
1035 * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN
1037 protected abstract Object reduceImportHiding();
1041 protected abstract Object reduceImportValueItem();
1043 * fieldDeclaration ::= ID HASTYPE type
1045 protected abstract Object reduceFieldDescription();
1047 * guardedExpEq ::= BAR exp (COMMA exp)* EQUALS exp
1049 protected abstract Object reduceGuardedExpEq();
1051 * fundep ::= ID ID* ARROW ID
1053 protected abstract Object reduceFundep();
1055 * ruleDeclaration ::= query
1057 protected abstract Object reduceQueryRuleDeclaration();
1061 protected abstract Object reduceGuardQuery();
1063 * query ::= exp EQUALS exp
1065 protected abstract Object reduceEqualsQuery();
1067 * query ::= exp BINDS exp
1069 protected abstract Object reduceBindQuery();
1071 * query ::= QUERY_OP queryBlock
1073 protected abstract Object reduceCompositeQuery();
1075 * lexp ::= faexp faexp*
1077 protected abstract Object reduceApply();
1081 protected abstract Object reduceSymbol();
1083 * symbol ::= ESCAPED_ID
1085 protected abstract Object reduceEscapedId();
1089 protected abstract Object reduceMinus();
1093 protected abstract Object reduceLess();
1095 * symbol ::= GREATER
1097 protected abstract Object reduceGreater();
1099 * symbol ::= SEPARATED_DOT
1101 protected abstract Object reduceDot();
1103 * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)*
1105 protected abstract Object reduceFieldAccess();
1109 protected abstract Object reduceIdAccessor();
1111 * accessor ::= BEGIN_STRING END_STRING
1113 protected abstract Object reduceStringAccessor();
1115 * accessor ::= LPAREN exp RPAREN
1117 protected abstract Object reduceExpAccessor();
1119 * case ::= exp caseRhs
1121 protected abstract Object reduceCase();
1123 * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)* query)?)? RBRACE
1125 protected abstract Object reduceQueryBlock();
1127 * verboseChrQuery ::= LBRACE chrQuery (SEMICOLON chrQuery)* RBRACE
1129 protected abstract Object reduceVerboseCHRConjunction();
1131 * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING
1133 protected abstract Object reduceStringLiteral();
1135 * listQualifier ::= exp
1137 protected abstract Object reduceGuardQualifier();
1139 * listQualifier ::= exp EQUALS exp
1141 protected abstract Object reduceLetQualifier();
1143 * listQualifier ::= exp BINDS exp
1145 protected abstract Object reduceBindQualifier();
1147 * listQualifier ::= THEN exp (BY exp)?
1149 protected abstract Object reduceThenQualifier();
1151 * chrQuery ::= (chrQueryPart COMMA)* chrQueryPart
1153 protected abstract Object reduceCHRConjunction();
1155 * chrQueryPart ::= exp
1157 protected abstract Object reduceCHRAtom();
1159 * chrQueryPart ::= exp EQUALS exp
1161 protected abstract Object reduceCHREquals();
1163 * chrQueryPart ::= exp BINDS exp
1165 protected abstract Object reduceCHRBinds();
1167 * caseRhs ::= ARROW exp (WHERE statements)?
1169 protected abstract Object reduceSimpleCaseRhs();
1171 * caseRhs ::= guardedExpArrow guardedExpArrow* (WHERE statements)?
1173 protected abstract Object reduceGuardedCaseRhs();
1175 * guardedExpArrow ::= BAR exp (COMMA exp)* ARROW exp
1177 protected abstract Object reduceGuardedExpArrow();
1181 protected abstract Object reduceGuardEquation();
1183 * equation ::= exp EQUALS exp
1185 protected abstract Object reduceBasicEquation();
1187 * etype ::= LESS ID (COMMA ID)* GREATER btype
1189 protected abstract Object reduceEffect();
1193 protected abstract Object reduceJustEtype();
1195 * etype ::= FORALL ID ID* (SEPARATED_DOT | ATTACHED_DOT) type
1197 protected abstract Object reduceForAll();
1199 * btype ::= atype atype*
1201 protected abstract Object reduceApplyType();
1203 * dummy ::= COMMENT EOL
1205 protected abstract Object reduceDummy();
1207 protected void postReduce(Object reduced) {