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 = 368;
17 private static final int TERMINAL_COUNT = 88;
18 private static final int NONTERMINAL_COUNT = 52;
19 private static final int PRODUCT_COUNT = 142;
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[6820];
24 private static final int[] ERROR_TABLE = new int[1012];
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[] {
128 public static final String[] NONTERMINAL_NAMES = new String[] {
165 "symbolWithoutMinus",
185 DataInputStream input = new DataInputStream(SCLParser.class.getResourceAsStream("SCLParser.dat"));
186 for(int i=0;i<ACTION_ROW_ID.length;++i)
187 ACTION_ROW_ID[i] = input.readInt();
188 for(int i=0;i<ACTION_COLUMN_ID.length;++i)
189 ACTION_COLUMN_ID[i] = input.readInt();
190 for(int i=0;i<ACTION_TABLE.length;++i)
191 ACTION_TABLE[i] = input.readShort();
192 for(int i=0;i<ERROR_TABLE.length;++i)
193 ERROR_TABLE[i] = input.readInt();
194 for(int i=0;i<GOTO_ROW_ID.length;++i)
195 GOTO_ROW_ID[i] = input.readInt();
196 for(int i=0;i<GOTO_COLUMN_ID.length;++i)
197 GOTO_COLUMN_ID[i] = input.readInt();
198 for(int i=0;i<GOTO_TABLE.length;++i)
199 GOTO_TABLE[i] = input.readShort();
200 for(int i=0;i<PRODUCT_LHS.length;++i)
201 PRODUCT_LHS[i] = input.readInt();
203 } catch(IOException e) {
208 private static short getAction(int state, int symbol) {
209 int id = TERMINAL_COUNT*state + symbol;
210 if( ((ERROR_TABLE[id>>5] >> (id&31))&1) != 0 )
212 return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]];
215 private static short getGoto(int state, int symbol) {
216 return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]];
219 protected abstract Token nextToken();
221 private Object[] symbolStack = new Object[INITIAL_CAPACITY];
222 private int symbolStackLength = 0;
224 private int[] stateStack = new int[INITIAL_CAPACITY];
225 private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY];
226 private int stateStackLength = 0;
229 private int reductionLength;
231 protected int length() {
232 return reductionLength;
235 protected Object get(int i) {
236 if(i < 0 || i >= reductionLength)
237 throw new IndexOutOfBoundsException();
238 return symbolStack[symbolStackLength+i];
241 private String parseErrorDescription(int state, Token token, int tokenId) {
242 StringBuilder b = new StringBuilder();
243 b.append("Unexpected token '").append(token)
244 .append("' (").append(TERMINAL_NAMES[tokenId])
245 .append("). Expected one of ");
246 ArrayList<String> possibleTerminals = new ArrayList<String>();
247 for(int i=0;i<TERMINAL_COUNT;++i)
248 if(getAction(state, i) != ERROR_ACTION)
249 possibleTerminals.add(TERMINAL_NAMES[i]);
250 Collections.sort(possibleTerminals);
251 for(int i=0;i<possibleTerminals.size();++i) {
254 b.append(possibleTerminals.get(i));
260 protected abstract RuntimeException syntaxError(Token token, String description);
262 private static String describeAction(boolean isGoto, int action) {
263 if(action == ERROR_ACTION)
265 if(action == ACCEPT_ACTION)
267 StringBuilder b = new StringBuilder();
271 if((action & REDUCE_MASK) != 0) {
272 action ^= REDUCE_MASK;
278 if((action & POP_MASK) != 0) {
282 if((action & PUSH_MASK) != 0) {
286 b.append(' ').append(action);
290 private void printState(int state) {
291 System.out.print("state=" + state + ":");
292 for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) {
293 Object s = symbolStack[i];
294 if(s instanceof Token)
295 System.out.print(" " + TERMINAL_NAMES[((Token)s).id]);
297 System.out.print(" null");
299 System.out.print(" " + s.getClass().getSimpleName());
300 while(j>=0 && symbolStackPositionStack[j]==i)
301 System.out.print(" (" + stateStack[j--] + ")");
303 System.out.println();
306 private Object parse(int state) {
308 Token token = nextToken();
309 int tokenId = token.id;
311 System.out.println("---> token " + TERMINAL_NAMES[tokenId] + " \"" + token.text + "\" <---");
315 short action = getAction(state, tokenId);
317 System.out.println(" -> action=" + describeAction(false, action));
318 //System.out.println(STATE_DESCRIPTIONS[state]);
319 if((action & REDUCE_MASK) != 0) {
320 if(action == ACCEPT_ACTION)
321 return symbolStack[symbolStackLength-1];
322 if(action == ERROR_ACTION)
323 throw syntaxError(token, parseErrorDescription(state, token, tokenId));
324 int popAmount = (action >>> 13)&3;
327 System.out.println(" POP " + popAmount);
329 stateStackLength -= popAmount;
330 action &= STATE_MASK;
332 int reductionBegin = symbolStackPositionStack[--stateStackLength];
334 reductionLength = symbolStackLength-reductionBegin;
335 symbolStackLength = reductionBegin;
337 if(symbolStackLength == symbolStack.length)
338 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
339 Object symbol = reduce(action);
341 symbolStack[symbolStackLength] = symbol;
343 state = stateStack[stateStackLength];
348 System.out.println(" nonterminal=" + NONTERMINAL_NAMES[PRODUCT_LHS[action]]);
350 action = getGoto(state, PRODUCT_LHS[action]);
352 System.out.println(" -> action=" + describeAction(true, action));
355 if((action & POP_MASK) != 0) {
359 if((action & PUSH_MASK) != 0) {
360 if(stateStackLength == stateStack.length) {
361 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
362 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
364 symbolStackPositionStack[stateStackLength] = symbolStackLength;
365 stateStack[stateStackLength++] = state;
367 state = action & STATE_MASK;
372 if((action & POP_MASK) != 0) {
376 if((action & PUSH_MASK) != 0) {
377 if(stateStackLength == stateStack.length) {
378 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
379 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
381 symbolStackPositionStack[stateStackLength] = symbolStackLength;
382 stateStack[stateStackLength++] = state;
386 state = action & STATE_MASK;
389 if(symbolStackLength == symbolStack.length)
390 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
391 symbolStack[symbolStackLength++] = token;
398 public Object parseModule() {
401 public Object parseCommands() {
404 public Object parseImport() {
407 public Object parseType() {
410 public Object parseExp() {
413 public Object parseEquationBlock() {
418 protected Object reduce(int productionId) {
420 switch(productionId) {
422 return reduceModule();
424 return reduceOneCommand();
426 return reduceManyCommands();
428 return reduceImport();
430 return reduceArrow();
432 return reduceLocalTypeAnnotation();
434 return reduceEquationBlock();
436 return reduceModuleHeader();
438 return reduceTypeAnnotation();
440 return reduceValueDefinition();
442 return reduceDataDefinition();
444 return reduceTypeDefinition();
446 return reduceClassDefinition();
448 return reduceInstanceDefinition();
450 return reduceDerivingInstanceDefinition();
452 return reduceDocumentationString();
454 return reduceAnnotation();
456 return reducePrecedenceDefinition();
458 return reduceJustImport();
460 return reduceImportJava();
462 return reduceEffectDefinition();
464 return reduceRuleDefinition();
466 return reduceMappingRelationDefinition();
468 return reduceRelationDefinition();
470 return reduceRulesetDefinition();
472 return reduceStatementCommand();
474 return reduceImportCommand();
476 return reduceGuardStatement();
478 return reduceLetStatement();
480 return reduceBindStatement();
482 return reduceRuleStatement();
484 return reduceCHRStatement();
486 return reduceVerboseCHRStatement();
488 return reduceConstraintStatement();
490 return reduceLocalInclude();
492 return reduceDeclarations();
494 return reduceField();
496 return reduceFieldShorthand();
498 return reduceWildcard();
500 return reduceVarId();
502 return reduceEscapedSymbol();
504 return reduceTupleConstructor();
506 return reduceBinary();
508 return reduceSimpleRhs();
510 return reduceGuardedRhs();
512 return reduceConstructor();
514 return reduceRecordConstructor();
516 return reduceContext();
518 return reduceFundeps();
520 return reduceTypeVar();
522 return reducePlainEffect();
524 return reduceTupleType();
526 return reduceListType();
528 return reduceListTypeConstructor();
530 return reduceTupleTypeConstructor();
532 return reduceLambda();
534 return reduceLambdaMatch();
540 return reduceMatch();
544 return reduceSelect();
546 return reduceCHRSelect();
548 return reduceEnforce();
552 return reduceHashedId();
554 return reduceBlank();
556 return reduceInteger();
558 return reduceFloat();
560 return reduceString();
564 return reduceTuple();
566 return reduceViewPattern();
568 return reduceRightSection();
570 return reduceLeftSection();
572 return reduceListLiteral();
574 return reduceRange();
576 return reduceListComprehension();
580 return reduceRecord();
582 return reduceTransformation();
586 return reduceRuleDeclarations();
588 return reduceStatements();
590 return reduceImportShowing();
592 return reduceImportHiding();
594 return reduceImportValueItem();
596 return reduceFieldDescription();
598 return reduceGuardedExpEq();
600 return reduceFundep();
602 return reduceQueryRuleDeclaration();
604 return reduceAnnotation();
606 return reduceGuardQuery();
608 return reduceEqualsQuery();
610 return reduceBindQuery();
612 return reduceCompositeQuery();
614 return reduceApply();
616 return reduceSymbol();
618 return reduceEscapedId();
620 return reduceMinus();
624 return reduceGreater();
626 return reduceDoubleLess();
628 return reduceDoubleGreater();
632 return reduceFieldAccess();
634 return reduceIdAccessor();
636 return reduceStringAccessor();
638 return reduceExpAccessor();
642 return reduceQueryBlock();
644 return reduceVerboseCHRConjunction();
646 return reduceStringLiteral();
648 return reduceSymbol();
650 return reduceEscapedId();
654 return reduceGreater();
658 return reduceGuardQualifier();
660 return reduceLetQualifier();
662 return reduceBindQualifier();
664 return reduceThenQualifier();
666 return reduceCHRConjunction();
668 return reduceCHRAtom();
670 return reduceCHREquals();
672 return reduceCHRBinds();
674 return reduceSimpleCaseRhs();
676 return reduceGuardedCaseRhs();
678 return reduceGuardedExpArrow();
680 return reduceGuardEquation();
682 return reduceBasicEquation();
684 return reduceEffect();
686 return reduceJustEtype();
688 return reduceForAll();
690 return reduceApplyType();
692 return reduceDummy();
695 throw new RuntimeException("Internal parser error.");
697 } catch(SCLSyntaxErrorException e) {
698 StringBuilder b = new StringBuilder();
699 b.append("Failed to reduce");
700 for(int i=0;i<length();++i) {
702 b.append("\n (").append(i).append(") \"").append(obj).append('\"');
703 if(obj instanceof Token)
704 b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
706 b.append(" [").append(obj.getClass().getSimpleName()).append("]");
708 throw new RuntimeException(b.toString(), e);
713 * module ::= (declaration (SEMICOLON declaration)*)?
715 protected abstract Object reduceModule();
717 * commands ::= command?
719 protected abstract Object reduceOneCommand();
721 * commands ::= commands SEMICOLON command
723 protected abstract Object reduceManyCommands();
725 * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
727 protected abstract Object reduceImport();
729 * type ::= (etype (ARROW | IMPLIES))* etype
731 protected abstract Object reduceArrow();
733 * exp ::= bexp (HASTYPE type)?
735 protected abstract Object reduceLocalTypeAnnotation();
737 * equationBlock ::= (equation (SEMICOLON equation)*)?
739 protected abstract Object reduceEquationBlock();
741 * declaration ::= MODULE LBRACE (field (COMMA field)*)? RBRACE
743 protected abstract Object reduceModuleHeader();
745 * declaration ::= (var COMMA)* var HASTYPE type
747 protected abstract Object reduceTypeAnnotation();
749 * declaration ::= bexp rhs
751 protected abstract Object reduceValueDefinition();
753 * declaration ::= DATA ID ID* (EQUALS (constructor BAR)* constructor)?
755 protected abstract Object reduceDataDefinition();
757 * declaration ::= TYPE ID ID* EQUALS type
759 protected abstract Object reduceTypeDefinition();
761 * declaration ::= CLASS context? ID ID* (BAR fundeps | (BAR fundeps)? WHERE declarations)?
763 protected abstract Object reduceClassDefinition();
765 * declaration ::= INSTANCE context? ID atype atype* (WHERE declarations)?
767 protected abstract Object reduceInstanceDefinition();
769 * declaration ::= DERIVING INSTANCE context? ID atype atype*
771 protected abstract Object reduceDerivingInstanceDefinition();
773 * declaration ::= BEGIN_STRING END_STRING
775 protected abstract Object reduceDocumentationString();
777 * declaration ::= ANNOTATION_ID aexp*
779 protected abstract Object reduceAnnotation();
781 * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)* var
783 protected abstract Object reducePrecedenceDefinition();
785 * declaration ::= import
787 protected abstract Object reduceJustImport();
789 * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
791 protected abstract Object reduceImportJava();
793 * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
795 protected abstract Object reduceEffectDefinition();
797 * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)* ID)? WHERE ruleDeclarations
799 protected abstract Object reduceRuleDefinition();
801 * declaration ::= MAPPING_RELATION ID atype*
803 protected abstract Object reduceMappingRelationDefinition();
805 * declaration ::= bexp FOLLOWS ruleDeclarations
807 protected abstract Object reduceRelationDefinition();
809 * declaration ::= RULESET ID WHERE statements
811 protected abstract Object reduceRulesetDefinition();
813 * command ::= statement
815 protected abstract Object reduceStatementCommand();
819 protected abstract Object reduceImportCommand();
823 protected abstract Object reduceGuardStatement();
825 * statement ::= exp rhs
827 protected abstract Object reduceLetStatement();
829 * statement ::= exp BINDS exp
831 protected abstract Object reduceBindStatement();
833 * statement ::= exp FOLLOWS queryBlock
835 protected abstract Object reduceRuleStatement();
837 * statement ::= chrQuery IMPLIES chrQuery
839 protected abstract Object reduceCHRStatement();
841 * statement ::= WHEN verboseChrQuery THEN_AFTER_WHEN verboseChrQuery
843 protected abstract Object reduceVerboseCHRStatement();
845 * statement ::= CONSTRAINT constructor
847 protected abstract Object reduceConstraintStatement();
849 * statement ::= INCLUDE ID aexp
851 protected abstract Object reduceLocalInclude();
853 * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)* declaration)?)? RBRACE
855 protected abstract Object reduceDeclarations();
857 * field ::= ID EQUALS exp
859 protected abstract Object reduceField();
863 protected abstract Object reduceFieldShorthand();
867 protected abstract Object reduceWildcard();
871 protected abstract Object reduceVarId();
873 * var ::= ESCAPED_SYMBOL
875 protected abstract Object reduceEscapedSymbol();
877 * var ::= LPAREN COMMA COMMA* RPAREN
879 protected abstract Object reduceTupleConstructor();
881 * bexp ::= MINUS? lexp (symbol lexp)*
883 protected abstract Object reduceBinary();
885 * rhs ::= EQUALS exp (WHERE statements)?
887 protected abstract Object reduceSimpleRhs();
889 * rhs ::= guardedExpEq guardedExpEq* (WHERE statements)?
891 protected abstract Object reduceGuardedRhs();
893 * constructor ::= (ANNOTATION_ID aexp)* ID atype*
895 protected abstract Object reduceConstructor();
897 * constructor ::= (ANNOTATION_ID aexp)* ID LBRACE fieldDeclaration (COMMA fieldDeclaration)* RBRACE
899 protected abstract Object reduceRecordConstructor();
901 * context ::= LPAREN type (COMMA type)* RPAREN IMPLIES
903 protected abstract Object reduceContext();
905 * fundeps ::= (fundep COMMA)* fundep
907 protected abstract Object reduceFundeps();
911 protected abstract Object reduceTypeVar();
913 * atype ::= DOUBLE_LESS ID (COMMA ID)* DOUBLE_GREATER
915 protected abstract Object reducePlainEffect();
917 * atype ::= LPAREN (type (COMMA (type COMMA)* type)?)? RPAREN
919 protected abstract Object reduceTupleType();
921 * atype ::= LBRACKET type RBRACKET
923 protected abstract Object reduceListType();
925 * atype ::= LBRACKET RBRACKET
927 protected abstract Object reduceListTypeConstructor();
929 * atype ::= LPAREN COMMA COMMA* RPAREN
931 protected abstract Object reduceTupleTypeConstructor();
933 * aexp ::= LAMBDA aexp aexp* ARROW exp
935 protected abstract Object reduceLambda();
937 * aexp ::= LAMBDA_MATCH LBRACE case (SEMICOLON case)* RBRACE
939 protected abstract Object reduceLambdaMatch();
941 * aexp ::= LET statements IN exp
943 protected abstract Object reduceLet();
945 * aexp ::= IF exp THEN exp (ELSE exp)?
947 protected abstract Object reduceIf();
949 * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)* RBRACE
951 protected abstract Object reduceMatch();
953 * aexp ::= (DO | MDO | EDO) statements
955 protected abstract Object reduceDo();
957 * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
959 protected abstract Object reduceSelect();
961 * aexp ::= CHR_SELECT exp WHERE verboseChrQuery
963 protected abstract Object reduceCHRSelect();
965 * aexp ::= ENFORCE queryBlock
967 protected abstract Object reduceEnforce();
971 protected abstract Object reduceVar();
973 * aexp ::= ATTACHED_HASH ID
975 protected abstract Object reduceHashedId();
979 protected abstract Object reduceBlank();
983 protected abstract Object reduceInteger();
987 protected abstract Object reduceFloat();
989 * aexp ::= stringLiteral
991 protected abstract Object reduceString();
995 protected abstract Object reduceChar();
997 * aexp ::= LPAREN (exp (COMMA (exp COMMA)* exp)?)? RPAREN
999 protected abstract Object reduceTuple();
1001 * aexp ::= LPAREN exp ARROW exp RPAREN
1003 protected abstract Object reduceViewPattern();
1005 * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
1007 protected abstract Object reduceRightSection();
1009 * aexp ::= LPAREN lexp symbol RPAREN
1011 protected abstract Object reduceLeftSection();
1013 * aexp ::= LBRACKET (exp (COMMA (exp COMMA)* exp)?)? RBRACKET
1015 protected abstract Object reduceListLiteral();
1017 * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
1019 protected abstract Object reduceRange();
1021 * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)* RBRACKET
1023 protected abstract Object reduceListComprehension();
1025 * aexp ::= ID AT aexp
1027 protected abstract Object reduceAs();
1029 * aexp ::= ID LBRACE (field (COMMA field)*)? RBRACE
1031 protected abstract Object reduceRecord();
1033 * aexp ::= TRANSFORMATION ID WHERE queryBlock
1035 protected abstract Object reduceTransformation();
1037 * aexp ::= EQ LBRACE equationBlock RBRACE
1039 protected abstract Object reduceEq();
1041 * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)* ruleDeclaration)?)? RBRACE
1043 protected abstract Object reduceRuleDeclarations();
1045 * statements ::= LBRACE (statement (SEMICOLON (statement SEMICOLON)* statement)?)? RBRACE
1047 protected abstract Object reduceStatements();
1049 * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)* importItem)?)? RPAREN
1051 protected abstract Object reduceImportShowing();
1053 * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN
1055 protected abstract Object reduceImportHiding();
1059 protected abstract Object reduceImportValueItem();
1061 * fieldDeclaration ::= ID HASTYPE type
1063 protected abstract Object reduceFieldDescription();
1065 * guardedExpEq ::= BAR exp (COMMA exp)* EQUALS exp
1067 protected abstract Object reduceGuardedExpEq();
1069 * fundep ::= ID ID* ARROW ID
1071 protected abstract Object reduceFundep();
1073 * ruleDeclaration ::= query
1075 protected abstract Object reduceQueryRuleDeclaration();
1079 protected abstract Object reduceGuardQuery();
1081 * query ::= exp EQUALS exp
1083 protected abstract Object reduceEqualsQuery();
1085 * query ::= exp BINDS exp
1087 protected abstract Object reduceBindQuery();
1089 * query ::= QUERY_OP queryBlock
1091 protected abstract Object reduceCompositeQuery();
1093 * lexp ::= faexp faexp*
1095 protected abstract Object reduceApply();
1099 protected abstract Object reduceSymbol();
1101 * symbol ::= ESCAPED_ID
1103 protected abstract Object reduceEscapedId();
1107 protected abstract Object reduceMinus();
1111 protected abstract Object reduceLess();
1113 * symbol ::= GREATER
1115 protected abstract Object reduceGreater();
1117 * symbol ::= DOUBLE_LESS
1119 protected abstract Object reduceDoubleLess();
1121 * symbol ::= DOUBLE_GREATER
1123 protected abstract Object reduceDoubleGreater();
1125 * symbol ::= SEPARATED_DOT
1127 protected abstract Object reduceDot();
1129 * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)*
1131 protected abstract Object reduceFieldAccess();
1135 protected abstract Object reduceIdAccessor();
1137 * accessor ::= BEGIN_STRING END_STRING
1139 protected abstract Object reduceStringAccessor();
1141 * accessor ::= LPAREN exp RPAREN
1143 protected abstract Object reduceExpAccessor();
1145 * case ::= exp caseRhs
1147 protected abstract Object reduceCase();
1149 * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)* query)?)? RBRACE
1151 protected abstract Object reduceQueryBlock();
1153 * verboseChrQuery ::= LBRACE chrQuery (SEMICOLON chrQuery)* RBRACE
1155 protected abstract Object reduceVerboseCHRConjunction();
1157 * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING
1159 protected abstract Object reduceStringLiteral();
1161 * listQualifier ::= exp
1163 protected abstract Object reduceGuardQualifier();
1165 * listQualifier ::= exp EQUALS exp
1167 protected abstract Object reduceLetQualifier();
1169 * listQualifier ::= exp BINDS exp
1171 protected abstract Object reduceBindQualifier();
1173 * listQualifier ::= THEN exp (BY exp)?
1175 protected abstract Object reduceThenQualifier();
1177 * chrQuery ::= (chrQueryPart COMMA)* chrQueryPart
1179 protected abstract Object reduceCHRConjunction();
1181 * chrQueryPart ::= exp
1183 protected abstract Object reduceCHRAtom();
1185 * chrQueryPart ::= exp EQUALS exp
1187 protected abstract Object reduceCHREquals();
1189 * chrQueryPart ::= exp BINDS exp
1191 protected abstract Object reduceCHRBinds();
1193 * caseRhs ::= ARROW exp (WHERE statements)?
1195 protected abstract Object reduceSimpleCaseRhs();
1197 * caseRhs ::= guardedExpArrow guardedExpArrow* (WHERE statements)?
1199 protected abstract Object reduceGuardedCaseRhs();
1201 * guardedExpArrow ::= BAR exp (COMMA exp)* ARROW exp
1203 protected abstract Object reduceGuardedExpArrow();
1207 protected abstract Object reduceGuardEquation();
1209 * equation ::= exp EQUALS exp
1211 protected abstract Object reduceBasicEquation();
1213 * etype ::= LESS ID (COMMA ID)* GREATER btype
1215 protected abstract Object reduceEffect();
1219 protected abstract Object reduceJustEtype();
1221 * etype ::= FORALL ID ID* (SEPARATED_DOT | ATTACHED_DOT) type
1223 protected abstract Object reduceForAll();
1225 * btype ::= atype atype*
1227 protected abstract Object reduceApplyType();
1229 * dummy ::= COMMENT EOL
1231 protected abstract Object reduceDummy();
1233 protected void postReduce(Object reduced) {