Example usage for org.antlr.v4.runtime CommonToken getInputStream

List of usage examples for org.antlr.v4.runtime CommonToken getInputStream

Introduction

In this page you can find the example usage for org.antlr.v4.runtime CommonToken getInputStream.

Prototype

@Override
    public CharStream getInputStream() 

Source Link

Usage

From source file:com.jmcalc.utils.DescriptiveErrorListener.java

License:Apache License

@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine,
        String msg, RecognitionException e) {
    CommonToken offendingToken = ((CommonToken) offendingSymbol);
    String sourceName = offendingToken.getInputStream()
            .getText(new Interval(0, offendingToken.getInputStream().size()));
    if (e != null) {
        throw new ExpressionParseException(sourceName + " -> line " + line + ":" + charPositionInLine
                + " mismatched input '" + e.getOffendingToken().getText() + "'");
    } else {//  ww  w .  j  a va 2s  .c om
        throw new ExpressionParseException(sourceName + " -> line " + line + ":" + charPositionInLine
                + " unexpected token: " + offendingToken.getText());
    }
}