/** Consume tokens until one matches the given token set */ @Override public void consumeUntil(IntStream i, BitSet set) { // System.out.println("consumeUntil(" + set.toString(getTokenNames()) + ")"); Token ttype; List<Token> skipped = new ArrayList<>(); beginResync(); try { while ((ttype = input.LT(1)) != null && ttype.getType() != Token.EOF && !set.member(ttype.getType())) { // System.out.println("consume during recover LA(1)=" + getTokenNames()[input.LA(1)]); input.consume(); skipped.add(ttype); } } finally { endResync(); } ((NbParseTreeBuilder) dbg).consumeSkippedTokens(skipped); }
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { TokenStream input = (TokenStream)_input; int _s = s; switch ( s ) { case 0 : int LA14_3 = input.LA(1); int index14_3 = input.index(); input.rewind(); s = -1; if ( (synpred9_InternalJavaJRExpression()) ) {s = 19;} else if ( (true) ) {s = 4;} input.seek(index14_3); if ( s>=0 ) return s; break; } if (state.backtracking>0) {state.failed=true; return -1;} NoViableAltException nvae = new NoViableAltException(getDescription(), 14, _s, input); error(nvae); throw nvae; }
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { TokenStream input = (TokenStream)_input; int _s = s; switch ( s ) { case 0 : int LA36_1 = input.LA(1); int index36_1 = input.index(); input.rewind(); s = -1; if ( (synpred12_InternalJavaJRExpression()) ) {s = 22;} else if ( (true) ) {s = 2;} input.seek(index36_1); if ( s>=0 ) return s; break; } if (state.backtracking>0) {state.failed=true; return -1;} NoViableAltException nvae = new NoViableAltException(getDescription(), 36, _s, input); error(nvae); throw nvae; }
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { TokenStream input = (TokenStream)_input; int _s = s; switch ( s ) { case 0 : int LA6_3 = input.LA(1); int index6_3 = input.index(); input.rewind(); s = -1; if ( (synpred10_InternalJavaJRExpression()) ) {s = 19;} else if ( (true) ) {s = 4;} input.seek(index6_3); if ( s>=0 ) return s; break; } if (state.backtracking>0) {state.failed=true; return -1;} NoViableAltException nvae = new NoViableAltException(getDescription(), 6, _s, input); error(nvae); throw nvae; }
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { TokenStream input = (TokenStream)_input; int _s = s; switch ( s ) { case 0 : int LA39_1 = input.LA(1); int index39_1 = input.index(); input.rewind(); s = -1; if ( (synpred63_InternalJavaJRExpression()) ) {s = 22;} else if ( (true) ) {s = 2;} input.seek(index39_1); if ( s>=0 ) return s; break; } if (state.backtracking>0) {state.failed=true; return -1;} NoViableAltException nvae = new NoViableAltException(getDescription(), 39, _s, input); error(nvae); throw nvae; }
public ParamsCountException(IntStream input, EditorOpDescr currentOp, String errorMsg, Boolean needsPop, Qualifier qualifier, String parsedTxt, int...position) { super(input); this.currentOp = currentOp; this.errorMsg = errorMsg; this.parsedTxt = parsedTxt; this.c = (parsedTxt !=null && !parsedTxt.isEmpty())? (int) parsedTxt.charAt(0):Token.EOF; if (position != null && position.length == 2) { this.line = position[0]; this.charPositionInLine = position[1]; } this.needsPop = needsPop; this.qualifier = qualifier; }
SemanticException(IntStream input, CommonTree tree, String errorMessage, Object... messageArguments) { super(); this.input = input; this.token = tree.getToken(); this.index = tree.getTokenStartIndex(); this.line = token.getLine(); this.charPositionInLine = token.getCharPositionInLine(); this.errorMessage = String.format(errorMessage, messageArguments); }
SemanticException(IntStream input, Token token, String errorMessage, Object... messageArguments) { super(); this.input = input; this.token = token; this.index = ((CommonToken)token).getStartIndex(); this.line = token.getLine(); this.charPositionInLine = token.getCharPositionInLine(); this.errorMessage = String.format(errorMessage, messageArguments); }
public static String displayError(IntStream stream, int line, int position, int length) { String[] lines = null; StringBuilder sb = new StringBuilder(); if (stream instanceof CharStream) { lines = ((CharStream) stream).substring(0, stream.size() - 1).split("\n"); } else if (stream instanceof TokenStream) { lines = ((TokenStream) stream).toString(0, stream.size() - 1).split("\n"); } sb.append(" at line ").append(line).append("\n"); if (lines != null) { int start = Math.max(0, line - 5); int end = Math.min(lines.length, line + 5); int badline = line - 1; for (int i = start; i < end; i++) { sb.append(String.format("%5d: %s\n", i + 1, lines[i])); if (i == badline) { for (int j = 0; j < position + 7; j++) sb.append("-"); for (int j = 0; j <= length; j++) sb.append("^"); sb.append("\n"); } } } return sb.toString(); }
public static String getParserExceptionDetails(RecognitionException e) { StringBuilder sb = new StringBuilder(); if ((duplicate == null) || !duplicate.equals(e)) { IntStream stream; int line, position, length; CommonToken token = (CommonToken) e.token; String message = e.getMessage(); if (message != null) { sb.append(message); } else { sb.append("Exception of type ").append(e.getClass().getCanonicalName()); } if (token == null) { stream = e.input; line = e.line; position = e.charPositionInLine; length = 1; } else { sb.append(" at token ").append(token.getText()); stream = token.getInputStream(); line = token.getLine(); position = token.getCharPositionInLine(); length = token.getStopIndex() - token.getStartIndex(); } String error = displayError(stream, line, position, length); sb.append(error); Throwable cause = e.getCause(); if (cause != null) { sb.append("Caused by ").append(cause.getMessage()).append("\n"); } } duplicate = e; return sb.toString(); }
@Override public void recover(IntStream stream, RecognitionException ex) { if (recoveryListener != null) recoveryListener.beginErrorRecovery(); removeUnexpectedElements(); if (ex instanceof FailedPredicateException && ex.token.getType() == Token.EOF) { failedPredicateAtEOF = true; } super.recover(stream, ex); if (recoveryListener != null) recoveryListener.endErrorRecovery(); }
@Override protected Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow) throws RecognitionException { try { mismatch = true; return super.recoverFromMismatchedToken(input, ttype, follow); } finally { mismatch = false; } }
@Override public boolean mismatchIsUnwantedToken(IntStream input, int ttype) { try { inMismatchIsUnwantedToken = true; boolean result = super.mismatchIsUnwantedToken(input, ttype); return result; } finally { inMismatchIsUnwantedToken = false; } }
@Override public int predict(IntStream input) throws RecognitionException { try { getRecognizer().beginDFAPrediction(); return super.predict(input); } finally { getRecognizer().endDFAPrediction(); } }
SemanticException(IntStream input, Token token, String errorMessage, Object... messageArguments) { super(); this.input = input; this.token = token; this.index = ((CommonToken) token).getStartIndex(); this.line = token.getLine(); this.charPositionInLine = token.getCharPositionInLine(); this.errorMessage = String.format(errorMessage, messageArguments); }
public int specialStateTransition(int s, IntStream _input) throws NoViableAltException { TokenStream input = (TokenStream)_input; int _s = s; switch ( s ) { case 0 : int LA57_0 = input.LA(1); int index57_0 = input.index(); input.rewind(); s = -1; if ( (LA57_0==EOF||LA57_0==BOOLEAN_LITERAL||LA57_0==STRING_LITERAL||LA57_0==NULL||LA57_0==CONTAIN||LA57_0==THAN||(LA57_0>=OR && LA57_0<=AND)||(LA57_0>=VAR && LA57_0<=FOR)||(LA57_0>=TRY && LA57_0<=SCRIPTCLOSE)||(LA57_0>=PLUS && LA57_0<=MINUSMINUS)||LA57_0==NOTOP||(LA57_0>=SEMICOLON && LA57_0<=LEFTBRACKET)||(LA57_0>=LEFTPAREN && LA57_0<=IDENTIFIER)||LA57_0==INTEGER_LITERAL||(LA57_0>=FLOATING_POINT_LITERAL && LA57_0<=138)||LA57_0==144) ) {s = 1;} else if ( (LA57_0==DOES) ) {s = 2;} else if ( (LA57_0==GREATER) ) {s = 3;} else if ( (LA57_0==LESS) ) {s = 4;} else if ( (LA57_0==NOT) ) {s = 5;} else if ( (LA57_0==IN) && ((!scriptMode))) {s = 6;} else if ( ((LA57_0>=EQUALSOP && LA57_0<=COLON)||LA57_0==QUESTIONMARK||LA57_0==RIGHTBRACKET) ) {s = 7;} else if ( (LA57_0==LT) ) {s = 8;} else if ( (LA57_0==CONTAINS||(LA57_0>=IS && LA57_0<=LTE)||(LA57_0>=LE && LA57_0<=NEQ)||LA57_0==EQUALSEQUALSOP||(LA57_0>=139 && LA57_0<=143)) ) {s = 9;} input.seek(index57_0); if ( s>=0 ) return s; break; } if (state.backtracking>0) {state.failed=true; return -1;} NoViableAltException nvae = new NoViableAltException(getDescription(), 57, _s, input); error(nvae); throw nvae; }
/** * Constructor that takes an additional string to be concatenated * with the exception message */ public InvalidScalarProjectionException(IntStream input, SourceLocation loc, ScalarExpression expr, String msg) { super( input, loc ); this.scalarExpr = expr; this.msg = new String(msg); }
LogicalPlanBuilder(PigContext pigContext, String scope, Map<String, String> fileNameMap, IntStream input) { this.pigContext = pigContext; this.scope = scope; this.fileNameMap = fileNameMap; this.intStream = input; }
LogicalPlanBuilder(IntStream input) throws ExecException { pigContext = new PigContext( ExecType.LOCAL, new Properties() ); pigContext.connect(); this.scope = "test"; this.fileNameMap = new HashMap<String, String>(); this.intStream = input; }
String buildStreamOp(SourceLocation loc, String alias, String inputAlias, StreamingCommand command, LogicalSchema schema, IntStream input) throws RecognitionException { try { LOStream op = new LOStream( plan, pigContext.createExecutableManager(), command, schema ); return buildOp( loc, op, alias, inputAlias, null ); } catch (ExecException ex) { throw new PlanGenerationFailureException( input, loc, ex ); } }
public UnfinishedNestedCondition(IntStream input, String type, String parsed, Boolean wrongToken, Boolean unfinishToken) { super(input); this.type = type; this.parsed = parsed; this.wrongToken = wrongToken; this.unfinishToken = unfinishToken; }
public MissingOutputSelectorException(IntStream input, EditorOpDescr currentOp, Token unwantedOutputSelector, String... expected) { super(input); this.currentOp = currentOp; this.expected = expected; // this.currentOutput = currentOutputSelector; if (unwantedOutputSelector != null) { this.token = unwantedOutputSelector; } }