currentToken = e.getOffendingToken(); context = e.getCtx();
public void reportError(final Parser recognizer, final RecognitionException e) { if (!this.inErrorRecoveryMode(recognizer)) { this.beginErrorCondition(recognizer); if (e instanceof NoViableAltException) { this.reportNoViableAlternative(recognizer, (NoViableAltException) e); } else if (e instanceof InputMismatchException) { this.reportInputMismatch(recognizer, (InputMismatchException) e); } else if (e instanceof FailedPredicateException) { this.reportFailedPredicate(recognizer, (FailedPredicateException) e); } else { System.err.println("unknown recognition error type: " + e.getClass().getName()); recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e); } } }
/** What is the error header, normally line/character position information? */ public String getErrorHeader(RecognitionException e) { int line = e.getOffendingToken().getLine(); int charPositionInLine = e.getOffendingToken().getCharPositionInLine(); return "line "+line+":"+charPositionInLine; }
recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e);
Token tok = e.getOffendingToken(); int expectedTokenType = Token.INVALID_TYPE; if ( !ime.getExpectedTokens().isNil() ) { Token tok = e.getOffendingToken(); Token errToken = getTokenFactory().create(new Pair<TokenSource, CharStream>(tok.getTokenSource(), tok.getTokenSource().getInputStream()),
public void reportError(Parser recognizer, RecognitionException e) { // Antlr has an issue handling LexerNoViableAltException as then offending token can be null // Try: "select a.b('aa\") from A" if (e instanceof LexerNoViableAltException && e.getOffendingToken() == null) { return; } super.reportError(recognizer, e); } }
public void reportError(Parser recognizer, RecognitionException e) { // Antlr has an issue handling LexerNoViableAltException as then offending token can be null // Try: "select a.b('aa\") from A" if (e instanceof LexerNoViableAltException && e.getOffendingToken() == null) { return; } super.reportError(recognizer, e); } }
/** What is the error header, normally line/character position information? */ public String getErrorHeader(RecognitionException e) { int line = e.getOffendingToken().getLine(); int charPositionInLine = e.getOffendingToken().getCharPositionInLine(); return "line "+line+":"+charPositionInLine; }
/** What is the error header, normally line/character position information? */ public String getErrorHeader(RecognitionException e) { int line = e.getOffendingToken().getLine(); int charPositionInLine = e.getOffendingToken().getCharPositionInLine(); return "line "+line+":"+charPositionInLine; }
/** What is the error header, normally line/character position information? */ public String getErrorHeader(RecognitionException e) { int line = e.getOffendingToken().getLine(); int charPositionInLine = e.getOffendingToken().getCharPositionInLine(); return "line "+line+":"+charPositionInLine; }
public LiquidException(RecognitionException e) { super(createMessage(e), e); this.line = e.getOffendingToken().getLine(); this.charPositionInLine = e.getOffendingToken().getCharPositionInLine(); }
@Override public void reportError(RecognitionException re) { if (re.getOffendingToken() != null) { // System.out.println("Token line:" + re.token.getLine()); // System.out.println("Token text:" + re.token.getText()); } // re.printStackTrace(); // System.err.println(re.getMessage()); addMessage(new ParseError(re.getOffendingToken().getLine(), re.getOffendingToken().getCharPositionInLine(), re.getOffendingToken().getCharPositionInLine(), re.getMessage(), re.getMessage())); }
@Override public void reportError(String[] tokenNames, RecognitionException re) { // System.out.println("Token line:" + re.token.getLine()); // System.out.println("Token text:" + re.token.getText()); // System.err.println(tokenNames); // System.err.println(re.getMessage()); addMessage(new ParseError(re.getOffendingToken().getLine(), re.getOffendingToken().getCharPositionInLine(), re.getOffendingToken().getCharPositionInLine(), tokenNames.toString(), re.getMessage())); // re.printStackTrace(); }
@Override public void reportError(Parser recognizer, RecognitionException e) { if (!(e instanceof BatfishRecognitionException)) { recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e); } }
/** What is the error header, normally line/character position information? */ @NotNull public String getErrorHeader(@NotNull RecognitionException e) { int line = e.getOffendingToken().getLine(); int charPositionInLine = e.getOffendingToken().getCharPositionInLine(); return "line "+line+":"+charPositionInLine; }
protected void notifyErrorListeners(@NotNull Parser recognizer, String message, RecognitionException e) { recognizer.notifyErrorListeners(e.getOffendingToken(recognizer), message, e); }
@Override public void reportError(IntStream input, RecognitionException re, org.antlr.runtime.BitSet follow) { // System.out.println("Token line:" + re.token.getLine()); // System.out.println("Token text:" + re.token.getText()); addMessage(new ParseError(re.getOffendingToken().getLine(), re.getOffendingToken().getCharPositionInLine(), re.getOffendingToken().getCharPositionInLine(), re.getMessage(), re.getMessage())); // System.err.println(re.getMessage()); }
@Override public void recover(Parser recognizer, RecognitionException e) { /* CharStream stream = recognizer.getInputStream().getTokenSource().getInputStream(); String input = stream.toString(); String filename = stream.getSourceName(); Source source = new Source(filename, input); */ int line = e.getOffendingToken().getLine(); int column = e.getOffendingToken().getCharPositionInLine(); Position position = new Position(line, column); throw new SyntaxException(e).set(position); }
private static GlobNode parse(ANTLRInputStream input) throws GlobParseException { GlobLexer lexer = new GlobLexer(input); CommonTokenStream tokenStream = new CommonTokenStream(lexer); GlobParser parser = new GlobParser(tokenStream); parser.setErrorHandler(new BailErrorStrategy()); ParseTreeWalker walker = new ParseTreeWalker(); GlobListener listener = new GlobListener(); try { walker.walk(listener, parser.rootGlob()); } catch (ParseCancellationException e) { RecognitionException ex = ((RecognitionException) e.getCause()); throw new GlobParseException("Unable to parse glob: Error at token " + ex.getOffendingToken().getText() + " at position " + ex.getOffendingToken().getLine() + ":" + ex.getOffendingToken().getCharPositionInLine(), ex); } return listener.popNode(); }
@Override public void reportError(Parser recognizer, RecognitionException e) { String msg = AntlrErrorString.exceptionString(recognizer, e); Diagnosis diagnosis = new Diagnosis( compilationUnit.getCompileContext(), Diagnosis.Kind.ERROR, OffsetRangeHelper.getOffsetRange(e.getOffendingToken()), msg, compilationUnit.getSource() ); diagnosisHandler.handleDiagnosis(diagnosis); }