Package org.antlr.v4.runtime.atn
Class LL1Analyzer
- java.lang.Object
-
- org.antlr.v4.runtime.atn.LL1Analyzer
-
public class LL1Analyzer extends Object
-
-
Constructor Summary
Constructors Constructor Description LL1Analyzer(ATN atn)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_LOOK(ATNState s, ATNState stopState, PredictionContext ctx, IntervalSet look, Set<ATNConfig> lookBusy, BitSet calledRuleStack, boolean seeThruPreds, boolean addEOF)Compute set of tokens that can followsin the ATN in the specifiedctx.IntervalSet[]getDecisionLookahead(ATNState s)Calculates the SLL(1) expected lookahead set for each outgoing transition of anATNState.IntervalSetLOOK(ATNState s, ATNState stopState, RuleContext ctx)Compute set of tokens that can followsin the ATN in the specifiedctx.IntervalSetLOOK(ATNState s, RuleContext ctx)Compute set of tokens that can followsin the ATN in the specifiedctx.
-
-
-
Field Detail
-
HIT_PRED
public static final int HIT_PRED
Special value added to the lookahead sets to indicate that we hit a predicate during analysis ifseeThruPreds==false.- See Also:
- Constant Field Values
-
atn
public final ATN atn
-
-
Constructor Detail
-
LL1Analyzer
public LL1Analyzer(ATN atn)
-
-
Method Detail
-
getDecisionLookahead
public IntervalSet[] getDecisionLookahead(ATNState s)
Calculates the SLL(1) expected lookahead set for each outgoing transition of anATNState. The returned array has one element for each outgoing transition ins. If the closure from transition i leads to a semantic predicate before matching a symbol, the element at index i of the result will benull.- Parameters:
s- the ATN state- Returns:
- the expected symbols for each outgoing transition of
s.
-
LOOK
public IntervalSet LOOK(ATNState s, RuleContext ctx)
Compute set of tokens that can followsin the ATN in the specifiedctx.If
ctxisnulland the end of the rule containingsis reached,Token.EPSILONis added to the result set. Ifctxis notnulland the end of the outermost rule is reached,Token.EOFis added to the result set.- Parameters:
s- the ATN statectx- the complete parser context, ornullif the context should be ignored- Returns:
- The set of tokens that can follow
sin the ATN in the specifiedctx.
-
LOOK
public IntervalSet LOOK(ATNState s, ATNState stopState, RuleContext ctx)
Compute set of tokens that can followsin the ATN in the specifiedctx.If
ctxisnulland the end of the rule containingsis reached,Token.EPSILONis added to the result set. Ifctxis notnulland the end of the outermost rule is reached,Token.EOFis added to the result set.- Parameters:
s- the ATN statestopState- the ATN state to stop at. This can be aBlockEndStateto detect epsilon paths through a closure.ctx- the complete parser context, ornullif the context should be ignored- Returns:
- The set of tokens that can follow
sin the ATN in the specifiedctx.
-
_LOOK
protected void _LOOK(ATNState s, ATNState stopState, PredictionContext ctx, IntervalSet look, Set<ATNConfig> lookBusy, BitSet calledRuleStack, boolean seeThruPreds, boolean addEOF)
Compute set of tokens that can followsin the ATN in the specifiedctx.If
ctxisnullandstopStateor the end of the rule containingsis reached,Token.EPSILONis added to the result set. Ifctxis notnullandaddEOFistrueandstopStateor the end of the outermost rule is reached,Token.EOFis added to the result set.- Parameters:
s- the ATN state.stopState- the ATN state to stop at. This can be aBlockEndStateto detect epsilon paths through a closure.ctx- The outer context, ornullif the outer context should not be used.look- The result lookahead set.lookBusy- A set used for preventing epsilon closures in the ATN from causing a stack overflow. Outside code should passnew HashSet<ATNConfig>for this argument.calledRuleStack- A set used for preventing left recursion in the ATN from causing a stack overflow. Outside code should passnew BitSet()for this argument.seeThruPreds-trueto true semantic predicates as implicitlytrueand "see through them", otherwisefalseto treat semantic predicates as opaque and addHIT_PREDto the result if one is encountered.addEOF- AddToken.EOFto the result if the end of the outermost context is reached. This parameter has no effect ifctxisnull.
-
-