Example usage for org.antlr.v4.runtime.misc IntervalSet remove

List of usage examples for org.antlr.v4.runtime.misc IntervalSet remove

Introduction

In this page you can find the example usage for org.antlr.v4.runtime.misc IntervalSet remove.

Prototype

@Override
    public void remove(int el) 

Source Link

Usage

From source file:com.sample.JavaErrorStrategy.java

License:BSD License

@NotNull
protected IntervalSet getErrorRecoverySet(@NotNull Parser recognizer) {
    ATN atn = recognizer.getInterpreter().atn;
    RuleContext ctx = recognizer.getContext();
    IntervalSet recoverSet = new IntervalSet();
    while (ctx != null && ctx.invokingState >= 0) {
        // compute what follows who invoked us
        ATNState invokingState = atn.states.get(ctx.invokingState);
        RuleTransition rt = (RuleTransition) invokingState.transition(0);
        IntervalSet follow = atn.nextTokens(rt.followState);
        recoverSet.addAll(follow);/*from   w ww  .jav  a  2  s . c  o  m*/
        ctx = ctx.parent;
    }
    recoverSet.remove(Token.EPSILON);
    // System.out.println("recover set "+recoverSet.toString(recognizer.getTokenNames()));
    return recoverSet;
}