Package org.antlr.v4.runtime.atn
Class LL1Analyzer
java.lang.Object
org.antlr.v4.runtime.atn.LL1Analyzer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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
.Calculates the SLL(1) expected lookahead set for each outgoing transition of anATNState
.LOOK
(ATNState s, ATNState stopState, RuleContext ctx) Compute set of tokens that can follows
in the ATN in the specifiedctx
.LOOK
(ATNState s, RuleContext ctx) Compute set of tokens that can follows
in the ATN in the specifiedctx
.
-
Field Details
-
HIT_PRED
public static final int HIT_PREDSpecial value added to the lookahead sets to indicate that we hit a predicate during analysis ifseeThruPreds==false
.- See Also:
-
atn
-
-
Constructor Details
-
LL1Analyzer
-
-
Method Details
-
getDecisionLookahead
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
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
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
.
-