List of usage examples for org.antlr.v4.runtime InputMismatchException getOffendingToken
public Token getOffendingToken()
From source file:org.ballerinalang.composer.service.workspace.rest.datamodel.BallerinaComposerErrorStrategy.java
License:Open Source License
@Override public void reportInputMismatch(Parser parser, InputMismatchException e) { Token missingSymbol = getMissingSymbol(parser); int line = missingSymbol.getLine(); int position = missingSymbol.getCharPositionInLine(); String mismatchedToken = getTokenErrorDisplay(e.getOffendingToken()); String expectedToken = e.getExpectedTokens().toString(parser.getVocabulary()); String msg = getSourceLocation(parser, line, position) + "mismatched input " + mismatchedToken + ". Expecting one of " + expectedToken; // FixMe: This need to be handled by grammar itself if (!EOF.equals(mismatchedToken)) { errorTokens.add(createError(line, position, msg)); }/*w ww .jav a 2 s . c o m*/ }
From source file:org.ballerinalang.composer.service.workspace.suggetions.CapturePossibleTokenStrategy.java
License:Open Source License
@Override public void reportInputMismatch(Parser parser, InputMismatchException e) { fetchPossibleTokens(parser, e.getOffendingToken(), e.getExpectedTokens()); }
From source file:org.ballerinalang.langserver.completions.BallerinaCustomErrorStrategy.java
License:Open Source License
@Override public void reportInputMismatch(Parser parser, InputMismatchException e) { fillContext(parser, e.getOffendingToken()); }
From source file:org.ballerinalang.util.parser.BallerinaParserErrorStrategy.java
License:Open Source License
@Override public void reportInputMismatch(Parser parser, InputMismatchException e) { int line = getMissingSymbol(parser).getLine(); int position = getMissingSymbol(parser).getCharPositionInLine(); String mismatchedToken = getTokenErrorDisplay(e.getOffendingToken()); String expectedToken = e.getExpectedTokens().toString(parser.getVocabulary()); String msg = getSourceLocation(parser, line, position) + "mismatched input " + mismatchedToken + ". Expecting one of " + expectedToken; setContextException(parser);//from www. j av a 2s. c o m throw new ParseCancellationException(msg); }
From source file:org.beetl.core.parser.BeetlAntlrErrorStrategy.java
License:BSD License
protected void reportInputMismatch(@NotNull Parser recognizer, @NotNull InputMismatchException e) { String msg = " " + getTokenErrorDisplay(e.getOffendingToken()) + " " + e.getExpectedTokens().toString(recognizer.getTokenNames()); BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg, e); exception.token = this.getGrammarToken(e.getOffendingToken()); throw exception; }
From source file:org.fiware.kiara.generator.exceptions.ExceptionErrorStrategy.java
License:Open Source License
@Override public void reportInputMismatch(Parser recognizer, InputMismatchException e) throws RecognitionException { String msg = ""; msg += "In file " + recognizer.getSourceName() + " at line " + recognizer.getContext().start.getLine() + ": "; msg += "Mismatched input " + getTokenErrorDisplay(e.getOffendingToken()); msg += " expecting one of " + e.getExpectedTokens().toString(recognizer.getTokenNames()) + "\n"; msg += "Line Number " + recognizer.getContext().start.getLine() + ", Column " + recognizer.getContext().start.getCharPositionInLine() + ";"; RecognitionException ex = new RecognitionException(msg, recognizer, recognizer.getInputStream(), recognizer.getContext());/*www.j a v a 2 s . c o m*/ ex.initCause(e); throw ex; }