Top Fields Constructors Methods
org.antlr.v4.runtime.atn

public Class LL1Analyzer

extends Object
Class Inheritance
Imports
org.antlr.v4.runtime.Token, org.antlr.v4.runtime.misc.IntervalSet, .NotNull, .Nullable, java.util.BitSet, .HashSet, .Set

Field Summary

Modifier and TypeField and Description
public final ATN
public static final int
HIT_PRED

Special value added to the lookahead sets to indicate that we hit a predicate during analysis if seeThruPreds==false.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
_LOOK(ATNState
the ATN state.
s
,
ATNState
the ATN state to stop at. This can be a BlockEndState to detect epsilon paths through a closure.
stopState
,
PredictionContext
The outer context, or PredictionContext#EMPTY_LOCAL if the outer context should not be used.
ctx
,
IntervalSet
The result lookahead set.
look
,
Set<ATNConfig>
A set used for preventing epsilon closures in the ATN from causing a stack overflow. Outside code should pass new HashSet<ATNConfig> for this argument.
lookBusy
,
BitSet
A set used for preventing left recursion in the ATN from causing a stack overflow. Outside code should pass new BitSet() for this argument.
calledRuleStack
,
boolean
true to true semantic predicates as implicitly true and "see through them", otherwise false to treat semantic predicates as opaque and add HIT_PRED to the result if one is encountered.
seeThruPreds
,
boolean
Add Token#EOF to the result if the end of the outermost context is reached. This parameter has no effect if ctx is PredictionContext#EMPTY_LOCAL.
addEOF
)

Compute set of tokens that can follow s in the ATN in the specified ctx.

public IntervalSet[]

Returns:

the expected symbols for each outgoing transition of s.
getDecisionLookahead
(ATNState
the ATN state
s
)

Calculates the SLL(1) expected lookahead set for each outgoing transition of an ATNState.

public IntervalSet

Returns:

The set of tokens that can follow s in the ATN in the specified ctx.
LOOK
(ATNState
the ATN state
s
,
PredictionContext
the complete parser context, or null if the context should be ignored
ctx
)

Compute set of tokens that can follow s in the ATN in the specified ctx.

public IntervalSet

Returns:

The set of tokens that can follow s in the ATN in the specified ctx.
LOOK
(ATNState
the ATN state
s
,
ATNState
the ATN state to stop at. This can be a BlockEndState to detect epsilon paths through a closure.
stopState
,
PredictionContext
the complete parser context, or null if the context should be ignored
ctx
)

Compute set of tokens that can follow s in the ATN in the specified ctx.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

atnback to summary
public final ATN atn
Annotations
@NotNull
HIT_PREDback to summary
public static final int HIT_PRED

Special value added to the lookahead sets to indicate that we hit a predicate during analysis if seeThruPreds==false.

Constructor Detail

LL1Analyzerback to summary
public LL1Analyzer(ATN atn)

Method Detail

_LOOKback to summary
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 follow s in the ATN in the specified ctx.

If ctx is PredictionContext#EMPTY_LOCAL and stopState or the end of the rule containing s is reached, Token#EPSILON is added to the result set. If ctx is not PredictionContext#EMPTY_LOCAL and addEOF is true and stopState or the end of the outermost rule is reached, Token#EOF is added to the result set.

Parameters
s:ATNState

the ATN state.

stopState:ATNState

the ATN state to stop at. This can be a BlockEndState to detect epsilon paths through a closure.

ctx:PredictionContext

The outer context, or PredictionContext#EMPTY_LOCAL if the outer context should not be used.

look:IntervalSet

The result lookahead set.

lookBusy:Set<ATNConfig>

A set used for preventing epsilon closures in the ATN from causing a stack overflow. Outside code should pass new HashSet<ATNConfig> for this argument.

calledRuleStack:BitSet

A set used for preventing left recursion in the ATN from causing a stack overflow. Outside code should pass new BitSet() for this argument.

seeThruPreds:boolean

true to true semantic predicates as implicitly true and "see through them", otherwise false to treat semantic predicates as opaque and add HIT_PRED to the result if one is encountered.

addEOF:boolean

Add Token#EOF to the result if the end of the outermost context is reached. This parameter has no effect if ctx is PredictionContext#EMPTY_LOCAL.

getDecisionLookaheadback to summary
public IntervalSet[] getDecisionLookahead(ATNState s)

Calculates the SLL(1) expected lookahead set for each outgoing transition of an ATNState. The returned array has one element for each outgoing transition in s. If the closure from transition i leads to a semantic predicate before matching a symbol, the element at index i of the result will be null.

Parameters
s:ATNState

the ATN state

Returns:IntervalSet[]

the expected symbols for each outgoing transition of s.

Annotations
@Nullable
LOOKback to summary
public IntervalSet LOOK(ATNState s, PredictionContext ctx)

Compute set of tokens that can follow s in the ATN in the specified ctx.

If ctx is null and the end of the rule containing s is reached, Token#EPSILON is added to the result set. If ctx is not null and the end of the outermost rule is reached, Token#EOF is added to the result set.

Parameters
s:ATNState

the ATN state

ctx:PredictionContext

the complete parser context, or null if the context should be ignored

Returns:IntervalSet

The set of tokens that can follow s in the ATN in the specified ctx.

Annotations
@NotNull
LOOKback to summary
public IntervalSet LOOK(ATNState s, ATNState stopState, PredictionContext ctx)

Compute set of tokens that can follow s in the ATN in the specified ctx.

If ctx is null and the end of the rule containing s is reached, Token#EPSILON is added to the result set. If ctx is not PredictionContext#EMPTY_LOCAL and the end of the outermost rule is reached, Token#EOF is added to the result set.

Parameters
s:ATNState

the ATN state

stopState:ATNState

the ATN state to stop at. This can be a BlockEndState to detect epsilon paths through a closure.

ctx:PredictionContext

the complete parser context, or null if the context should be ignored

Returns:IntervalSet

The set of tokens that can follow s in the ATN in the specified ctx.

Annotations
@NotNull