public IntervalSet getExpectedTokens(int stateNumber, RuleContext context) {if (stateNumber < 0 || stateNumber >= states.size()) {throw new IllegalArgumentException("Invalid state number.");}RuleContext ctx = context;ATNState s = states.get(stateNumber);IntervalSet following = nextTokens(s);if (!following.contains(Token.EPSILON)) {return following;}IntervalSet expected = new IntervalSet();expected.addAll(following);expected.remove(Token.EPSILON);while (ctx != null && ctx.invokingState >= 0 && following.contains(Token.EPSILON)) {ATNState invokingState = states.get(ctx.invokingState);RuleTransition rt = (RuleTransition)invokingState.transition(0);following = nextTokens(rt.followState);expected.addAll(following);expected.remove(Token.EPSILON);ctx = ctx.parent;}if (following.contains(Token.EPSILON)) {expected.add(Token.EOF);}return expected;}

public IntervalSet getExpectedTokens ( int stateNumber , RuleContext context ) { if ( stateNumber < 0 || stateNumber >= states . size ( ) ) { throw new IllegalArgumentException ( "Invalid state number." ) ; } RuleContext ctx = context ; ATNState s = states . get ( stateNumber ) ; IntervalSet following = nextTokens ( s ) ; if ( ! following . contains ( Token . EPSILON ) ) { return following ; } IntervalSet expected = new IntervalSet ( ) ; expected . addAll ( following ) ; expected . remove ( Token . EPSILON ) ; while ( ctx != null && ctx . invokingState >= 0 && following . contains ( Token . EPSILON ) ) { ATNState invokingState = states . get ( ctx . invokingState ) ; RuleTransition rt = ( RuleTransition ) invokingState . transition ( 0 ) ; following = nextTokens ( rt . followState ) ; expected . addAll ( following ) ; expected . remove ( Token . EPSILON ) ; ctx = ctx . parent ; } if ( following . contains ( Token . EPSILON ) ) { expected . add ( Token . EOF ) ; } return expected ; }
public virtual IntervalSet GetExpectedTokens(int stateNumber, RuleContext context){if (stateNumber < 0 || stateNumber >= states.Count){throw new ArgumentException("Invalid state number.");}RuleContext ctx = context;ATNState s = states[stateNumber];IntervalSet following = NextTokens(s);if (!following.Contains(TokenConstants.EPSILON)){return following;}IntervalSet expected = new IntervalSet();expected.AddAll(following);expected.Remove(TokenConstants.EPSILON);while (ctx != null && ctx.invokingState >= 0 && following.Contains(TokenConstants.EPSILON)){ATNState invokingState = states[ctx.invokingState];RuleTransition rt = (RuleTransition)invokingState.Transition(0);following = NextTokens(rt.followState);expected.AddAll(following);expected.Remove(TokenConstants.EPSILON);ctx = ctx.Parent;}if (following.Contains(TokenConstants.EPSILON)){expected.Add(TokenConstants.EOF);}return expected;}
