List of usage examples for org.antlr.v4.runtime.atn ATN nextTokens
public IntervalSet nextTokens(ATNState s)
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);//w ww .java 2 s. c o m ctx = ctx.parent; } recoverSet.remove(Token.EPSILON); // System.out.println("recover set "+recoverSet.toString(recognizer.getTokenNames())); return recoverSet; }