1 package org.simantics.scl.compiler.internal.parsing.parser;
\r
3 import java.io.DataInputStream;
\r
4 import java.io.IOException;
\r
5 import java.util.ArrayList;
\r
6 import java.util.Arrays;
\r
7 import java.util.Collections;
\r
8 import org.simantics.scl.compiler.internal.parsing.exceptions.SCLSyntaxErrorException;
\r
10 import org.simantics.scl.compiler.internal.parsing.Token;
\r
12 public abstract class SCLParser {
\r
13 public static final boolean TRACE = false;
\r
15 private static final int INITIAL_CAPACITY = 16;
\r
16 private static final int STATE_COUNT = 323;
\r
17 private static final int TERMINAL_COUNT = 79;
\r
18 private static final int NONTERMINAL_COUNT = 49;
\r
19 private static final int PRODUCT_COUNT = 126;
\r
21 private static final int[] ACTION_ROW_ID = new int[STATE_COUNT];
\r
22 private static final int[] ACTION_COLUMN_ID = new int[TERMINAL_COUNT];
\r
23 private static final short[] ACTION_TABLE = new short[5508];
\r
24 private static final int[] ERROR_TABLE = new int[798];
\r
25 private static final int[] GOTO_ROW_ID = new int[STATE_COUNT];
\r
26 private static final int[] GOTO_COLUMN_ID = new int[NONTERMINAL_COUNT];
\r
27 private static final short[] GOTO_TABLE = new short[1620];
\r
28 private static final int[] PRODUCT_LHS = new int[PRODUCT_COUNT];
\r
30 private static final short STATE_MASK = (short)0x0fff;
\r
31 private static final short REDUCE_MASK = (short)0x8000;
\r
32 private static final short POP_MASK = (short)0x4000;
\r
33 private static final short PUSH_MASK = (short)0x2000;
\r
34 private static final short ERROR_ACTION = (short)0xffff;
\r
35 private static final short ACCEPT_ACTION = (short)0xfffe;
\r
37 public static final String[] TERMINAL_NAMES = new String[] {
\r
119 public static final String[] NONTERMINAL_NAMES = new String[] {
\r
138 "ruleDeclarations",
\r
141 "fieldDeclaration",
\r
154 "symbolWithoutMinus",
\r
173 DataInputStream input = new DataInputStream(SCLParser.class.getResourceAsStream("SCLParser.dat"));
\r
174 for(int i=0;i<ACTION_ROW_ID.length;++i)
\r
175 ACTION_ROW_ID[i] = input.readInt();
\r
176 for(int i=0;i<ACTION_COLUMN_ID.length;++i)
\r
177 ACTION_COLUMN_ID[i] = input.readInt();
\r
178 for(int i=0;i<ACTION_TABLE.length;++i)
\r
179 ACTION_TABLE[i] = input.readShort();
\r
180 for(int i=0;i<ERROR_TABLE.length;++i)
\r
181 ERROR_TABLE[i] = input.readInt();
\r
182 for(int i=0;i<GOTO_ROW_ID.length;++i)
\r
183 GOTO_ROW_ID[i] = input.readInt();
\r
184 for(int i=0;i<GOTO_COLUMN_ID.length;++i)
\r
185 GOTO_COLUMN_ID[i] = input.readInt();
\r
186 for(int i=0;i<GOTO_TABLE.length;++i)
\r
187 GOTO_TABLE[i] = input.readShort();
\r
188 for(int i=0;i<PRODUCT_LHS.length;++i)
\r
189 PRODUCT_LHS[i] = input.readInt();
\r
191 } catch(IOException e) {
\r
192 e.printStackTrace();
\r
196 private static short getAction(int state, int symbol) {
\r
197 int id = TERMINAL_COUNT*state + symbol;
\r
198 if( ((ERROR_TABLE[id>>5] >> (id&31))&1) != 0 )
\r
199 return ERROR_ACTION;
\r
200 return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]];
\r
203 private static short getGoto(int state, int symbol) {
\r
204 return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]];
\r
207 protected abstract Token nextToken();
\r
209 private Object[] symbolStack = new Object[INITIAL_CAPACITY];
\r
210 private int symbolStackLength = 0;
\r
212 private int[] stateStack = new int[INITIAL_CAPACITY];
\r
213 private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY];
\r
214 private int stateStackLength = 0;
\r
217 private int reductionLength;
\r
219 protected int length() {
\r
220 return reductionLength;
\r
223 protected Object get(int i) {
\r
224 if(i < 0 || i >= reductionLength)
\r
225 throw new IndexOutOfBoundsException();
\r
226 return symbolStack[symbolStackLength+i];
\r
229 private String parseErrorDescription(int state, Token token, int tokenId) {
\r
230 StringBuilder b = new StringBuilder();
\r
231 b.append("Unexpected token '").append(token)
\r
232 .append("' (").append(TERMINAL_NAMES[tokenId])
\r
233 .append("). Expected one of ");
\r
234 ArrayList<String> possibleTerminals = new ArrayList<String>();
\r
235 for(int i=0;i<TERMINAL_COUNT;++i)
\r
236 if(getAction(state, i) != ERROR_ACTION)
\r
237 possibleTerminals.add(TERMINAL_NAMES[i]);
\r
238 Collections.sort(possibleTerminals);
\r
239 for(int i=0;i<possibleTerminals.size();++i) {
\r
242 b.append(possibleTerminals.get(i));
\r
245 return b.toString();
\r
248 protected abstract RuntimeException syntaxError(Token token, String description);
\r
250 private static String describeAction(int action) {
\r
251 if(action == ERROR_ACTION)
\r
253 if(action == ACCEPT_ACTION)
\r
255 StringBuilder b = new StringBuilder();
\r
256 if((action & REDUCE_MASK) != 0) {
\r
257 action ^= REDUCE_MASK;
\r
258 b.append("REDUCE");
\r
262 if((action & POP_MASK) != 0) {
\r
263 action ^= POP_MASK;
\r
266 if((action & PUSH_MASK) != 0) {
\r
267 action ^= PUSH_MASK;
\r
270 b.append(' ').append(action);
\r
271 return b.toString();
\r
274 private Object parse(int state) {
\r
276 Token token = nextToken();
\r
277 int tokenId = token.id;
\r
279 short action = getAction(state, tokenId);
\r
281 System.out.println("state=" + state + ", tokenId=" + TERMINAL_NAMES[tokenId] +
\r
282 ", action=" + describeAction(action));
\r
283 System.out.print(" ");
\r
284 for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) {
\r
285 Object s = symbolStack[i];
\r
286 if(s instanceof Token)
\r
287 System.out.print(" " + TERMINAL_NAMES[((Token)s).id]);
\r
289 System.out.print(" " + s.getClass().getSimpleName());
\r
290 while(j>=0 && symbolStackPositionStack[j]==i)
\r
291 System.out.print(" (" + stateStack[j--] + ")");
\r
293 System.out.println();
\r
295 //System.out.println(STATE_DESCRIPTIONS[state]);
\r
296 if((action & REDUCE_MASK) != 0) {
\r
297 if(action == ACCEPT_ACTION)
\r
298 return symbolStack[symbolStackLength-1];
\r
299 if(action == ERROR_ACTION)
\r
300 throw syntaxError(token, parseErrorDescription(state, token, tokenId));
\r
301 stateStackLength -= (action >>> 13)&3;
\r
302 action &= STATE_MASK;
\r
304 int reductionBegin = symbolStackPositionStack[--stateStackLength];
\r
306 reductionLength = symbolStackLength-reductionBegin;
\r
307 symbolStackLength = reductionBegin;
\r
309 if(symbolStackLength == symbolStack.length)
\r
310 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
\r
311 Object symbol = reduce(action);
\r
312 postReduce(symbol);
\r
313 symbolStack[symbolStackLength] = symbol;
\r
315 state = stateStack[stateStackLength];
\r
316 action = getGoto(state, PRODUCT_LHS[action]);
\r
318 if((action & POP_MASK) != 0) {
\r
319 --stateStackLength;
\r
322 if((action & PUSH_MASK) != 0) {
\r
323 if(stateStackLength == stateStack.length) {
\r
324 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
\r
325 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
\r
327 symbolStackPositionStack[stateStackLength] = symbolStackLength;
\r
328 stateStack[stateStackLength++] = state;
\r
330 state = action & STATE_MASK;
\r
331 ++symbolStackLength;
\r
335 if((action & POP_MASK) != 0) {
\r
336 --stateStackLength;
\r
339 if((action & PUSH_MASK) != 0) {
\r
340 if(stateStackLength == stateStack.length) {
\r
341 stateStack = Arrays.copyOf(stateStack, stateStackLength*2);
\r
342 symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2);
\r
344 symbolStackPositionStack[stateStackLength] = symbolStackLength;
\r
345 stateStack[stateStackLength++] = state;
\r
349 state = action & STATE_MASK;
\r
352 if(symbolStackLength == symbolStack.length)
\r
353 symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2);
\r
354 symbolStack[symbolStackLength++] = token;
\r
361 public Object parseModule() {
\r
364 public Object parseCommands() {
\r
367 public Object parseImport() {
\r
370 public Object parseType() {
\r
373 public Object parseExp() {
\r
376 public Object parseEquationBlock() {
\r
381 protected Object reduce(int productionId) {
\r
383 switch(productionId) {
\r
385 return reduceModule();
\r
387 return reduceOneCommand();
\r
389 return reduceManyCommands();
\r
391 return reduceImport();
\r
393 return reduceArrow();
\r
395 return reduceLocalTypeAnnotation();
\r
397 return reduceEntityTypeAnnotation();
\r
399 return reduceEquationBlock();
\r
401 return reduceTypeAnnotation();
\r
403 return reduceValueDefinition();
\r
405 return reduceDataDefinition();
\r
407 return reduceTypeDefinition();
\r
409 return reduceClassDefinition();
\r
411 return reduceInstanceDefinition();
\r
413 return reduceDerivingInstanceDefinition();
\r
415 return reduceDocumentationString();
\r
417 return reduceAnnotation();
\r
419 return reducePrecedenceDefinition();
\r
421 return reduceJustImport();
\r
423 return reduceImportJava();
\r
425 return reduceEffectDefinition();
\r
427 return reduceRuleDefinition();
\r
429 return reduceMappingRelationDefinition();
\r
431 return reduceRelationDefinition();
\r
433 return reduceStatementCommand();
\r
435 return reduceImportCommand();
\r
437 return reduceGuardStatement();
\r
439 return reduceLetStatement();
\r
441 return reduceBindStatement();
\r
443 return reduceRuleStatement();
\r
445 return reduceDeclarations();
\r
447 return reduceVarId();
\r
449 return reduceEscapedSymbol();
\r
451 return reduceTupleConstructor();
\r
453 return reduceBinary();
\r
455 return reduceSimpleRhs();
\r
457 return reduceGuardedRhs();
\r
459 return reduceConstructor();
\r
461 return reduceRecordConstructor();
\r
463 return reduceContext();
\r
465 return reduceFundeps();
\r
467 return reduceTypeVar();
\r
469 return reduceTupleType();
\r
471 return reduceListType();
\r
473 return reduceListTypeConstructor();
\r
475 return reduceTupleTypeConstructor();
\r
477 return reduceLambda();
\r
479 return reduceLet();
\r
483 return reduceMatch();
\r
487 return reduceSelect();
\r
489 return reduceEnforce();
\r
491 return reduceWhen();
\r
493 return reduceVar();
\r
495 return reduceHashedId();
\r
497 return reduceBlank();
\r
499 return reduceInteger();
\r
501 return reduceFloat();
\r
503 return reduceString();
\r
505 return reduceChar();
\r
507 return reduceTuple();
\r
509 return reduceRightSection();
\r
511 return reduceLeftSection();
\r
513 return reduceListLiteral();
\r
515 return reduceRange();
\r
517 return reduceListComprehension();
\r
521 return reduceRecord();
\r
523 return reduceTransformation();
\r
527 return reduceRuleDeclarations();
\r
529 return reduceImportShowing();
\r
531 return reduceImportHiding();
\r
533 return reduceImportValueItem();
\r
535 return reduceFieldDescription();
\r
537 return reduceStatements();
\r
539 return reduceGuardedExpEq();
\r
541 return reduceFundep();
\r
543 return reduceQueryRuleDeclaration();
\r
545 return reduceAnnotation();
\r
547 return reduceGuardQuery();
\r
549 return reduceEqualsQuery();
\r
551 return reduceBindQuery();
\r
553 return reduceCompositeQuery();
\r
555 return reduceQueryBlock();
\r
557 return reduceApply();
\r
559 return reduceSymbol();
\r
561 return reduceEscapedId();
\r
563 return reduceMinus();
\r
565 return reduceLess();
\r
567 return reduceGreater();
\r
569 return reduceDot();
\r
571 return reduceFieldAccess();
\r
573 return reduceIdAccessor();
\r
575 return reduceStringAccessor();
\r
577 return reduceExpAccessor();
\r
579 return reduceCase();
\r
581 return reduceStringLiteral();
\r
583 return reduceSymbol();
\r
585 return reduceEscapedId();
\r
587 return reduceLess();
\r
589 return reduceGreater();
\r
591 return reduceDot();
\r
593 return reduceGuardQualifier();
\r
595 return reduceLetQualifier();
\r
597 return reduceBindQualifier();
\r
599 return reduceThenQualifier();
\r
601 return reduceField();
\r
603 return reduceFieldShorthand();
\r
605 return reduceSimpleCaseRhs();
\r
607 return reduceGuardedCaseRhs();
\r
609 return reduceGuardedExpArrow();
\r
611 return reduceGuardEquation();
\r
613 return reduceBasicEquation();
\r
615 return reduceEffect();
\r
617 return reduceJustEtype();
\r
619 return reduceForAll();
\r
621 return reduceApplyType();
\r
623 return reduceDummy1();
\r
626 throw new RuntimeException("Internal parser error.");
\r
628 } catch(SCLSyntaxErrorException e) {
\r
629 StringBuilder b = new StringBuilder();
\r
630 b.append("Failed to reduce");
\r
631 for(int i=0;i<length();++i) {
\r
632 Object obj = get(i);
\r
633 b.append("\n (").append(i).append(") \"").append(obj).append('\"');
\r
634 if(obj instanceof Token)
\r
635 b.append(" (").append(TERMINAL_NAMES[((Token)obj).id]).append(")");
\r
637 b.append(" [").append(obj.getClass().getSimpleName()).append("]");
\r
639 throw new RuntimeException(b.toString(), e);
\r
644 * module ::= (declaration (SEMICOLON declaration)*)?
\r
646 protected abstract Object reduceModule();
\r
648 * commands ::= command?
\r
650 protected abstract Object reduceOneCommand();
\r
652 * commands ::= commands SEMICOLON command
\r
654 protected abstract Object reduceManyCommands();
\r
656 * import ::= (IMPORT | INCLUDE) BEGIN_STRING END_STRING (AS ID)? importSpec?
\r
658 protected abstract Object reduceImport();
\r
660 * type ::= (etype (ARROW | IMPLIES))* etype
\r
662 protected abstract Object reduceArrow();
\r
664 * exp ::= bexp (HASTYPE type)?
\r
666 protected abstract Object reduceLocalTypeAnnotation();
\r
668 * exp ::= bexp COLON ID (queryBlock | WITH queryBlock?)?
\r
670 protected abstract Object reduceEntityTypeAnnotation();
\r
672 * equationBlock ::= (equation (SEMICOLON equation)*)?
\r
674 protected abstract Object reduceEquationBlock();
\r
676 * declaration ::= (var COMMA)* var HASTYPE type
\r
678 protected abstract Object reduceTypeAnnotation();
\r
680 * declaration ::= bexp rhs
\r
682 protected abstract Object reduceValueDefinition();
\r
684 * declaration ::= DATA ID ID* (EQUALS (constructor BAR)* constructor)?
\r
686 protected abstract Object reduceDataDefinition();
\r
688 * declaration ::= TYPE ID ID* EQUALS type
\r
690 protected abstract Object reduceTypeDefinition();
\r
692 * declaration ::= CLASS context? ID ID* (BAR fundeps | (BAR fundeps)? WHERE declarations)?
\r
694 protected abstract Object reduceClassDefinition();
\r
696 * declaration ::= INSTANCE context? ID atype atype* (WHERE declarations)?
\r
698 protected abstract Object reduceInstanceDefinition();
\r
700 * declaration ::= DERIVING INSTANCE context? ID atype atype*
\r
702 protected abstract Object reduceDerivingInstanceDefinition();
\r
704 * declaration ::= BEGIN_STRING END_STRING
\r
706 protected abstract Object reduceDocumentationString();
\r
708 * declaration ::= ANNOTATION_ID aexp*
\r
710 protected abstract Object reduceAnnotation();
\r
712 * declaration ::= (INFIX | INFIXL | INFIXR) INTEGER (var COMMA)* var
\r
714 protected abstract Object reducePrecedenceDefinition();
\r
716 * declaration ::= import
\r
718 protected abstract Object reduceJustImport();
\r
720 * declaration ::= IMPORTJAVA BEGIN_STRING END_STRING WHERE declarations
\r
722 protected abstract Object reduceImportJava();
\r
724 * declaration ::= EFFECT ID BEGIN_STRING END_STRING BEGIN_STRING END_STRING
\r
726 protected abstract Object reduceEffectDefinition();
\r
728 * declaration ::= (RULE | ABSTRACT_RULE) ID (EXTENDS (ID COMMA)* ID)? WHERE ruleDeclarations
\r
730 protected abstract Object reduceRuleDefinition();
\r
732 * declaration ::= MAPPING_RELATION ID atype*
\r
734 protected abstract Object reduceMappingRelationDefinition();
\r
736 * declaration ::= bexp FOLLOWS ruleDeclarations
\r
738 protected abstract Object reduceRelationDefinition();
\r
740 * command ::= statement
\r
742 protected abstract Object reduceStatementCommand();
\r
744 * command ::= import
\r
746 protected abstract Object reduceImportCommand();
\r
748 * statement ::= exp
\r
750 protected abstract Object reduceGuardStatement();
\r
752 * statement ::= exp rhs
\r
754 protected abstract Object reduceLetStatement();
\r
756 * statement ::= exp BINDS exp
\r
758 protected abstract Object reduceBindStatement();
\r
760 * statement ::= exp FOLLOWS queryBlock
\r
762 protected abstract Object reduceRuleStatement();
\r
764 * declarations ::= LBRACE (declaration (SEMICOLON (declaration SEMICOLON)* declaration)?)? RBRACE
\r
766 protected abstract Object reduceDeclarations();
\r
770 protected abstract Object reduceVarId();
\r
772 * var ::= ESCAPED_SYMBOL
\r
774 protected abstract Object reduceEscapedSymbol();
\r
776 * var ::= LPAREN COMMA COMMA* RPAREN
\r
778 protected abstract Object reduceTupleConstructor();
\r
780 * bexp ::= MINUS? lexp (symbol lexp)*
\r
782 protected abstract Object reduceBinary();
\r
784 * rhs ::= EQUALS exp (WHERE statements)?
\r
786 protected abstract Object reduceSimpleRhs();
\r
788 * rhs ::= guardedExpEq guardedExpEq* (WHERE statements)?
\r
790 protected abstract Object reduceGuardedRhs();
\r
792 * constructor ::= (ANNOTATION_ID aexp)* ID atype*
\r
794 protected abstract Object reduceConstructor();
\r
796 * constructor ::= (ANNOTATION_ID aexp)* ID LBRACE fieldDeclaration (COMMA fieldDeclaration)* RBRACE
\r
798 protected abstract Object reduceRecordConstructor();
\r
800 * context ::= LPAREN type (COMMA type)* RPAREN IMPLIES
\r
802 protected abstract Object reduceContext();
\r
804 * fundeps ::= (fundep COMMA)* fundep
\r
806 protected abstract Object reduceFundeps();
\r
810 protected abstract Object reduceTypeVar();
\r
812 * atype ::= LPAREN (type (COMMA (type COMMA)* type)?)? RPAREN
\r
814 protected abstract Object reduceTupleType();
\r
816 * atype ::= LBRACKET type RBRACKET
\r
818 protected abstract Object reduceListType();
\r
820 * atype ::= LBRACKET RBRACKET
\r
822 protected abstract Object reduceListTypeConstructor();
\r
824 * atype ::= LPAREN COMMA COMMA* RPAREN
\r
826 protected abstract Object reduceTupleTypeConstructor();
\r
828 * aexp ::= LAMBDA aexp aexp* ARROW exp
\r
830 protected abstract Object reduceLambda();
\r
832 * aexp ::= LET statements IN exp
\r
834 protected abstract Object reduceLet();
\r
836 * aexp ::= IF exp THEN exp ELSE exp
\r
838 protected abstract Object reduceIf();
\r
840 * aexp ::= MATCH exp WITH LBRACE case (SEMICOLON case)* RBRACE
\r
842 protected abstract Object reduceMatch();
\r
844 * aexp ::= (DO | MDO) statements
\r
846 protected abstract Object reduceDo();
\r
848 * aexp ::= (SELECT | SELECT_FIRST | SELECT_DISTINCT) exp WHERE queryBlock
\r
850 protected abstract Object reduceSelect();
\r
852 * aexp ::= ENFORCE queryBlock
\r
854 protected abstract Object reduceEnforce();
\r
856 * aexp ::= WHEN queryBlock SEMICOLON exp
\r
858 protected abstract Object reduceWhen();
\r
862 protected abstract Object reduceVar();
\r
864 * aexp ::= ATTACHED_HASH ID
\r
866 protected abstract Object reduceHashedId();
\r
870 protected abstract Object reduceBlank();
\r
874 protected abstract Object reduceInteger();
\r
878 protected abstract Object reduceFloat();
\r
880 * aexp ::= stringLiteral
\r
882 protected abstract Object reduceString();
\r
886 protected abstract Object reduceChar();
\r
888 * aexp ::= LPAREN (exp (COMMA (exp COMMA)* exp)?)? RPAREN
\r
890 protected abstract Object reduceTuple();
\r
892 * aexp ::= LPAREN symbolWithoutMinus lexp RPAREN
\r
894 protected abstract Object reduceRightSection();
\r
896 * aexp ::= LPAREN lexp symbol RPAREN
\r
898 protected abstract Object reduceLeftSection();
\r
900 * aexp ::= LBRACKET (exp (COMMA (exp COMMA)* exp)?)? RBRACKET
\r
902 protected abstract Object reduceListLiteral();
\r
904 * aexp ::= LBRACKET exp DOTDOT exp RBRACKET
\r
906 protected abstract Object reduceRange();
\r
908 * aexp ::= LBRACKET exp BAR listQualifier (COMMA listQualifier)* RBRACKET
\r
910 protected abstract Object reduceListComprehension();
\r
912 * aexp ::= ID AT aexp
\r
914 protected abstract Object reduceAs();
\r
916 * aexp ::= ID LBRACE (field (COMMA field)*)? RBRACE
\r
918 protected abstract Object reduceRecord();
\r
920 * aexp ::= TRANSFORMATION ID WHERE queryBlock
\r
922 protected abstract Object reduceTransformation();
\r
924 * aexp ::= EQ LBRACE equationBlock RBRACE
\r
926 protected abstract Object reduceEq();
\r
928 * ruleDeclarations ::= LBRACE (ruleDeclaration (SEMICOLON (ruleDeclaration SEMICOLON)* ruleDeclaration)?)? RBRACE
\r
930 protected abstract Object reduceRuleDeclarations();
\r
932 * importSpec ::= LPAREN (importItem (COMMA (importItem COMMA)* importItem)?)? RPAREN
\r
934 protected abstract Object reduceImportShowing();
\r
936 * importSpec ::= HIDING LPAREN (importItem (COMMA importItem)*)? RPAREN
\r
938 protected abstract Object reduceImportHiding();
\r
940 * importItem ::= ID
\r
942 protected abstract Object reduceImportValueItem();
\r
944 * fieldDeclaration ::= ID HASTYPE type
\r
946 protected abstract Object reduceFieldDescription();
\r
948 * statements ::= LBRACE statement (SEMICOLON statement)* RBRACE
\r
950 protected abstract Object reduceStatements();
\r
952 * guardedExpEq ::= BAR exp (COMMA exp)* EQUALS exp
\r
954 protected abstract Object reduceGuardedExpEq();
\r
956 * fundep ::= ID ID* ARROW ID
\r
958 protected abstract Object reduceFundep();
\r
960 * ruleDeclaration ::= query
\r
962 protected abstract Object reduceQueryRuleDeclaration();
\r
966 protected abstract Object reduceGuardQuery();
\r
968 * query ::= exp EQUALS exp
\r
970 protected abstract Object reduceEqualsQuery();
\r
972 * query ::= exp BINDS exp
\r
974 protected abstract Object reduceBindQuery();
\r
976 * query ::= QUERY_OP queryBlock
\r
978 protected abstract Object reduceCompositeQuery();
\r
980 * queryBlock ::= LBRACE (query (SEMICOLON (query SEMICOLON)* query)?)? RBRACE
\r
982 protected abstract Object reduceQueryBlock();
\r
984 * lexp ::= faexp faexp*
\r
986 protected abstract Object reduceApply();
\r
988 * symbol ::= SYMBOL
\r
990 protected abstract Object reduceSymbol();
\r
992 * symbol ::= ESCAPED_ID
\r
994 protected abstract Object reduceEscapedId();
\r
998 protected abstract Object reduceMinus();
\r
1002 protected abstract Object reduceLess();
\r
1004 * symbol ::= GREATER
\r
1006 protected abstract Object reduceGreater();
\r
1008 * symbol ::= SEPARATED_DOT
\r
1010 protected abstract Object reduceDot();
\r
1012 * faexp ::= aexp ((ATTACHED_HASH | ATTACHED_DOT) accessor)*
\r
1014 protected abstract Object reduceFieldAccess();
\r
1018 protected abstract Object reduceIdAccessor();
\r
1020 * accessor ::= BEGIN_STRING END_STRING
\r
1022 protected abstract Object reduceStringAccessor();
\r
1024 * accessor ::= LPAREN exp RPAREN
\r
1026 protected abstract Object reduceExpAccessor();
\r
1028 * case ::= exp caseRhs
\r
1030 protected abstract Object reduceCase();
\r
1032 * stringLiteral ::= BEGIN_STRING (SUSPEND_STRING exp CONTINUE_STRING)* END_STRING
\r
1034 protected abstract Object reduceStringLiteral();
\r
1036 * listQualifier ::= exp
\r
1038 protected abstract Object reduceGuardQualifier();
\r
1040 * listQualifier ::= exp EQUALS exp
\r
1042 protected abstract Object reduceLetQualifier();
\r
1044 * listQualifier ::= exp BINDS exp
\r
1046 protected abstract Object reduceBindQualifier();
\r
1048 * listQualifier ::= THEN exp (BY exp)?
\r
1050 protected abstract Object reduceThenQualifier();
\r
1052 * field ::= ID EQUALS exp
\r
1054 protected abstract Object reduceField();
\r
1058 protected abstract Object reduceFieldShorthand();
\r
1060 * caseRhs ::= ARROW exp (WHERE statements)?
\r
1062 protected abstract Object reduceSimpleCaseRhs();
\r
1064 * caseRhs ::= guardedExpArrow guardedExpArrow* (WHERE statements)?
\r
1066 protected abstract Object reduceGuardedCaseRhs();
\r
1068 * guardedExpArrow ::= BAR exp (COMMA exp)* ARROW exp
\r
1070 protected abstract Object reduceGuardedExpArrow();
\r
1072 * equation ::= exp
\r
1074 protected abstract Object reduceGuardEquation();
\r
1076 * equation ::= exp EQUALS exp
\r
1078 protected abstract Object reduceBasicEquation();
\r
1080 * etype ::= LESS ID (COMMA ID)* GREATER btype
\r
1082 protected abstract Object reduceEffect();
\r
1086 protected abstract Object reduceJustEtype();
\r
1088 * etype ::= FORALL ID ID* (SEPARATED_DOT | ATTACHED_DOT) type
\r
1090 protected abstract Object reduceForAll();
\r
1092 * btype ::= atype atype*
\r
1094 protected abstract Object reduceApplyType();
\r
1096 * dummy ::= COMMENT EOL
\r
1098 protected abstract Object reduceDummy1();
\r
1100 protected void postReduce(Object reduced) {
\r