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 = 85;
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[962];
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[] {
125 public static final String[] NONTERMINAL_NAMES = new String[] {
162 "symbolWithoutMinus",
182 DataInputStream input = new DataInputStream(SCLParser.class.getResourceAsStream("SCLParser.dat"));
183 for(int i=0;i<ACTION_ROW_ID.length;++i)
184 ACTION_ROW_ID[i] = input.readInt();
185 for(int i=0;i<ACTION_COLUMN_ID.length;++i)
186 ACTION_COLUMN_ID[i] = input.readInt();
187 for(int i=0;i<ACTION_TABLE.length;++i)
188 ACTION_TABLE[i] = input.readShort();
189 for(int i=0;i<ERROR_TABLE.length;++i)
190 ERROR_TABLE[i] = input.readInt();
191 for(int i=0;i<GOTO_ROW_ID.length;++i)
192 GOTO_ROW_ID[i] = input.readInt();
193 for(int i=0;i<GOTO_COLUMN_ID.length;++i)
194 GOTO_COLUMN_ID[i] = input.readInt();
195 for(int i=0;i<GOTO_TABLE.length;++i)
196 GOTO_TABLE[i] = input.readShort();
197 for(int i=0;i<PRODUCT_LHS.length;++i)
198 PRODUCT_LHS[i] = input.readInt();
200 } catch(IOException e) {
205 private static short getAction(int state, int symbol) {
206 int id = TERMINAL_COUNT*state + symbol;
207 if( ((ERROR_TABLE[id>>5] >> (id&31))&1) != 0 )
209 return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]];
212 private static short getGoto(int state, int symbol) {
213 return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]];
216 protected abstract Token nextToken();
218 private Object[] symbolStack = new Object[INITIAL_CAPACITY];
219 private int symbolStackLength = 0;
221 private int[] stateStack = new int[INITIAL_CAPACITY];
222 private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY];
223 private int stateStackLength = 0;
226 private int reductionLength;
228 protected int length() {
229 return reductionLength;
232 protected Object get(int i) {
233 if(i < 0 || i >= reductionLength)
234 throw new IndexOutOfBoundsException();
235 return symbolStack[symbolStackLength+i];
238 private String parseErrorDescription(int state, Token token, int tokenId) {
239 StringBuilder b = new StringBuilder();
240 b.append("Unexpected token '").append(token)
241 .append("' (").append(TERMINAL_NAMES[tokenId])
242 .append("). Expected one of ");
243 ArrayList<String> possibleTerminals = new ArrayList<String>();
244 for(int i=0;i<TERMINAL_COUNT;++i)
245 if(getAction(state, i) != ERROR_ACTION)
246 possibleTerminals.add(TERMINAL_NAMES[i]);
247 Collections.sort(possibleTerminals);
248 for(int i=0;i<possibleTerminals.size();++i) {
251 b.append(possibleTerminals.get(i));
257 protected abstract RuntimeException syntaxError(Token token, String description);
259 private static String describeAction(boolean isGoto, int action) {
260 if(action == ERROR_ACTION)
262 if(action == ACCEPT_ACTION)
264 StringBuilder b = new StringBuilder();
268 if((action & REDUCE_MASK) != 0) {
269 action ^= REDUCE_MASK;
275 if((action & POP_MASK) != 0) {
279 if((action & PUSH_MASK) != 0) {
283 b.append(' ').append(action);
287 private void printState(int state) {
288 System.out.print("state=" + state + ":");
289 for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) {
290 Object s = symbolStack[i];
291 if(s instanceof Token)
292 System.out.print(" " + TERMINAL_NAMES[((Token)s).id]);
294 System.out.print(" null");
296 System.out.print(" " + s.getClass().getSimpleName());
297 while(j>=0 && symbolStackPositionStack[j]==i)
298 System.out.print(" (" + stateStack[j--] + ")");
300 System.out.println();
303 private Object parse(int state) {
305 Token token = nextToken();
306 int tokenId = token.id;
308 System.out.println("---> token " + TERMINAL_NAMES[tokenId] + " \"" + token.text + "\" <---");
312 short action = getAction(state, tokenId);
314 System.out.println(" -> action=" + describeAction(false, action));
315 //System.out.println(STATE_DESCRIPTIONS[state]);
316 if((action & REDUCE_MASK) != 0) {
317 if(action == ACCEPT_ACTION)
318 return symbolStack[symbolStackLength-1];
319 if(action == ERROR_ACTION)
320 throw syntaxError(token, parseErrorDescription(state, token, tokenId));
321 int popAmount = (action >>> 13)&3;
324 System.out.println(" POP " + popAmount);
326 stateStackLength -= popAmount;
327 action &= STATE_MASK;
329 int reductionBegin = symbolStackPositionStack[--stateStackLength];
331 reductionLength = symbolStackLength-reductionBegin;
332 symbolStackLength = reductionBegin;
334 if(symbolStackLength == symbolStack.length)
335 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
336 Object symbol = reduce(action);
338 symbolStack[symbolStackLength] = symbol;
340 state = stateStack[stateStackLength];
345 System.out.println(" nonterminal=" + NONTERMINAL_NAMES[PRODUCT_LHS[action]]);
347 action = getGoto(state, PRODUCT_LHS[action]);
349 System.out.println(" -> action=" + describeAction(true, action));
352 if((action & POP_MASK) != 0) {
356 if((action & PUSH_MASK) != 0) {
357 if(stateStackLength == stateStack.length) {
358 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
359 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
361 symbolStackPositionStack[stateStackLength] = symbolStackLength;
362 stateStack[stateStackLength++] = state;
364 state = action & STATE_MASK;
369 if((action & POP_MASK) != 0) {
373 if((action & PUSH_MASK) != 0) {
374 if(stateStackLength == stateStack.length) {
375 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
376 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
378 symbolStackPositionStack[stateStackLength] = symbolStackLength;
379 stateStack[stateStackLength++] = state;
383 state = action & STATE_MASK;
386 if(symbolStackLength == symbolStack.length)
387 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
388 symbolStack[symbolStackLength++] = token;
395 public Object parseModule() {
398 public Object parseCommands() {
401 public Object parseImport() {
404 public Object parseType() {
407 public Object parseExp() {
410 public Object parseEquationBlock() {
415 protected Object reduce(int productionId) {
417 switch(productionId) {
419 return reduceModule();
421 return reduceOneCommand();
423 return reduceManyCommands();
425 return reduceImport();
427 return reduceArrow();
429 return reduceLocalTypeAnnotation();
431 return reduceEquationBlock();
433 return reduceModuleHeader();
435 return reduceTypeAnnotation();
437 return reduceValueDefinition();
439 return reduceDataDefinition();
441 return reduceTypeDefinition();
443 return reduceClassDefinition();
445 return reduceInstanceDefinition();
447 return reduceDerivingInstanceDefinition();
449 return reduceDocumentationString();
451 return reduceAnnotation();
453 return reducePrecedenceDefinition();
455 return reduceJustImport();
457 return reduceImportJava();
459 return reduceEffectDefinition();
461 return reduceRuleDefinition();
463 return reduceMappingRelationDefinition();
465 return reduceRelationDefinition();
467 return reduceRulesetDefinition();
469 return reduceStatementCommand();
471 return reduceImportCommand();
473 return reduceGuardStatement();
475 return reduceLetStatement();
477 return reduceBindStatement();
479 return reduceRuleStatement();
481 return reduceCHRStatement();
483 return reduceVerboseCHRStatement();
485 return reduceConstraintStatement();
487 return reduceLocalInclude();
489 return reduceDeclarations();
491 return reduceField();
493 return reduceFieldShorthand();
495 return reduceVarId();
497 return reduceEscapedSymbol();
499 return reduceTupleConstructor();
501 return reduceBinary();
503 return reduceSimpleRhs();
505 return reduceGuardedRhs();
507 return reduceConstructor();
509 return reduceRecordConstructor();
511 return reduceContext();
513 return reduceFundeps();
515 return reduceTypeVar();
517 return reduceTupleType();
519 return reduceListType();
521 return reduceListTypeConstructor();
523 return reduceTupleTypeConstructor();
525 return reduceLambda();
527 return reduceLambdaMatch();
533 return reduceMatch();
537 return reduceSelect();
539 return reduceCHRSelect();
541 return reduceEnforce();
545 return reduceHashedId();
547 return reduceBlank();
549 return reduceInteger();
551 return reduceFloat();
553 return reduceString();
557 return reduceTuple();
559 return reduceViewPattern();
561 return reduceRightSection();
563 return reduceLeftSection();
565 return reduceListLiteral();
567 return reduceRange();
569 return reduceListComprehension();
573 return reduceRecord();
575 return reduceTransformation();
579 return reduceRuleDeclarations();
581 return reduceStatements();
583 return reduceImportShowing();
585 return reduceImportHiding();
587 return reduceImportValueItem();
589 return reduceFieldDescription();
591 return reduceGuardedExpEq();
593 return reduceFundep();
595 return reduceQueryRuleDeclaration();
597 return reduceAnnotation();
599 return reduceGuardQuery();
601 return reduceEqualsQuery();
603 return reduceBindQuery();
605 return reduceCompositeQuery();
607 return reduceApply();
609 return reduceSymbol();
611 return reduceEscapedId();
613 return reduceMinus();
617 return reduceGreater();
621 return reduceFieldAccess();
623 return reduceIdAccessor();
625 return reduceStringAccessor();
627 return reduceExpAccessor();
631 return reduceQueryBlock();
633 return reduceVerboseCHRConjunction();
635 return reduceStringLiteral();
637 return reduceSymbol();
639 return reduceEscapedId();
643 return reduceGreater();
647 return reduceGuardQualifier();
649 return reduceLetQualifier();
651 return reduceBindQualifier();
653 return reduceThenQualifier();
655 return reduceCHRConjunction();
657 return reduceCHRAtom();
659 return reduceCHREquals();
661 return reduceCHRBinds();
663 return reduceSimpleCaseRhs();
665 return reduceGuardedCaseRhs();
667 return reduceGuardedExpArrow();
669 return reduceGuardEquation();
671 return reduceBasicEquation();
673 return reduceEffect();
675 return reduceJustEtype();
677 return reduceForAll();
679 return reduceApplyType();
681 return reduceDummy();
684 throw new RuntimeException("Internal parser error.");
686 } catch(SCLSyntaxErrorException e) {
687 StringBuilder b = new StringBuilder();
688 b.append("Failed to reduce");
689 for(int i=0;i<length();++i) {
691 b.append("\n (").append(i).append(") \"").append(obj).append('\"');
692 if(obj instanceof Token)
693 b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
695 b.append(" [").append(obj.getClass().getSimpleName()).append("]");
697 throw new RuntimeException(b.toString(), e);
702 * module ::= (declaration (SEMICOLON declaration)*)?
704 protected abstract Object reduceModule();
706 * commands ::= command?
708 protected abstract Object reduceOneCommand();
710 * commands ::= commands SEMICOLON command
712 protected abstract Object reduceManyCommands();
714 * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
716 protected abstract Object reduceImport();
718 * type ::= (etype (ARROW | IMPLIES))* etype
720 protected abstract Object reduceArrow();
722 * exp ::= bexp (HASTYPE type)?
724 protected abstract Object reduceLocalTypeAnnotation();
726 * equationBlock ::= (equation (SEMICOLON equation)*)?
728 protected abstract Object reduceEquationBlock();
730 * declaration ::= MODULE LBRACE (field (COMMA field)*)? RBRACE
732 protected abstract Object reduceModuleHeader();
734 * declaration ::= (var COMMA)* var HASTYPE type
736 protected abstract Object reduceTypeAnnotation();
738 * declaration ::= bexp rhs
740 protected abstract Object reduceValueDefinition();
742 * declaration ::= DATA ID ID* (EQUALS (constructor BAR)* constructor)?
744 protected abstract Object reduceDataDefinition();
746 * declaration ::= TYPE ID ID* EQUALS type
748 protected abstract Object reduceTypeDefinition();
750 * declaration ::= CLASS context? ID ID* (BAR fundeps | (BAR fundeps)? WHERE declarations)?
752 protected abstract Object reduceClassDefinition();
754 * declaration ::= INSTANCE context? ID atype atype* (WHERE declarations)?
756 protected abstract Object reduceInstanceDefinition();
758 * declaration ::= DERIVING INSTANCE context? ID atype atype*
760 protected abstract Object reduceDerivingInstanceDefinition();
762 * declaration ::= BEGIN_STRING END_STRING
764 protected abstract Object reduceDocumentationString();
766 * declaration ::= ANNOTATION_ID aexp*
768 protected abstract Object reduceAnnotation();
770 * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)* var
772 protected abstract Object reducePrecedenceDefinition();
774 * declaration ::= import
776 protected abstract Object reduceJustImport();
778 * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
780 protected abstract Object reduceImportJava();
782 * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
784 protected abstract Object reduceEffectDefinition();
786 * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)* ID)? WHERE ruleDeclarations
788 protected abstract Object reduceRuleDefinition();
790 * declaration ::= MAPPING_RELATION ID atype*
792 protected abstract Object reduceMappingRelationDefinition();
794 * declaration ::= bexp FOLLOWS ruleDeclarations
796 protected abstract Object reduceRelationDefinition();
798 * declaration ::= RULESET ID WHERE statements
800 protected abstract Object reduceRulesetDefinition();
802 * command ::= statement
804 protected abstract Object reduceStatementCommand();
808 protected abstract Object reduceImportCommand();
812 protected abstract Object reduceGuardStatement();
814 * statement ::= exp rhs
816 protected abstract Object reduceLetStatement();
818 * statement ::= exp BINDS exp
820 protected abstract Object reduceBindStatement();
822 * statement ::= exp FOLLOWS queryBlock
824 protected abstract Object reduceRuleStatement();
826 * statement ::= chrQuery IMPLIES chrQuery
828 protected abstract Object reduceCHRStatement();
830 * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
832 protected abstract Object reduceVerboseCHRStatement();
834 * statement ::= CONSTRAINT constructor
836 protected abstract Object reduceConstraintStatement();
838 * statement ::= INCLUDE ID aexp
840 protected abstract Object reduceLocalInclude();
842 * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)* declaration)?)? RBRACE
844 protected abstract Object reduceDeclarations();
846 * field ::= ID EQUALS exp
848 protected abstract Object reduceField();
852 protected abstract Object reduceFieldShorthand();
856 protected abstract Object reduceVarId();
858 * var ::= ESCAPED_SYMBOL
860 protected abstract Object reduceEscapedSymbol();
862 * var ::= LPAREN COMMA COMMA* RPAREN
864 protected abstract Object reduceTupleConstructor();
866 * bexp ::= MINUS? lexp (symbol lexp)*
868 protected abstract Object reduceBinary();
870 * rhs ::= EQUALS exp (WHERE statements)?
872 protected abstract Object reduceSimpleRhs();
874 * rhs ::= guardedExpEq guardedExpEq* (WHERE statements)?
876 protected abstract Object reduceGuardedRhs();
878 * constructor ::= (ANNOTATION_ID aexp)* ID atype*
880 protected abstract Object reduceConstructor();
882 * constructor ::= (ANNOTATION_ID aexp)* ID LBRACE fieldDeclaration (COMMA fieldDeclaration)* RBRACE
884 protected abstract Object reduceRecordConstructor();
886 * context ::= LPAREN type (COMMA type)* RPAREN IMPLIES
888 protected abstract Object reduceContext();
890 * fundeps ::= (fundep COMMA)* fundep
892 protected abstract Object reduceFundeps();
896 protected abstract Object reduceTypeVar();
898 * atype ::= LPAREN (type (COMMA (type COMMA)* type)?)? RPAREN
900 protected abstract Object reduceTupleType();
902 * atype ::= LBRACKET type RBRACKET
904 protected abstract Object reduceListType();
906 * atype ::= LBRACKET RBRACKET
908 protected abstract Object reduceListTypeConstructor();
910 * atype ::= LPAREN COMMA COMMA* RPAREN
912 protected abstract Object reduceTupleTypeConstructor();
914 * aexp ::= LAMBDA aexp aexp* ARROW exp
916 protected abstract Object reduceLambda();
918 * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE
920 protected abstract Object reduceLambdaMatch();
922 * aexp ::= LET statements IN exp
924 protected abstract Object reduceLet();
926 * aexp ::= IF exp THEN exp (ELSE exp)?
928 protected abstract Object reduceIf();
930 * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)* RBRACE
932 protected abstract Object reduceMatch();
934 * aexp ::= (DO | MDO) statements
936 protected abstract Object reduceDo();
938 * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
940 protected abstract Object reduceSelect();
942 * aexp ::= CHR_SELECT exp WHERE verboseChrQuery
944 protected abstract Object reduceCHRSelect();
946 * aexp ::= ENFORCE queryBlock
948 protected abstract Object reduceEnforce();
952 protected abstract Object reduceVar();
954 * aexp ::= ATTACHED_HASH ID
956 protected abstract Object reduceHashedId();
960 protected abstract Object reduceBlank();
964 protected abstract Object reduceInteger();
968 protected abstract Object reduceFloat();
970 * aexp ::= stringLiteral
972 protected abstract Object reduceString();
976 protected abstract Object reduceChar();
978 * aexp ::= LPAREN (exp (COMMA (exp COMMA)* exp)?)? RPAREN
980 protected abstract Object reduceTuple();
982 * aexp ::= LPAREN exp ARROW exp RPAREN
984 protected abstract Object reduceViewPattern();
986 * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
988 protected abstract Object reduceRightSection();
990 * aexp ::= LPAREN lexp symbol RPAREN
992 protected abstract Object reduceLeftSection();
994 * aexp ::= LBRACKET (exp (COMMA (exp COMMA)* exp)?)? RBRACKET
996 protected abstract Object reduceListLiteral();
998 * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
1000 protected abstract Object reduceRange();
1002 * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)* RBRACKET
1004 protected abstract Object reduceListComprehension();
1006 * aexp ::= ID AT aexp
1008 protected abstract Object reduceAs();
1010 * aexp ::= ID LBRACE (field (COMMA field)*)? RBRACE
1012 protected abstract Object reduceRecord();
1014 * aexp ::= TRANSFORMATION ID WHERE queryBlock
1016 protected abstract Object reduceTransformation();
1018 * aexp ::= EQ LBRACE equationBlock RBRACE
1020 protected abstract Object reduceEq();
1022 * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)* ruleDeclaration)?)? RBRACE
1024 protected abstract Object reduceRuleDeclarations();
1026 * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)* statement)?)? RBRACE
1028 protected abstract Object reduceStatements();
1030 * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)* importItem)?)? RPAREN
1032 protected abstract Object reduceImportShowing();
1034 * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN
1036 protected abstract Object reduceImportHiding();
1040 protected abstract Object reduceImportValueItem();
1042 * fieldDeclaration ::= ID HASTYPE type
1044 protected abstract Object reduceFieldDescription();
1046 * guardedExpEq ::= BAR exp (COMMA exp)* EQUALS exp
1048 protected abstract Object reduceGuardedExpEq();
1050 * fundep ::= ID ID* ARROW ID
1052 protected abstract Object reduceFundep();
1054 * ruleDeclaration ::= query
1056 protected abstract Object reduceQueryRuleDeclaration();
1060 protected abstract Object reduceGuardQuery();
1062 * query ::= exp EQUALS exp
1064 protected abstract Object reduceEqualsQuery();
1066 * query ::= exp BINDS exp
1068 protected abstract Object reduceBindQuery();
1070 * query ::= QUERY_OP queryBlock
1072 protected abstract Object reduceCompositeQuery();
1074 * lexp ::= faexp faexp*
1076 protected abstract Object reduceApply();
1080 protected abstract Object reduceSymbol();
1082 * symbol ::= ESCAPED_ID
1084 protected abstract Object reduceEscapedId();
1088 protected abstract Object reduceMinus();
1092 protected abstract Object reduceLess();
1094 * symbol ::= GREATER
1096 protected abstract Object reduceGreater();
1098 * symbol ::= SEPARATED_DOT
1100 protected abstract Object reduceDot();
1102 * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)*
1104 protected abstract Object reduceFieldAccess();
1108 protected abstract Object reduceIdAccessor();
1110 * accessor ::= BEGIN_STRING END_STRING
1112 protected abstract Object reduceStringAccessor();
1114 * accessor ::= LPAREN exp RPAREN
1116 protected abstract Object reduceExpAccessor();
1118 * case ::= exp caseRhs
1120 protected abstract Object reduceCase();
1122 * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)* query)?)? RBRACE
1124 protected abstract Object reduceQueryBlock();
1126 * verboseChrQuery ::= LBRACE chrQuery (SEMICOLON chrQuery)* RBRACE
1128 protected abstract Object reduceVerboseCHRConjunction();
1130 * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING
1132 protected abstract Object reduceStringLiteral();
1134 * listQualifier ::= exp
1136 protected abstract Object reduceGuardQualifier();
1138 * listQualifier ::= exp EQUALS exp
1140 protected abstract Object reduceLetQualifier();
1142 * listQualifier ::= exp BINDS exp
1144 protected abstract Object reduceBindQualifier();
1146 * listQualifier ::= THEN exp (BY exp)?
1148 protected abstract Object reduceThenQualifier();
1150 * chrQuery ::= (chrQueryPart COMMA)* chrQueryPart
1152 protected abstract Object reduceCHRConjunction();
1154 * chrQueryPart ::= exp
1156 protected abstract Object reduceCHRAtom();
1158 * chrQueryPart ::= exp EQUALS exp
1160 protected abstract Object reduceCHREquals();
1162 * chrQueryPart ::= exp BINDS exp
1164 protected abstract Object reduceCHRBinds();
1166 * caseRhs ::= ARROW exp (WHERE statements)?
1168 protected abstract Object reduceSimpleCaseRhs();
1170 * caseRhs ::= guardedExpArrow guardedExpArrow* (WHERE statements)?
1172 protected abstract Object reduceGuardedCaseRhs();
1174 * guardedExpArrow ::= BAR exp (COMMA exp)* ARROW exp
1176 protected abstract Object reduceGuardedExpArrow();
1180 protected abstract Object reduceGuardEquation();
1182 * equation ::= exp EQUALS exp
1184 protected abstract Object reduceBasicEquation();
1186 * etype ::= LESS ID (COMMA ID)* GREATER btype
1188 protected abstract Object reduceEffect();
1192 protected abstract Object reduceJustEtype();
1194 * etype ::= FORALL ID ID* (SEPARATED_DOT | ATTACHED_DOT) type
1196 protected abstract Object reduceForAll();
1198 * btype ::= atype atype*
1200 protected abstract Object reduceApplyType();
1202 * dummy ::= COMMENT EOL
1204 protected abstract Object reduceDummy();
1206 protected void postReduce(Object reduced) {