Modifier and Type | Field | Description |
---|---|---|
Vector<Integer> |
accept |
|
protected DFAState[] |
altToAcceptState |
We only want one accept state per predicted alt; track here
|
protected boolean |
cyclic |
Are there any loops in this DFA?
Computed by doesStateReachAcceptState()
|
static int |
CYCLIC_BUSY |
|
static int |
CYCLIC_DONE |
|
static int |
CYCLIC_UNKNOWN |
|
NFAState |
decisionNFAStartState |
From what NFAState did we create the DFA?
|
int |
decisionNumber |
This DFA is being built for which decision?
|
String |
description |
The printable grammar fragment associated with this DFA
|
protected int |
edgeTransitionClass |
The unique edge transition class number; every time we see a new
set of edges emanating from a state, we number it so we can reuse
if it's every seen again for another state.
|
Map<List<Integer>,Integer> |
edgeTransitionClassMap |
Map an edge transition table to a unique set number; ordered so
we can push into the output template as an ordered list of sets
and then ref them from within the transition[][] table.
|
Vector<Integer> |
eof |
|
Vector<Integer> |
eot |
|
protected CodeGenerator |
generator |
Which generator to use if we're building state tables
|
boolean |
hasPredicateBlockedByAction |
|
Vector<Integer> |
max |
|
protected int |
max_k |
While building the DFA, track max lookahead depth if not cyclic
|
static int |
MAX_STATE_TRANSITIONS_FOR_TABLE |
How many edges can each DFA state have before a "special" state
is created that uses IF expressions instead of a table?
|
static int |
MAX_TIME_PER_DFA_CREATION |
Set to 0 to not terminate early (time in ms)
|
Vector<Integer> |
min |
|
protected int |
nAlts |
|
NFA |
nfa |
Which NFA are we converting (well, which piece of the NFA)?
|
protected NFAToDFAConverter |
nfaConverter |
|
protected int |
numberOfStates |
count only new states not states that were rejected as already present
|
boolean |
predicateVisible |
Track whether this DFA has at least one sem/syn pred encountered
during a closure operation.
|
DecisionProbe |
probe |
This probe tells you a lot about a decision and is useful even
when there is no error such as when a syntactic nondeterminism
is solved via semantic predicates.
|
static int |
REACHABLE_BUSY |
|
static int |
REACHABLE_NO |
|
static int |
REACHABLE_UNKNOWN |
|
static int |
REACHABLE_YES |
|
IntSet |
recursiveAltSet |
Track whether an alt discovers recursion for each alt during
NFA to DFA conversion; >1 alt with recursion implies nonregular.
|
protected boolean |
reduced |
Is this DFA reduced? I.e., can all states lead to an accept state?
|
Vector<Integer> |
special |
|
List<DFAState> |
specialStates |
List of special DFAState objects
|
List<org.stringtemplate.v4.ST> |
specialStateSTs |
List of ST for special states.
|
DFAState |
startState |
What's the start state for this DFA?
|
protected int |
stateCounter |
Unique state numbers per DFA
|
protected Vector<DFAState> |
states |
Maps the state number to the actual DFAState.
|
Vector<Vector<Integer>> |
transition |
|
Vector<Integer> |
transitionEdgeTables |
just the Vector<Integer> indicating which unique edge table is at
position i.
|
protected int |
uniqueCompressedSpecialStateNum |
|
protected Map<DFAState,DFAState> |
uniqueStates |
A set of all uniquely-numbered DFA states.
|
protected List<Integer> |
unreachableAlts |
Each alt in an NFA derived from a grammar must have a DFA state that
predicts it lest the parser not know what to do.
|
protected int |
user_k |
User specified max fixed lookahead.
|
Modifier | Constructor | Description |
---|---|---|
protected |
DFA() |
|
|
DFA(int decisionNumber,
NFAState decisionStartState) |
Modifier and Type | Method | Description |
---|---|---|
protected DFAState |
addState(DFAState d) |
Add a new DFA state to this DFA if not already present.
|
boolean |
canInlineDecision() |
|
protected void |
createEOTAndEOFTables(DFAState s) |
Set up the EOT and EOF tables; we cannot put -1 min/max values so
we need another way to test that in the DFA transition function.
|
protected void |
createMinMaxTables(DFAState s) |
|
protected void |
createSpecialTable(DFAState s) |
|
void |
createStateTables(CodeGenerator generator) |
|
protected void |
createTransitionTableEntryForState(DFAState s) |
|
protected boolean |
doesStateReachAcceptState(DFAState d) |
figure out if this state eventually reaches an accept state and
modify the instance variable 'reduced' to indicate if we find
at least one state that cannot reach an accept state.
|
void |
findAllGatedSynPredsUsedInDFAAcceptStates() |
Walk all accept states and find the manually-specified synpreds.
|
DFAState |
getAcceptState(int alt) |
|
boolean |
getAutoBacktrackMode() |
|
GrammarAST |
getDecisionASTNode() |
What GrammarAST node (derived from the grammar) is this DFA
associated with? It will point to the start of a block or
the loop back of a (...)+ block etc...
|
int |
getDecisionNumber() |
|
String |
getDescription() |
|
boolean |
getHasSynPred() |
|
List<? extends String> |
getJavaCompressedAccept() |
|
List<? extends String> |
getJavaCompressedEOF() |
|
List<? extends String> |
getJavaCompressedEOT() |
|
List<? extends String> |
getJavaCompressedMax() |
|
List<? extends String> |
getJavaCompressedMin() |
|
List<? extends String> |
getJavaCompressedSpecial() |
|
List<List<? extends String>> |
getJavaCompressedTransition() |
|
int |
getMaxLookaheadDepth() |
Return k if decision is LL(k) for some k else return max int
|
int |
getMaxStateNumber() |
What is the max state number ever created? This may be beyond
getNumberOfStates().
|
NFAState |
getNFADecisionStartState() |
|
int |
getNumberOfAlts() |
|
int |
getNumberOfStates() |
|
String |
getReasonForFailure() |
|
List<? extends String> |
getRunLengthEncoding(List<Integer> data) |
Compress the incoming data list so that runs of same number are
encoded as number,value pair sequences.
|
DFAState |
getState(int stateNumber) |
|
Map<DFAState,DFAState> |
getUniqueStates() |
|
List<Integer> |
getUnreachableAlts() |
Return a list of Integer alt numbers for which no lookahead could
be computed or for which no single DFA accept state predicts those
alts.
|
int |
getUserMaxLookahead() |
The user may specify a max, acyclic lookahead for any decision.
|
boolean |
hasCycle() |
Compute cyclic w/o relying on state computed during analysis.
|
boolean |
hasSemPred() |
|
boolean |
hasSynPred() |
Count all disambiguating syn preds (ignore synpred tests
for gated edges, which occur for nonambig input sequences).
|
protected void |
initAltRelatedInfo() |
|
boolean |
isClassicDFA() |
|
boolean |
isCyclic() |
Is this DFA cyclic? That is, are there any loops? If not, then
the DFA is essentially an LL(k) predictor for some fixed, max k value.
|
boolean |
isGreedy() |
|
boolean |
isReduced() |
Is the DFA reduced? I.e., does every state have a path to an accept
state? If not, don't delete as we need to generate an error indicating
which paths are "dead ends".
|
boolean |
isTokensRuleDecision() |
Is this DFA derived from the NFA for the Tokens rule?
|
DFAState |
newState() |
|
boolean |
okToRetryDFAWithK1() |
If this DFA failed to finish during construction, we might be
able to retry with k=1 but we need to know whether it will
potentially succeed.
|
int |
predict(org.antlr.runtime.IntStream input) |
|
void |
removeState(DFAState d) |
|
void |
resetStateNumbersToBeContiguous() |
Walk all states and reset their numbers to be a contiguous sequence
of integers starting from 0.
|
void |
setAcceptState(int alt,
DFAState acceptState) |
|
void |
setState(int stateNumber,
DFAState d) |
|
void |
setUserMaxLookahead(int k) |
|
String |
toString() |
|
void |
verify() |
Once this DFA has been built, need to verify that:
1.
|
public static final int REACHABLE_UNKNOWN
public static final int REACHABLE_BUSY
public static final int REACHABLE_NO
public static final int REACHABLE_YES
public static final int CYCLIC_UNKNOWN
public static final int CYCLIC_BUSY
public static final int CYCLIC_DONE
public static int MAX_TIME_PER_DFA_CREATION
public static int MAX_STATE_TRANSITIONS_FOR_TABLE
public DFAState startState
public int decisionNumber
public NFAState decisionNFAStartState
public String description
protected Map<DFAState,DFAState> uniqueStates
protected Vector<DFAState> states
protected int stateCounter
protected int numberOfStates
protected int user_k
protected int max_k
protected boolean reduced
protected boolean cyclic
public boolean predicateVisible
public boolean hasPredicateBlockedByAction
protected List<Integer> unreachableAlts
protected int nAlts
protected DFAState[] altToAcceptState
public IntSet recursiveAltSet
public NFA nfa
protected NFAToDFAConverter nfaConverter
public DecisionProbe probe
public Map<List<Integer>,Integer> edgeTransitionClassMap
protected int edgeTransitionClass
public List<org.stringtemplate.v4.ST> specialStateSTs
public Vector<Integer> transitionEdgeTables
protected int uniqueCompressedSpecialStateNum
protected CodeGenerator generator
protected DFA()
public DFA(int decisionNumber, NFAState decisionStartState)
public void resetStateNumbersToBeContiguous()
public List<? extends String> getRunLengthEncoding(List<Integer> data)
public void createStateTables(CodeGenerator generator)
protected void createMinMaxTables(DFAState s)
protected void createTransitionTableEntryForState(DFAState s)
protected void createEOTAndEOFTables(DFAState s)
protected void createSpecialTable(DFAState s)
public int predict(org.antlr.runtime.IntStream input)
protected DFAState addState(DFAState d)
public void removeState(DFAState d)
public int getMaxStateNumber()
public DFAState getState(int stateNumber)
public void setState(int stateNumber, DFAState d)
public boolean isReduced()
public boolean isCyclic()
public boolean isClassicDFA()
public boolean canInlineDecision()
public boolean isTokensRuleDecision()
public int getUserMaxLookahead()
public boolean getAutoBacktrackMode()
public void setUserMaxLookahead(int k)
public int getMaxLookaheadDepth()
public boolean hasSynPred()
public boolean getHasSynPred()
public boolean hasSemPred()
public boolean hasCycle()
public List<Integer> getUnreachableAlts()
public void verify()
protected boolean doesStateReachAcceptState(DFAState d)
public void findAllGatedSynPredsUsedInDFAAcceptStates()
public NFAState getNFADecisionStartState()
public DFAState getAcceptState(int alt)
public void setAcceptState(int alt, DFAState acceptState)
public String getDescription()
public int getDecisionNumber()
public boolean okToRetryDFAWithK1()
public String getReasonForFailure()
public GrammarAST getDecisionASTNode()
public boolean isGreedy()
public DFAState newState()
public int getNumberOfStates()
public int getNumberOfAlts()
protected void initAltRelatedInfo()
Copyright © 1992–2019 ANTLR. All rights reserved.