/** 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 stopState the ATN state to stop at. This can be a * {@link BlockEndState} to detect epsilon paths through a closure. * @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, ATNState stopState, RuleContext ctx) { IntervalSet r = new IntervalSet(); boolean seeThruPreds = true; // ignore preds; get all lookahead PredictionContext lookContext = ctx != null ? PredictionContext.fromRuleContext(s.atn, ctx) : null; _LOOK(s, stopState, lookContext, r, new HashSet<ATNConfig>(), new BitSet(), seeThruPreds, true); return r; }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
/** * 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); }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
/** * 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; }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
Set<ATNConfig> lookBusy = new HashSet<ATNConfig>(); boolean seeThruPreds = false; // fail to get lookahead upon pred _LOOK(s.transition(alt).target, null, PredictionContext.EMPTY, look[alt], lookBusy, new BitSet(), seeThruPreds, false);
/** * 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; }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
ATNState returnState = atn.states.get(ctx.getReturnState(i)); _LOOK(returnState, stopState, ctx.getParent(i), look, lookBusy, calledRuleStack, seeThruPreds, addEOF); _LOOK(t.target, stopState, newContext, look, lookBusy, calledRuleStack, seeThruPreds, addEOF); _LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF); _LOOK(t.target, stopState, ctx, look, lookBusy, calledRuleStack, seeThruPreds, addEOF);
/** * 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; }
protected void processParser() { g.decisionLOOK = new ArrayList<IntervalSet[]>(g.atn.getNumberOfDecisions()+1); for (DecisionState s : g.atn.decisionToState) { g.tool.log("LL1", "\nDECISION "+s.decision+" in rule "+g.getRule(s.ruleIndex).name); IntervalSet[] look; if ( s.nonGreedy ) { // nongreedy decisions can't be LL(1) look = new IntervalSet[s.getNumberOfTransitions()+1]; } else { LL1Analyzer anal = new LL1Analyzer(g.atn); look = anal.getDecisionLookahead(s); g.tool.log("LL1", "look=" + Arrays.toString(look)); } assert s.decision + 1 >= g.decisionLOOK.size(); Utils.setSize(g.decisionLOOK, s.decision+1); g.decisionLOOK.set(s.decision, look); g.tool.log("LL1", "LL(1)? " + disjoint(look)); } }
/** * 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 stopState the ATN state to stop at. This can be a * {@link BlockEndState} to detect epsilon paths through a closure. * @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, ATNState stopState, RuleContext ctx) { IntervalSet r = new IntervalSet(); boolean seeThruPreds = true; // ignore preds; get all lookahead PredictionContext lookContext = ctx != null ? PredictionContext.fromRuleContext(s.atn, ctx) : null; _LOOK(s, stopState, lookContext, r, new HashSet<ATNConfig>(), new BitSet(), seeThruPreds, true); return r; }
/** * 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); }
/** 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 stopState the ATN state to stop at. This can be a * {@link BlockEndState} to detect epsilon paths through a closure. * @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, ATNState stopState, RuleContext ctx) { IntervalSet r = new IntervalSet(); boolean seeThruPreds = true; // ignore preds; get all lookahead PredictionContext lookContext = ctx != null ? PredictionContext.fromRuleContext(s.atn, ctx) : null; _LOOK(s, stopState, lookContext, r, new HashSet<ATNConfig>(), new BitSet(), seeThruPreds, true); return r; }