Package org.antlr.v4.runtime.atn
Class ATNConfigSet
java.lang.Object
org.antlr.v4.runtime.atn.ATNConfigSet
- Direct Known Subclasses:
OrderedATNConfigSet
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static final class
static class
The reason that we need this is because we don't want the hash map to use the standard hash code and equals. -
Field Summary
FieldsModifier and TypeFieldDescriptionAll configs but hashed by (s, i, _, pi) not including context.Track the elements as they are added to the set; supports get(i)protected BitSet
Currently this is only used when we detect SLL conflict; this does not necessarily represent the ambiguous alternatives.boolean
final boolean
Indicates that this configuration set is part of a full context LL prediction.boolean
protected boolean
Indicates that the set of configurations is read-only.int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
add
(ATNConfig config, DoubleKeyMap<PredictionContext, PredictionContext, PredictionContext> mergeCache) Adding a new config means merging contexts with existing configs for(s, i, pi, _)
, wheres
is theATNConfig.state
,i
is theATNConfig.alt
, andpi
is theATNConfig.semanticContext
.boolean
addAll
(Collection<? extends ATNConfig> coll) void
clear()
boolean
boolean
containsAll
(Collection<?> c) boolean
containsFast
(ATNConfig obj) elements()
Return a List holding list of configsboolean
get
(int i) getAlts()
Gets the complete set of represented alternatives for the configuration set.int
hashCode()
boolean
isEmpty()
boolean
iterator()
void
optimizeConfigs
(ATNSimulator interpreter) boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) void
setReadonly
(boolean readonly) int
size()
toArray()
<T> T[]
toArray
(T[] a) toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
spliterator
-
Field Details
-
readonly
protected boolean readonlyIndicates that the set of configurations is read-only. Do not allow any code to manipulate the set; DFA states will point at the sets and they must not change. This does not protect the other fields; in particular, conflictingAlts is set after we've made this readonly. -
configLookup
All configs but hashed by (s, i, _, pi) not including context. Wiped out when we go readonly as this set becomes a DFA state. -
configs
Track the elements as they are added to the set; supports get(i) -
uniqueAlt
public int uniqueAlt -
conflictingAlts
Currently this is only used when we detect SLL conflict; this does not necessarily represent the ambiguous alternatives. In fact, I should also point out that this seems to include predicated alternatives that have predicates that evaluate to false. Computed in computeTargetState(). -
hasSemanticContext
public boolean hasSemanticContext -
dipsIntoOuterContext
public boolean dipsIntoOuterContext -
fullCtx
public final boolean fullCtxIndicates that this configuration set is part of a full context LL prediction. It will be used to determine how to merge $. With SLL it's a wildcard whereas it is not for LL context merge.
-
-
Constructor Details
-
ATNConfigSet
public ATNConfigSet(boolean fullCtx) -
ATNConfigSet
public ATNConfigSet() -
ATNConfigSet
-
-
Method Details
-
add
-
add
public boolean add(ATNConfig config, DoubleKeyMap<PredictionContext, PredictionContext, PredictionContext> mergeCache) Adding a new config means merging contexts with existing configs for(s, i, pi, _)
, wheres
is theATNConfig.state
,i
is theATNConfig.alt
, andpi
is theATNConfig.semanticContext
. We use(s,i,pi)
as key.This method updates
dipsIntoOuterContext
andhasSemanticContext
when necessary. -
elements
Return a List holding list of configs -
getStates
-
getAlts
Gets the complete set of represented alternatives for the configuration set.- Returns:
- the set of represented alternatives in this configuration set
- Since:
- 4.3
-
getPredicates
-
get
-
optimizeConfigs
-
addAll
-
equals
-
hashCode
public int hashCode() -
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
containsFast
-
iterator
-
clear
public void clear() -
isReadonly
public boolean isReadonly() -
setReadonly
public void setReadonly(boolean readonly) -
toString
-
toArray
-
toArray
public <T> T[] toArray(T[] a) -
remove
-
containsAll
- Specified by:
containsAll
in interfaceCollection<ATNConfig>
- Specified by:
containsAll
in interfaceSet<ATNConfig>
-
retainAll
-
removeAll
-