List of usage examples for org.antlr.v4.runtime RecognitionException getRecognizer
public Recognizer<?, ?> getRecognizer()
From source file:excecoes.SyntaxError.java
public SyntaxError(String message, RecognitionException e, int line, int charPositionInLine) { super(message, e.getRecognizer(), e.getInputStream(), (ParserRuleContext) e.getCtx()); this.setOffendingToken(e.getOffendingToken()); this.initCause(e); this.setLine(line); this.setCharPositionInLine(charPositionInLine); }
From source file:org.kie.dmn.feel.parser.feel11.FEELParser.java
License:Apache License
private static SyntaxErrorEvent generateInvalidVariableError(Object offendingSymbol, int line, int charPositionInLine, RecognitionException e, CommonToken token) { String chars = token.getText().length() == 1 ? "character" : "sequence of characters"; if (charPositionInLine == 0) { if ("in".equals(token.getText()) || REUSABLE_KEYWORDS.contains(token.getText())) { return new SyntaxErrorEvent(FEELEvent.Severity.ERROR, Msg.createMessage(Msg.INVALID_VARIABLE_NAME_START, "keyword", token.getText()), e, line, charPositionInLine, offendingSymbol); } else {//from w ww . j a va2 s . co m return new SyntaxErrorEvent(FEELEvent.Severity.ERROR, Msg.createMessage(Msg.INVALID_VARIABLE_NAME_START, chars, token.getText()), e, line, charPositionInLine, offendingSymbol); } } else if ("in".equals(token.getText())) { return new SyntaxErrorEvent(FEELEvent.Severity.ERROR, Msg.createMessage(Msg.INVALID_VARIABLE_NAME, "keyword", token.getText()), e, line, charPositionInLine, offendingSymbol); } else if ("}".equals(token.getText()) && e != null && e.getRecognizer() instanceof Parser && ((Parser) e.getRecognizer()).getRuleInvocationStack().contains("key")) { return new SyntaxErrorEvent(FEELEvent.Severity.ERROR, Msg.createMessage(Msg.MISSING_EXPRESSION, e.getCtx().getText()), e, line, charPositionInLine, offendingSymbol); } else { return new SyntaxErrorEvent(FEELEvent.Severity.ERROR, Msg.createMessage(Msg.INVALID_VARIABLE_NAME, chars, token.getText()), e, line, charPositionInLine, offendingSymbol); } }