Package org.antlr.v4.runtime.atn
Class ATNConfigSet
- java.lang.Object
-
- org.antlr.v4.runtime.atn.ATNConfigSet
-
- Direct Known Subclasses:
OrderedATNConfigSet
public class ATNConfigSet extends Object implements Set<ATNConfig>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ATNConfigSet.AbstractConfigHashSet
static class
ATNConfigSet.ConfigEqualityComparator
static class
ATNConfigSet.ConfigHashSet
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
Fields Modifier and Type Field Description ATNConfigSet.AbstractConfigHashSet
configLookup
All configs but hashed by (s, i, _, pi) not including context.ArrayList<ATNConfig>
configs
Track the elements as they are added to the set; supports get(i)protected BitSet
conflictingAlts
Currently this is only used when we detect SLL conflict; this does not necessarily represent the ambiguous alternatives.boolean
dipsIntoOuterContext
boolean
fullCtx
Indicates that this configuration set is part of a full context LL prediction.boolean
hasSemanticContext
protected boolean
readonly
Indicates that the set of configurations is read-only.int
uniqueAlt
-
Constructor Summary
Constructors Constructor Description ATNConfigSet()
ATNConfigSet(boolean fullCtx)
ATNConfigSet(ATNConfigSet old)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(ATNConfig config)
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
contains(Object o)
boolean
containsAll(Collection<?> c)
boolean
containsFast(ATNConfig obj)
List<ATNConfig>
elements()
Return a List holding list of configsboolean
equals(Object o)
ATNConfig
get(int i)
BitSet
getAlts()
Gets the complete set of represented alternatives for the configuration set.List<SemanticContext>
getPredicates()
Set<ATNState>
getStates()
int
hashCode()
boolean
isEmpty()
boolean
isReadonly()
Iterator<ATNConfig>
iterator()
void
optimizeConfigs(ATNSimulator interpreter)
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
void
setReadonly(boolean readonly)
int
size()
ATNConfig[]
toArray()
<T> T[]
toArray(T[] a)
String
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 Detail
-
readonly
protected boolean readonly
Indicates 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
public ATNConfigSet.AbstractConfigHashSet 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
public final ArrayList<ATNConfig> configs
Track the elements as they are added to the set; supports get(i)
-
uniqueAlt
public int uniqueAlt
-
conflictingAlts
protected BitSet 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 fullCtx
Indicates 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 Detail
-
ATNConfigSet
public ATNConfigSet(boolean fullCtx)
-
ATNConfigSet
public ATNConfigSet()
-
ATNConfigSet
public ATNConfigSet(ATNConfigSet old)
-
-
Method Detail
-
add
public boolean add(ATNConfig config)
-
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.
-
getAlts
public BitSet 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
public List<SemanticContext> getPredicates()
-
get
public ATNConfig get(int i)
-
optimizeConfigs
public void optimizeConfigs(ATNSimulator interpreter)
-
addAll
public boolean addAll(Collection<? extends ATNConfig> coll)
-
equals
public boolean equals(Object o)
-
hashCode
public int hashCode()
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
containsFast
public boolean containsFast(ATNConfig obj)
-
clear
public void clear()
-
isReadonly
public boolean isReadonly()
-
setReadonly
public void setReadonly(boolean readonly)
-
toArray
public ATNConfig[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
remove
public boolean remove(Object o)
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<ATNConfig>
- Specified by:
containsAll
in interfaceSet<ATNConfig>
-
retainAll
public boolean retainAll(Collection<?> c)
-
removeAll
public boolean removeAll(Collection<?> c)
-
-