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