public abstract class ATNSimulator extends Object
Modifier and Type | Field and Description |
---|---|
ATN |
atn |
static DFAState |
ERROR
Must distinguish between missing edge and edge we know leads nowhere
|
static UUID |
SERIALIZED_UUID
Deprecated.
Use
ATNDeserializer.checkCondition(boolean) instead. |
static int |
SERIALIZED_VERSION
Deprecated.
Use
ATNDeserializer.SERIALIZED_VERSION instead. |
protected PredictionContextCache |
sharedContextCache
The context cache maps all PredictionContext objects that are equals()
to a single cached copy.
|
Constructor and Description |
---|
ATNSimulator(ATN atn,
PredictionContextCache sharedContextCache) |
Modifier and Type | Method and Description |
---|---|
static void |
checkCondition(boolean condition)
Deprecated.
Use
ATNDeserializer.checkCondition(boolean) instead. |
static void |
checkCondition(boolean condition,
String message)
Deprecated.
Use
ATNDeserializer.checkCondition(boolean, String) instead. |
void |
clearDFA()
Clear the DFA cache used by the current instance.
|
static ATN |
deserialize(char[] data)
Deprecated.
Use
ATNDeserializer.deserialize(char[]) instead. |
static Transition |
edgeFactory(ATN atn,
int type,
int src,
int trg,
int arg1,
int arg2,
int arg3,
List<IntervalSet> sets)
|
PredictionContext |
getCachedContext(PredictionContext context) |
PredictionContextCache |
getSharedContextCache() |
abstract void |
reset() |
static ATNState |
stateFactory(int type,
int ruleIndex)
Deprecated.
Use
ATNDeserializer.stateFactory(int, int) instead. |
static int |
toInt(char c)
Deprecated.
Use
ATNDeserializer.toInt(char) instead. |
static int |
toInt32(char[] data,
int offset)
Deprecated.
Use
ATNDeserializer.toInt32(char[], int) instead. |
static long |
toLong(char[] data,
int offset)
Deprecated.
Use
ATNDeserializer.toLong(char[], int) instead. |
static UUID |
toUUID(char[] data,
int offset)
Deprecated.
Use
ATNDeserializer.toUUID(char[], int) instead. |
@Deprecated public static final int SERIALIZED_VERSION
ATNDeserializer.SERIALIZED_VERSION
instead.@Deprecated public static final UUID SERIALIZED_UUID
ATNDeserializer.checkCondition(boolean)
instead.public static final DFAState ERROR
public final ATN atn
protected final PredictionContextCache sharedContextCache
This cache makes a huge difference in memory and a little bit in speed. For the Java grammar on java.*, it dropped the memory requirements at the end from 25M to 16M. We don't store any of the full context graphs in the DFA because they are limited to local context only, but apparently there's a lot of repetition there as well. We optimize the config contexts before storing the config set in the DFA states by literally rebuilding them with cached subgraphs only.
I tried a cache for use during closure operations, that was whacked after each adaptivePredict(). It cost a little bit more time I think and doesn't save on the overall footprint so it's not worth the complexity.
public ATNSimulator(ATN atn, PredictionContextCache sharedContextCache)
public abstract void reset()
public void clearDFA()
UnsupportedOperationException
- if the current instance does not
support clearing the DFA.public PredictionContextCache getSharedContextCache()
public PredictionContext getCachedContext(PredictionContext context)
@Deprecated public static ATN deserialize(char[] data)
ATNDeserializer.deserialize(char[])
instead.@Deprecated public static void checkCondition(boolean condition)
ATNDeserializer.checkCondition(boolean)
instead.@Deprecated public static void checkCondition(boolean condition, String message)
ATNDeserializer.checkCondition(boolean, String)
instead.@Deprecated public static int toInt(char c)
ATNDeserializer.toInt(char)
instead.@Deprecated public static int toInt32(char[] data, int offset)
ATNDeserializer.toInt32(char[], int)
instead.@Deprecated public static long toLong(char[] data, int offset)
ATNDeserializer.toLong(char[], int)
instead.@Deprecated public static UUID toUUID(char[] data, int offset)
ATNDeserializer.toUUID(char[], int)
instead.@Deprecated public static Transition edgeFactory(ATN atn, int type, int src, int trg, int arg1, int arg2, int arg3, List<IntervalSet> sets)
@Deprecated public static ATNState stateFactory(int type, int ruleIndex)
ATNDeserializer.stateFactory(int, int)
instead.Copyright © 1992–2017 ANTLR. All rights reserved.