public boolean isExpectedToken(int symbol) {
//   		return getInterpreter().atn.nextTokens(_ctx);
        ATN atn = getInterpreter().atn;
		ParserRuleContext ctx = _ctx;
        ATNState s = atn.states.get(getState());
        IntervalSet following = atn.nextTokens(s);
        if (following.contains(symbol)) {
            return true;
        }
//        System.out.println("following "+s+"="+following);
        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;
    }
Checks whether or not {@code symbol} can follow the current state in the
ATN. The behavior of this method is equivalent to the following, but is
implemented such that the complete context-sensitive follow set does not
need to be explicitly constructed.

<pre>
return getExpectedTokens().contains(symbol);
</pre>

@param symbol the symbol type to check
@return {@code true} if {@code symbol} can follow the current state in
the ATN, otherwise {@code false}.
runtime/Java/src/org/antlr/v4/runtime/Parser.java