/** * Compute set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. * * <p>If {@code ctx} is {@code null} and the end of the rule containing * {@code s} is reached, {@link Token#EPSILON} is added to the result set. * If {@code ctx} is not {@code null} and the end of the outermost rule is * reached, {@link Token#EOF} is added to the result set.</p> * * @param s the ATN state * @param ctx the complete parser context, or {@code null} if the context * should be ignored * * @return The set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. */ public IntervalSet LOOK(ATNState s, RuleContext ctx) { return LOOK(s, null, ctx); }
/** Compute the set of valid tokens that can occur starting in state {@code s}. * If {@code ctx} is null, the set of tokens will not include what can follow * the rule surrounding {@code s}. In other words, the set will be * restricted to tokens reachable staying within {@code s}'s rule. */ public IntervalSet nextTokens(ATNState s, RuleContext ctx) { LL1Analyzer anal = new LL1Analyzer(this); IntervalSet next = anal.LOOK(s, ctx); return next; }
/** * Compute set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. * * <p>If {@code ctx} is {@code null} and the end of the rule containing * {@code s} is reached, {@link Token#EPSILON} is added to the result set. * If {@code ctx} is not {@code null} and the end of the outermost rule is * reached, {@link Token#EOF} is added to the result set.</p> * * @param s the ATN state * @param ctx the complete parser context, or {@code null} if the context * should be ignored * * @return The set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. */ public IntervalSet LOOK(ATNState s, RuleContext ctx) { return LOOK(s, null, ctx); }
/** * Compute set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. * * <p>If {@code ctx} is {@code null} and the end of the rule containing * {@code s} is reached, {@link Token#EPSILON} is added to the result set. * If {@code ctx} is not {@code null} and the end of the outermost rule is * reached, {@link Token#EOF} is added to the result set.</p> * * @param s the ATN state * @param ctx the complete parser context, or {@code null} if the context * should be ignored * * @return The set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. */ public IntervalSet LOOK(ATNState s, RuleContext ctx) { return LOOK(s, null, ctx); }
/** * Compute set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. * * <p>If {@code ctx} is {@code null} and the end of the rule containing * {@code s} is reached, {@link Token#EPSILON} is added to the result set. * If {@code ctx} is not {@code null} and the end of the outermost rule is * reached, {@link Token#EOF} is added to the result set.</p> * * @param s the ATN state * @param ctx the complete parser context, or {@code null} if the context * should be ignored * * @return The set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. */ public IntervalSet LOOK(ATNState s, RuleContext ctx) { return LOOK(s, null, ctx); }
/** Compute the set of valid tokens that can occur starting in state {@code s}. * If {@code ctx} is null, the set of tokens will not include what can follow * the rule surrounding {@code s}. In other words, the set will be * restricted to tokens reachable staying within {@code s}'s rule. */ public IntervalSet nextTokens(ATNState s, RuleContext ctx) { LL1Analyzer anal = new LL1Analyzer(this); IntervalSet next = anal.LOOK(s, ctx); return next; }
/** Compute the set of valid tokens that can occur starting in state {@code s}. * If {@code ctx} is null, the set of tokens will not include what can follow * the rule surrounding {@code s}. In other words, the set will be * restricted to tokens reachable staying within {@code s}'s rule. */ public IntervalSet nextTokens(ATNState s, RuleContext ctx) { LL1Analyzer anal = new LL1Analyzer(this); IntervalSet next = anal.LOOK(s, ctx); return next; }
/** Compute the set of valid tokens that can occur starting in state {@code s}. * If {@code ctx} is null, the set of tokens will not include what can follow * the rule surrounding {@code s}. In other words, the set will be * restricted to tokens reachable staying within {@code s}'s rule. */ public IntervalSet nextTokens(ATNState s, RuleContext ctx) { LL1Analyzer anal = new LL1Analyzer(this); IntervalSet next = anal.LOOK(s, ctx); return next; }
/** Compute the set of valid tokens that can occur starting in state {@code s}. * If {@code ctx} is {@link PredictionContext#EMPTY_LOCAL}, the set of tokens will not include what can follow * the rule surrounding {@code s}. In other words, the set will be * restricted to tokens reachable staying within {@code s}'s rule. */ @NotNull public IntervalSet nextTokens(ATNState s, @NotNull PredictionContext ctx) { Args.notNull("ctx", ctx); LL1Analyzer anal = new LL1Analyzer(this); IntervalSet next = anal.LOOK(s, ctx); return next; }
/** * Compute set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. * * <p>If {@code ctx} is {@code null} and the end of the rule containing * {@code s} is reached, {@link Token#EPSILON} is added to the result set. * If {@code ctx} is not {@code null} and the end of the outermost rule is * reached, {@link Token#EOF} is added to the result set.</p> * * @param s the ATN state * @param ctx the complete parser context, or {@code null} if the context * should be ignored * * @return The set of tokens that can follow {@code s} in the ATN in the * specified {@code ctx}. */ @NotNull public IntervalSet LOOK(@NotNull ATNState s, @NotNull PredictionContext ctx) { return LOOK(s, s.atn.ruleToStopState[s.ruleIndex], ctx); }
protected void processLexer() { // make sure all non-fragment lexer rules must match at least one symbol for (Rule rule : g.rules.values()) { if (rule.isFragment()) { continue; } LL1Analyzer analyzer = new LL1Analyzer(g.atn); IntervalSet look = analyzer.LOOK(g.atn.ruleToStartState[rule.index], null); if (look.contains(Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_TOKEN, g.fileName, ((GrammarAST)rule.ast.getChild(0)).getToken(), rule.name); } } }
protected void processLexer() { // make sure all non-fragment lexer rules must match at least one symbol for (Rule rule : g.rules.values()) { if (rule.isFragment()) { continue; } LL1Analyzer analyzer = new LL1Analyzer(g.atn); IntervalSet look = analyzer.LOOK(g.atn.ruleToStartState[rule.index], null); if (look.contains(Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_TOKEN, g.fileName, ((GrammarAST)rule.ast.getChild(0)).getToken(), rule.name); } } }
protected void processLexer() { // make sure all non-fragment lexer rules must match at least one symbol for (Rule rule : g.rules.values()) { if (rule.isFragment()) { continue; } LL1Analyzer analyzer = new LL1Analyzer(g.atn); IntervalSet look = analyzer.LOOK(g.atn.ruleToStartState[rule.index], null); if (look.contains(Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_TOKEN, g.fileName, ((GrammarAST)rule.ast.getChild(0)).getToken(), rule.name); } } }
protected void processLexer() { // make sure all non-fragment lexer rules must match at least one symbol for (Rule rule : g.rules.values()) { if (rule.isFragment()) { continue; } LL1Analyzer analyzer = new LL1Analyzer(g.atn); IntervalSet look = analyzer.LOOK(g.atn.ruleToStartState[rule.index], PredictionContext.EMPTY_LOCAL); if (look.contains(Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_TOKEN, g.fileName, ((GrammarAST)rule.ast.getChild(0)).getToken(), rule.name); } } }
protected void processLexer() { // make sure all non-fragment lexer rules must match at least one symbol for (Rule rule : g.rules.values()) { if (rule.isFragment()) { continue; } LL1Analyzer analyzer = new LL1Analyzer(g.atn); IntervalSet look = analyzer.LOOK(g.atn.ruleToStartState[rule.index], null); if (look.contains(Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_TOKEN, g.fileName, ((GrammarAST)rule.ast.getChild(0)).getToken(), rule.name); } } }
if (analyzer.LOOK(pair.b, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) { ErrorType errorType = pair.a instanceof LeftRecursiveRule ? ErrorType.EPSILON_LR_FOLLOW : ErrorType.EPSILON_CLOSURE; g.tool.errMgr.grammarError(errorType, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name); if (analyzer.LOOK(startState, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_OPTIONAL, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name); continue optionalCheck;
ATNState blkStart = pair.b; ATNState blkStop = pair.c; IntervalSet lookahead = analyzer.LOOK(blkStart, blkStop, null); if ( lookahead.contains(org.antlr.v4.runtime.Token.EPSILON)) { ErrorType errorType = pair.a instanceof LeftRecursiveRule ? ErrorType.EPSILON_LR_FOLLOW : ErrorType.EPSILON_CLOSURE; if (analyzer.LOOK(startState, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_OPTIONAL, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name); continue optionalCheck;
if (analyzer.LOOK(pair.b, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) { ErrorType errorType = pair.a instanceof LeftRecursiveRule ? ErrorType.EPSILON_LR_FOLLOW : ErrorType.EPSILON_CLOSURE; g.tool.errMgr.grammarError(errorType, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name); if (analyzer.LOOK(startState, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_OPTIONAL, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name); continue optionalCheck;
ATNState blkStart = pair.b; ATNState blkStop = pair.c; IntervalSet lookahead = analyzer.LOOK(blkStart, blkStop, null); if ( lookahead.contains(org.antlr.v4.runtime.Token.EPSILON)) { ErrorType errorType = pair.a instanceof LeftRecursiveRule ? ErrorType.EPSILON_LR_FOLLOW : ErrorType.EPSILON_CLOSURE; if (analyzer.LOOK(startState, pair.c, null).contains(org.antlr.v4.runtime.Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_OPTIONAL, g.fileName, ((GrammarAST)pair.a.ast.getChild(0)).getToken(), pair.a.name); continue optionalCheck;
ATNState blkStart = pair.getItem2(); ATNState blkStop = pair.getItem3(); IntervalSet lookahead = analyzer.LOOK(blkStart, blkStop, PredictionContext.EMPTY_LOCAL); if (lookahead.contains(org.antlr.v4.runtime.Token.EPSILON)) { ErrorType errorType = pair.getItem1() instanceof LeftRecursiveRule ? ErrorType.EPSILON_LR_FOLLOW : ErrorType.EPSILON_CLOSURE; if (analyzer.LOOK(startState, pair.getItem3(), PredictionContext.EMPTY_LOCAL).contains(org.antlr.v4.runtime.Token.EPSILON)) { g.tool.errMgr.grammarError(ErrorType.EPSILON_OPTIONAL, g.fileName, ((GrammarAST)pair.getItem1().ast.getChild(0)).getToken(), pair.getItem1().name); continue optionalCheck;