Example usage for org.antlr.v4.runtime NoViableAltException getCtx

List of usage examples for org.antlr.v4.runtime NoViableAltException getCtx

Introduction

In this page you can find the example usage for org.antlr.v4.runtime NoViableAltException getCtx.

Prototype

public RuleContext getCtx() 

Source Link

Document

Gets the RuleContext at the time this exception was thrown.

Usage

From source file:com.github.jknack.handlebars.internal.HbsErrorStrategy.java

License:Apache License

@Override
public void reportNoViableAlternative(final Parser recognizer, final NoViableAltException e) {
    HbsParser parser = (HbsParser) recognizer;
    TokenStream tokens = parser.getTokenStream();
    HbsLexer lexer = (HbsLexer) tokens.getTokenSource();
    String msg = new ErrorStrategyVisitor(lexer.start, lexer.end).visit(e.getCtx());
    if (msg != null) {
        recognizer.notifyErrorListeners(e.getOffendingToken(), msg, e);
    } else {/*from  www.j  av a  2 s.  co  m*/
        super.reportNoViableAlternative(recognizer, e);
    }
}