java: public boolean isExpectedToken(int symbol) {ATN atn = getInterpreter().atn;ParserRuleContext ctx = _ctx;ATNState s = atn.states.get(getState());IntervalSet following = atn.nextTokens(s);if (following.contains(symbol)) {return true;}if ( !following.contains(Token.EPSILON) ) return false;while ( ctx!=null && ctx.invokingState>=0 && following.contains(Token.EPSILON) ) {ATNState invokingState = atn.states.get(ctx.invokingState);RuleTransition rt = (RuleTransition)invokingState.transition(0);following = atn.nextTokens(rt.followState);if (following.contains(symbol)) {return true;}ctx = (ParserRuleContext)ctx.parent;}if ( following.contains(Token.EPSILON) && symbol == Token.EOF ) {return true;}return false;}
C#: public virtual bool IsExpectedToken(int symbol){ATN atn = Interpreter.atn;ParserRuleContext ctx = _ctx;ATNState s = atn.states[State];IntervalSet following = atn.NextTokens(s);if (following.Contains(symbol)){return true;}if (!following.Contains(TokenConstants.EPSILON)){return false;}while (ctx != null && ctx.invokingState >= 0 && following.Contains(TokenConstants.EPSILON)){ATNState invokingState = atn.states[ctx.invokingState];RuleTransition rt = (RuleTransition)invokingState.Transition(0);following = atn.NextTokens(rt.followState);if (following.Contains(symbol)){return true;}ctx = (ParserRuleContext)ctx.Parent;}if (following.Contains(TokenConstants.EPSILON) && symbol == TokenConstants.EOF){return true;}return false;}