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 follows
in the ATN in the specifiedctx
.IntervalSet[]
getDecisionLookahead(ATNState s)
Calculates the SLL(1) expected lookahead set for each outgoing transition of anATNState
.IntervalSet
LOOK(ATNState s, ATNState stopState, RuleContext ctx)
Compute set of tokens that can follows
in the ATN in the specifiedctx
.IntervalSet
LOOK(ATNState s, RuleContext ctx)
Compute set of tokens that can follows
in 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 follows
in the ATN in the specifiedctx
.If
ctx
isnull
and the end of the rule containings
is reached,Token.EPSILON
is added to the result set. Ifctx
is notnull
and the end of the outermost rule is reached,Token.EOF
is added to the result set.- Parameters:
s
- the ATN statectx
- the complete parser context, ornull
if the context should be ignored- Returns:
- The set of tokens that can follow
s
in the ATN in the specifiedctx
.
-
LOOK
public IntervalSet LOOK(ATNState s, ATNState stopState, RuleContext ctx)
Compute set of tokens that can follows
in the ATN in the specifiedctx
.If
ctx
isnull
and the end of the rule containings
is reached,Token.EPSILON
is added to the result set. Ifctx
is notnull
and the end of the outermost rule is reached,Token.EOF
is added to the result set.- Parameters:
s
- the ATN statestopState
- the ATN state to stop at. This can be aBlockEndState
to detect epsilon paths through a closure.ctx
- the complete parser context, ornull
if the context should be ignored- Returns:
- The set of tokens that can follow
s
in 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 follows
in the ATN in the specifiedctx
.If
ctx
isnull
andstopState
or the end of the rule containings
is reached,Token.EPSILON
is added to the result set. Ifctx
is notnull
andaddEOF
istrue
andstopState
or the end of the outermost rule is reached,Token.EOF
is added to the result set.- Parameters:
s
- the ATN state.stopState
- the ATN state to stop at. This can be aBlockEndState
to detect epsilon paths through a closure.ctx
- The outer context, ornull
if 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
-true
to true semantic predicates as implicitlytrue
and "see through them", otherwisefalse
to treat semantic predicates as opaque and addHIT_PRED
to the result if one is encountered.addEOF
- AddToken.EOF
to the result if the end of the outermost context is reached. This parameter has no effect ifctx
isnull
.
-
-