X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fparsing%2Fparser%2FSCLParser.java;h=6852771b1b8558f107758215e1e557d31dc56cf2;hp=1679a019ea267c266466369e77a724403b61817e;hb=00b73fe170154840ac11c2a9403c6bcd9a0e673a;hpb=593a8f75d9dbc363234002dc500c346afbeba040 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java index 1679a019e..6852771b1 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/parser/SCLParser.java @@ -1,1144 +1,1216 @@ -package org.simantics.scl.compiler.internal.parsing.parser; - -import java.io.DataInputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import org.simantics.scl.compiler.internal.parsing.exceptions.SCLSyntaxErrorException; - -import org.simantics.scl.compiler.internal.parsing.Token; - -public abstract class SCLParser { - public static final boolean TRACE = false; - - private static final int INITIAL_CAPACITY = 16; - private static final int STATE_COUNT = 344; - private static final int TERMINAL_COUNT = 82; - private static final int NONTERMINAL_COUNT = 51; - private static final int PRODUCT_COUNT = 132; - - private static final int[] ACTION_ROW_ID = new int[STATE_COUNT]; - private static final int[] ACTION_COLUMN_ID = new int[TERMINAL_COUNT]; - private static final short[] ACTION_TABLE = new short[6120]; - private static final int[] ERROR_TABLE = new int[882]; - private static final int[] GOTO_ROW_ID = new int[STATE_COUNT]; - private static final int[] GOTO_COLUMN_ID = new int[NONTERMINAL_COUNT]; - private static final short[] GOTO_TABLE = new short[1829]; - private static final int[] PRODUCT_LHS = new int[PRODUCT_COUNT]; - - private static final short STATE_MASK = (short)0x0fff; - private static final short REDUCE_MASK = (short)0x8000; - private static final short POP_MASK = (short)0x4000; - private static final short PUSH_MASK = (short)0x2000; - private static final short ERROR_ACTION = (short)0xffff; - private static final short ACCEPT_ACTION = (short)0xfffe; - - public static final String[] TERMINAL_NAMES = new String[] { - "SEMICOLON", - "LBRACE", - "RBRACE", - "COMMA", - "HASTYPE", - "DATA", - "ID", - "EQUALS", - "BAR", - "TYPE", - "CLASS", - "WHERE", - "INSTANCE", - "DERIVING", - "BEGIN_STRING", - "END_STRING", - "ANNOTATION_ID", - "INFIX", - "INFIXL", - "INFIXR", - "INTEGER", - "IMPORTJAVA", - "EFFECT", - "RULE", - "ABSTRACT_RULE", - "EXTENDS", - "MAPPING_RELATION", - "FOLLOWS", - "IMPORT", - "INCLUDE", - "AS", - "LPAREN", - "RPAREN", - "HIDING", - "ARROW", - "COLON", - "WITH", - "MINUS", - "SYMBOL", - "LESS", - "GREATER", - "SEPARATED_DOT", - "ESCAPED_ID", - "LAMBDA", - "LAMBDA_MATCH", - "LET", - "IF", - "MATCH", - "DO", - "MDO", - "ENFORCE", - "BLANK", - "FLOAT", - "LBRACKET", - "ESCAPED_SYMBOL", - "CHAR", - "WHEN", - "ATTACHED_HASH", - "SELECT", - "SELECT_FIRST", - "SELECT_DISTINCT", - "TRANSFORMATION", - "EQ", - "ATTACHED_DOT", - "IN", - "THEN", - "ELSE", - "RBRACKET", - "DOTDOT", - "AT", - "SUSPEND_STRING", - "CONTINUE_STRING", - "BINDS", - "IMPLIES", - "THEN_AFTER_WHEN", - "CONSTRAINT", - "BY", - "QUERY_OP", - "FORALL", - "COMMENT", - "EOL", - "EOF" - }; - - public static final String[] NONTERMINAL_NAMES = new String[] { - "module", - "commands", - "import", - "type", - "exp", - "equationBlock", - "declaration", - "command", - "statement", - "declarations", - "var", - "bexp", - "rhs", - "constructor", - "context", - "fundeps", - "atype", - "aexp", - "ruleDeclarations", - "importSpec", - "importItem", - "fieldDeclaration", - "statements", - "guardedExpEq", - "fundep", - "ruleDeclaration", - "query", - "queryBlock", - "lexp", - "symbol", - "faexp", - "accessor", - "case", - "stringLiteral", - "symbolWithoutMinus", - "listQualifier", - "field", - "chrQuery", - "verboseChrQuery", - "caseRhs", - "guardedExpArrow", - "equation", - "etype", - "btype", - "dummy", - "init$6", - "init$5", - "init$4", - "init$3", - "init$2", - "init$1" - }; - - static { - try { - DataInputStream input = new DataInputStream(SCLParser.class.getResourceAsStream("SCLParser.dat")); - for(int i=0;i>5] >> (id&31))&1) != 0 ) - return ERROR_ACTION; - return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]]; - } - - private static short getGoto(int state, int symbol) { - return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]]; - } - - protected abstract Token nextToken(); - - private Object[] symbolStack = new Object[INITIAL_CAPACITY]; - private int symbolStackLength = 0; - - private int[] stateStack = new int[INITIAL_CAPACITY]; - private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY]; - private int stateStackLength = 0; - - // For reduce - private int reductionLength; - - protected int length() { - return reductionLength; - } - - protected Object get(int i) { - if(i < 0 || i >= reductionLength) - throw new IndexOutOfBoundsException(); - return symbolStack[symbolStackLength+i]; - } - - private String parseErrorDescription(int state, Token token, int tokenId) { - StringBuilder b = new StringBuilder(); - b.append("Unexpected token '").append(token) - .append("' (").append(TERMINAL_NAMES[tokenId]) - .append("). Expected one of "); - ArrayList possibleTerminals = new ArrayList(); - for(int i=0;i 0) - b.append(", "); - b.append(possibleTerminals.get(i)); - } - b.append('.'); - return b.toString(); - } - - protected abstract RuntimeException syntaxError(Token token, String description); - - private static String describeAction(int action) { - if(action == ERROR_ACTION) - return "ERROR"; - if(action == ACCEPT_ACTION) - return "ACCEPT"; - StringBuilder b = new StringBuilder(); - if((action & REDUCE_MASK) != 0) { - action ^= REDUCE_MASK; - b.append("REDUCE"); - } - else - b.append("SHIFT"); - if((action & POP_MASK) != 0) { - action ^= POP_MASK; - b.append(" POP"); - } - if((action & PUSH_MASK) != 0) { - action ^= PUSH_MASK; - b.append(" PUSH"); - } - b.append(' ').append(action); - return b.toString(); - } - - private Object parse(int state) { - while(true) { - Token token = nextToken(); - int tokenId = token.id; - while(true) { - short action = getAction(state, tokenId); - if(TRACE) { - System.out.println("state=" + state + ", tokenId=" + TERMINAL_NAMES[tokenId] + - ", action=" + describeAction(action)); - System.out.print(" "); - for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) { - Object s = symbolStack[i]; - if(s instanceof Token) - System.out.print(" " + TERMINAL_NAMES[((Token)s).id]); - else - System.out.print(" " + s.getClass().getSimpleName()); - while(j>=0 && symbolStackPositionStack[j]==i) - System.out.print(" (" + stateStack[j--] + ")"); - } - System.out.println(); - } - //System.out.println(STATE_DESCRIPTIONS[state]); - if((action & REDUCE_MASK) != 0) { - if(action == ACCEPT_ACTION) - return symbolStack[symbolStackLength-1]; - if(action == ERROR_ACTION) - throw syntaxError(token, parseErrorDescription(state, token, tokenId)); - stateStackLength -= (action >>> 13)&3; - action &= STATE_MASK; - - int reductionBegin = symbolStackPositionStack[--stateStackLength]; - - reductionLength = symbolStackLength-reductionBegin; - symbolStackLength = reductionBegin; - - if(symbolStackLength == symbolStack.length) - symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2); - Object symbol = reduce(action); - postReduce(symbol); - symbolStack[symbolStackLength] = symbol; - - state = stateStack[stateStackLength]; - action = getGoto(state, PRODUCT_LHS[action]); - // Pop state - if((action & POP_MASK) != 0) { - --stateStackLength; - } - // Push state - if((action & PUSH_MASK) != 0) { - if(stateStackLength == stateStack.length) { - stateStack = Arrays.copyOf(stateStack, stateStackLength*2); - symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2); - } - symbolStackPositionStack[stateStackLength] = symbolStackLength; - stateStack[stateStackLength++] = state; - } - state = action & STATE_MASK; - ++symbolStackLength; - } - else { - // Pop state - if((action & POP_MASK) != 0) { - --stateStackLength; - } - // Push state - if((action & PUSH_MASK) != 0) { - if(stateStackLength == stateStack.length) { - stateStack = Arrays.copyOf(stateStack, stateStackLength*2); - symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2); - } - symbolStackPositionStack[stateStackLength] = symbolStackLength; - stateStack[stateStackLength++] = state; - } - - // New state - state = action & STATE_MASK; - - // Push symbol - if(symbolStackLength == symbolStack.length) - symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2); - symbolStack[symbolStackLength++] = token; - break; - } - } - } - } - - public Object parseModule() { - return parse(0); - } - public Object parseCommands() { - return parse(329); - } - public Object parseImport() { - return parse(336); - } - public Object parseType() { - return parse(338); - } - public Object parseExp() { - return parse(340); - } - public Object parseEquationBlock() { - return parse(342); - } - - - protected Object reduce(int productionId) { - try { - switch(productionId) { - case 0: - return reduceModule(); - case 1: - return reduceOneCommand(); - case 2: - return reduceManyCommands(); - case 3: - return reduceImport(); - case 4: - return reduceArrow(); - case 5: - return reduceLocalTypeAnnotation(); - case 6: - return reduceEntityTypeAnnotation(); - case 7: - return reduceEquationBlock(); - case 8: - return reduceTypeAnnotation(); - case 9: - return reduceValueDefinition(); - case 10: - return reduceDataDefinition(); - case 11: - return reduceTypeDefinition(); - case 12: - return reduceClassDefinition(); - case 13: - return reduceInstanceDefinition(); - case 14: - return reduceDerivingInstanceDefinition(); - case 15: - return reduceDocumentationString(); - case 16: - return reduceAnnotation(); - case 17: - return reducePrecedenceDefinition(); - case 18: - return reduceJustImport(); - case 19: - return reduceImportJava(); - case 20: - return reduceEffectDefinition(); - case 21: - return reduceRuleDefinition(); - case 22: - return reduceMappingRelationDefinition(); - case 23: - return reduceRelationDefinition(); - case 24: - return reduceStatementCommand(); - case 25: - return reduceImportCommand(); - case 26: - return reduceGuardStatement(); - case 27: - return reduceLetStatement(); - case 28: - return reduceBindStatement(); - case 29: - return reduceRuleStatement(); - case 30: - return reduceCHRStatement(); - case 31: - return reduceVerboseCHRStatement(); - case 32: - return reduceConstraintStatement(); - case 33: - return reduceDeclarations(); - case 34: - return reduceVarId(); - case 35: - return reduceEscapedSymbol(); - case 36: - return reduceTupleConstructor(); - case 37: - return reduceBinary(); - case 38: - return reduceSimpleRhs(); - case 39: - return reduceGuardedRhs(); - case 40: - return reduceConstructor(); - case 41: - return reduceRecordConstructor(); - case 42: - return reduceContext(); - case 43: - return reduceFundeps(); - case 44: - return reduceTypeVar(); - case 45: - return reduceTupleType(); - case 46: - return reduceListType(); - case 47: - return reduceListTypeConstructor(); - case 48: - return reduceTupleTypeConstructor(); - case 49: - return reduceLambda(); - case 50: - return reduceLambdaMatch(); - case 51: - return reduceLet(); - case 52: - return reduceIf(); - case 53: - return reduceMatch(); - case 54: - return reduceDo(); - case 55: - return reduceSelect(); - case 56: - return reduceEnforce(); - case 57: - return reduceVar(); - case 58: - return reduceHashedId(); - case 59: - return reduceBlank(); - case 60: - return reduceInteger(); - case 61: - return reduceFloat(); - case 62: - return reduceString(); - case 63: - return reduceChar(); - case 64: - return reduceTuple(); - case 65: - return reduceViewPattern(); - case 66: - return reduceRightSection(); - case 67: - return reduceLeftSection(); - case 68: - return reduceListLiteral(); - case 69: - return reduceRange(); - case 70: - return reduceListComprehension(); - case 71: - return reduceAs(); - case 72: - return reduceRecord(); - case 73: - return reduceTransformation(); - case 74: - return reduceEq(); - case 75: - return reduceRuleDeclarations(); - case 76: - return reduceImportShowing(); - case 77: - return reduceImportHiding(); - case 78: - return reduceImportValueItem(); - case 79: - return reduceFieldDescription(); - case 80: - return reduceStatements(); - case 81: - return reduceGuardedExpEq(); - case 82: - return reduceFundep(); - case 83: - return reduceQueryRuleDeclaration(); - case 84: - return reduceAnnotation(); - case 85: - return reduceGuardQuery(); - case 86: - return reduceEqualsQuery(); - case 87: - return reduceBindQuery(); - case 88: - return reduceCompositeQuery(); - case 89: - return reduceQueryBlock(); - case 90: - return reduceApply(); - case 91: - return reduceSymbol(); - case 92: - return reduceEscapedId(); - case 93: - return reduceMinus(); - case 94: - return reduceLess(); - case 95: - return reduceGreater(); - case 96: - return reduceDot(); - case 97: - return reduceFieldAccess(); - case 98: - return reduceIdAccessor(); - case 99: - return reduceStringAccessor(); - case 100: - return reduceExpAccessor(); - case 101: - return reduceCase(); - case 102: - return reduceStringLiteral(); - case 103: - return reduceSymbol(); - case 104: - return reduceEscapedId(); - case 105: - return reduceLess(); - case 106: - return reduceGreater(); - case 107: - return reduceDot(); - case 108: - return reduceGuardQualifier(); - case 109: - return reduceLetQualifier(); - case 110: - return reduceBindQualifier(); - case 111: - return reduceThenQualifier(); - case 112: - return reduceField(); - case 113: - return reduceFieldShorthand(); - case 114: - return reduceCHRQuery(); - case 115: - return reduceVerboseCHRQuery(); - case 116: - return reduceSimpleCaseRhs(); - case 117: - return reduceGuardedCaseRhs(); - case 118: - return reduceGuardedExpArrow(); - case 119: - return reduceGuardEquation(); - case 120: - return reduceBasicEquation(); - case 121: - return reduceEffect(); - case 122: - return reduceJustEtype(); - case 123: - return reduceForAll(); - case 124: - return reduceApplyType(); - case 125: - return reduceDummy1(); - - default: - throw new RuntimeException("Internal parser error."); - } - } catch(SCLSyntaxErrorException e) { - StringBuilder b = new StringBuilder(); - b.append("Failed to reduce"); - for(int i=0;i>5] >> (id&31))&1) != 0 ) + return ERROR_ACTION; + return ACTION_TABLE[ACTION_ROW_ID[state] + ACTION_COLUMN_ID[symbol]]; + } + + private static short getGoto(int state, int symbol) { + return GOTO_TABLE[GOTO_ROW_ID[state] + GOTO_COLUMN_ID[symbol]]; + } + + protected abstract Token nextToken(); + + private Object[] symbolStack = new Object[INITIAL_CAPACITY]; + private int symbolStackLength = 0; + + private int[] stateStack = new int[INITIAL_CAPACITY]; + private int[] symbolStackPositionStack = new int[INITIAL_CAPACITY]; + private int stateStackLength = 0; + + // For reduce + private int reductionLength; + + protected int length() { + return reductionLength; + } + + protected Object get(int i) { + if(i < 0 || i >= reductionLength) + throw new IndexOutOfBoundsException(); + return symbolStack[symbolStackLength+i]; + } + + private String parseErrorDescription(int state, Token token, int tokenId) { + StringBuilder b = new StringBuilder(); + b.append("Unexpected token '").append(token) + .append("' (").append(TERMINAL_NAMES[tokenId]) + .append("). Expected one of "); + ArrayList possibleTerminals = new ArrayList(); + for(int i=0;i 0) + b.append(", "); + b.append(possibleTerminals.get(i)); + } + b.append('.'); + return b.toString(); + } + + protected abstract RuntimeException syntaxError(Token token, String description); + + private static String describeAction(boolean isGoto, int action) { + if(action == ERROR_ACTION) + return "ERROR"; + if(action == ACCEPT_ACTION) + return "ACCEPT"; + StringBuilder b = new StringBuilder(); + if(isGoto) + b.append("GOTO "); + else { + if((action & REDUCE_MASK) != 0) { + action ^= REDUCE_MASK; + b.append("REDUCE"); + } + else + b.append("SHIFT"); + } + if((action & POP_MASK) != 0) { + action ^= POP_MASK; + b.append(" POP"); + } + if((action & PUSH_MASK) != 0) { + action ^= PUSH_MASK; + b.append(" PUSH"); + } + b.append(' ').append(action); + return b.toString(); + } + + private void printState(int state) { + System.out.print("state=" + state + ":"); + for(int i=symbolStackLength-1,j=stateStackLength-1;i>=0;--i) { + Object s = symbolStack[i]; + if(s instanceof Token) + System.out.print(" " + TERMINAL_NAMES[((Token)s).id]); + else if(s == null) + System.out.print(" null"); + else + System.out.print(" " + s.getClass().getSimpleName()); + while(j>=0 && symbolStackPositionStack[j]==i) + System.out.print(" (" + stateStack[j--] + ")"); + } + System.out.println(); + } + + private Object parse(int state) { + while(true) { + Token token = nextToken(); + int tokenId = token.id; + if(TRACE) + System.out.println("---> token " + TERMINAL_NAMES[tokenId] + " \"" + token.text + "\" <---"); + while(true) { + if(TRACE) + printState(state); + short action = getAction(state, tokenId); + if(TRACE) + System.out.println(" -> action=" + describeAction(false, action)); + //System.out.println(STATE_DESCRIPTIONS[state]); + if((action & REDUCE_MASK) != 0) { + if(action == ACCEPT_ACTION) + return symbolStack[symbolStackLength-1]; + if(action == ERROR_ACTION) + throw syntaxError(token, parseErrorDescription(state, token, tokenId)); + int popAmount = (action >>> 13)&3; + if(TRACE) { + if(popAmount > 0) + System.out.println(" POP " + popAmount); + } + stateStackLength -= popAmount; + action &= STATE_MASK; + + int reductionBegin = symbolStackPositionStack[--stateStackLength]; + + reductionLength = symbolStackLength-reductionBegin; + symbolStackLength = reductionBegin; + + if(symbolStackLength == symbolStack.length) + symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2); + Object symbol = reduce(action); + postReduce(symbol); + symbolStack[symbolStackLength] = symbol; + + state = stateStack[stateStackLength]; + if(TRACE) { + ++symbolStackLength; + printState(state); + --symbolStackLength; + System.out.println(" nonterminal=" + NONTERMINAL_NAMES[PRODUCT_LHS[action]]); + } + action = getGoto(state, PRODUCT_LHS[action]); + if(TRACE) + System.out.println(" -> action=" + describeAction(true, action)); + + // Pop state + if((action & POP_MASK) != 0) { + --stateStackLength; + } + // Push state + if((action & PUSH_MASK) != 0) { + if(stateStackLength == stateStack.length) { + stateStack = Arrays.copyOf(stateStack, stateStackLength*2); + symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2); + } + symbolStackPositionStack[stateStackLength] = symbolStackLength; + stateStack[stateStackLength++] = state; + } + state = action & STATE_MASK; + ++symbolStackLength; + } + else { + // Pop state + if((action & POP_MASK) != 0) { + --stateStackLength; + } + // Push state + if((action & PUSH_MASK) != 0) { + if(stateStackLength == stateStack.length) { + stateStack = Arrays.copyOf(stateStack, stateStackLength*2); + symbolStackPositionStack = Arrays.copyOf(symbolStackPositionStack, stateStackLength*2); + } + symbolStackPositionStack[stateStackLength] = symbolStackLength; + stateStack[stateStackLength++] = state; + } + + // New state + state = action & STATE_MASK; + + // Push symbol + if(symbolStackLength == symbolStack.length) + symbolStack = Arrays.copyOf(symbolStack, symbolStackLength*2); + symbolStack[symbolStackLength++] = token; + break; + } + } + } + } + + public Object parseModule() { + return parse(0); + } + public Object parseCommands() { + return parse(347); + } + public Object parseImport() { + return parse(355); + } + public Object parseType() { + return parse(357); + } + public Object parseExp() { + return parse(359); + } + public Object parseEquationBlock() { + return parse(361); + } + + + protected Object reduce(int productionId) { + try { + switch(productionId) { + case 0: + return reduceModule(); + case 1: + return reduceOneCommand(); + case 2: + return reduceManyCommands(); + case 3: + return reduceImport(); + case 4: + return reduceArrow(); + case 5: + return reduceLocalTypeAnnotation(); + case 6: + return reduceEquationBlock(); + case 7: + return reduceModuleHeader(); + case 8: + return reduceTypeAnnotation(); + case 9: + return reduceValueDefinition(); + case 10: + return reduceDataDefinition(); + case 11: + return reduceTypeDefinition(); + case 12: + return reduceClassDefinition(); + case 13: + return reduceInstanceDefinition(); + case 14: + return reduceDerivingInstanceDefinition(); + case 15: + return reduceDocumentationString(); + case 16: + return reduceAnnotation(); + case 17: + return reducePrecedenceDefinition(); + case 18: + return reduceJustImport(); + case 19: + return reduceImportJava(); + case 20: + return reduceEffectDefinition(); + case 21: + return reduceRuleDefinition(); + case 22: + return reduceMappingRelationDefinition(); + case 23: + return reduceRelationDefinition(); + case 24: + return reduceRulesetDefinition(); + case 25: + return reduceStatementCommand(); + case 26: + return reduceImportCommand(); + case 27: + return reduceGuardStatement(); + case 28: + return reduceLetStatement(); + case 29: + return reduceBindStatement(); + case 30: + return reduceRuleStatement(); + case 31: + return reduceCHRStatement(); + case 32: + return reduceVerboseCHRStatement(); + case 33: + return reduceConstraintStatement(); + case 34: + return reduceLocalInclude(); + case 35: + return reduceDeclarations(); + case 36: + return reduceField(); + case 37: + return reduceFieldShorthand(); + case 38: + return reduceWildcard(); + case 39: + return reduceVarId(); + case 40: + return reduceEscapedSymbol(); + case 41: + return reduceTupleConstructor(); + case 42: + return reduceBinary(); + case 43: + return reduceSimpleRhs(); + case 44: + return reduceGuardedRhs(); + case 45: + return reduceConstructor(); + case 46: + return reduceRecordConstructor(); + case 47: + return reduceContext(); + case 48: + return reduceFundeps(); + case 49: + return reduceTypeVar(); + case 50: + return reduceTupleType(); + case 51: + return reduceListType(); + case 52: + return reduceListTypeConstructor(); + case 53: + return reduceTupleTypeConstructor(); + case 54: + return reduceLambda(); + case 55: + return reduceLambdaMatch(); + case 56: + return reduceLet(); + case 57: + return reduceIf(); + case 58: + return reduceMatch(); + case 59: + return reduceDo(); + case 60: + return reduceSelect(); + case 61: + return reduceCHRSelect(); + case 62: + return reduceEnforce(); + case 63: + return reduceVar(); + case 64: + return reduceHashedId(); + case 65: + return reduceBlank(); + case 66: + return reduceInteger(); + case 67: + return reduceFloat(); + case 68: + return reduceString(); + case 69: + return reduceChar(); + case 70: + return reduceTuple(); + case 71: + return reduceViewPattern(); + case 72: + return reduceRightSection(); + case 73: + return reduceLeftSection(); + case 74: + return reduceListLiteral(); + case 75: + return reduceRange(); + case 76: + return reduceListComprehension(); + case 77: + return reduceAs(); + case 78: + return reduceRecord(); + case 79: + return reduceTransformation(); + case 80: + return reduceEq(); + case 81: + return reduceRuleDeclarations(); + case 82: + return reduceStatements(); + case 83: + return reduceImportShowing(); + case 84: + return reduceImportHiding(); + case 85: + return reduceImportValueItem(); + case 86: + return reduceFieldDescription(); + case 87: + return reduceGuardedExpEq(); + case 88: + return reduceFundep(); + case 89: + return reduceQueryRuleDeclaration(); + case 90: + return reduceAnnotation(); + case 91: + return reduceGuardQuery(); + case 92: + return reduceEqualsQuery(); + case 93: + return reduceBindQuery(); + case 94: + return reduceCompositeQuery(); + case 95: + return reduceApply(); + case 96: + return reduceSymbol(); + case 97: + return reduceEscapedId(); + case 98: + return reduceMinus(); + case 99: + return reduceLess(); + case 100: + return reduceGreater(); + case 101: + return reduceDot(); + case 102: + return reduceFieldAccess(); + case 103: + return reduceIdAccessor(); + case 104: + return reduceStringAccessor(); + case 105: + return reduceExpAccessor(); + case 106: + return reduceCase(); + case 107: + return reduceQueryBlock(); + case 108: + return reduceVerboseCHRConjunction(); + case 109: + return reduceStringLiteral(); + case 110: + return reduceSymbol(); + case 111: + return reduceEscapedId(); + case 112: + return reduceLess(); + case 113: + return reduceGreater(); + case 114: + return reduceDot(); + case 115: + return reduceGuardQualifier(); + case 116: + return reduceLetQualifier(); + case 117: + return reduceBindQualifier(); + case 118: + return reduceThenQualifier(); + case 119: + return reduceCHRConjunction(); + case 120: + return reduceCHRAtom(); + case 121: + return reduceCHREquals(); + case 122: + return reduceCHRBinds(); + case 123: + return reduceSimpleCaseRhs(); + case 124: + return reduceGuardedCaseRhs(); + case 125: + return reduceGuardedExpArrow(); + case 126: + return reduceGuardEquation(); + case 127: + return reduceBasicEquation(); + case 128: + return reduceEffect(); + case 129: + return reduceJustEtype(); + case 130: + return reduceForAll(); + case 131: + return reduceApplyType(); + case 132: + return reduceDummy(); + + default: + throw new RuntimeException("Internal parser error."); + } + } catch(SCLSyntaxErrorException e) { + StringBuilder b = new StringBuilder(); + b.append("Failed to reduce"); + for(int i=0;i