类 NFAState
- java.lang.Object
-
- org.antlr.analysis.State
-
- org.antlr.analysis.NFAState
-
public class NFAState extends State
A state within an NFA. At most 2 transitions emanate from any NFA state.
-
-
字段概要
字段 修饰符和类型 字段 说明 GrammarAST
associatedASTNode
Associate this NFAState with the corresponding GrammarAST node from which this node was created.static int
BLOCK_START
static int
BYPASS
protected int
decisionNumber
What's its decision number from 1..n?int
decisionStateType
Subrules (...)* and (...)+ have more than one decision point in the NFA created for them.protected java.lang.String
description
During debugging and for nondeterminism warnings, it's useful to know what relationship this node has to the original grammar.Rule
enclosingRule
What rule do we live in?int
endOfBlockStateNumber
Jean Bovet needs in the GUI to know which state pairs correspond to the start/stop of a block.protected boolean
EOTTargetState
Is this state the sole target of an EOT transition?Label
incidentEdgeLabel
For o-A->o type NFA tranitions, record the label that leads to this state.static int
LOOPBACK
static int
MAX_TRANSITIONS
NFA
nfa
Which NFA are we in?static int
OPTIONAL_BLOCK_START
static int
RIGHT_EDGE_OF_BLOCK
Transition[]
transition
-
从类继承的字段 org.antlr.analysis.State
acceptState, INVALID_STATE_NUMBER, stateNumber
-
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addTransition(Transition e)
int
getDecisionNumber()
java.lang.String
getDescription()
int
getNumberOfTransitions()
boolean
isDecisionState()
boolean
isEOTTargetState()
void
setDecisionASTNode(GrammarAST decisionASTNode)
What AST node is associated with this NFAState? When you set the AST node, I set the node to point back to this NFA state.void
setDecisionNumber(int decisionNumber)
void
setDescription(java.lang.String description)
void
setEOTTargetState(boolean eot)
void
setTransition0(Transition e)
Used during optimization to reset a state to have the (single) transition another state has.java.lang.String
toString()
Transition
transition(int i)
int
translateDisplayAltToWalkAlt(int displayAlt)
The DFA decision for this NFA decision state always has an exit path for loops as n+1 for n alts in the loop.-
从类继承的方法 org.antlr.analysis.State
isAcceptState, setAcceptState
-
-
-
-
字段详细资料
-
LOOPBACK
public static final int LOOPBACK
- 另请参阅:
- 常量字段值
-
BLOCK_START
public static final int BLOCK_START
- 另请参阅:
- 常量字段值
-
OPTIONAL_BLOCK_START
public static final int OPTIONAL_BLOCK_START
- 另请参阅:
- 常量字段值
-
BYPASS
public static final int BYPASS
- 另请参阅:
- 常量字段值
-
RIGHT_EDGE_OF_BLOCK
public static final int RIGHT_EDGE_OF_BLOCK
- 另请参阅:
- 常量字段值
-
MAX_TRANSITIONS
public static final int MAX_TRANSITIONS
- 另请参阅:
- 常量字段值
-
transition
public Transition[] transition
-
incidentEdgeLabel
public Label incidentEdgeLabel
For o-A->o type NFA tranitions, record the label that leads to this state. Useful for creating rich error messages when we find insufficiently (with preds) covered states.
-
nfa
public NFA nfa
Which NFA are we in?
-
decisionNumber
protected int decisionNumber
What's its decision number from 1..n?
-
decisionStateType
public int decisionStateType
Subrules (...)* and (...)+ have more than one decision point in the NFA created for them. They both have a loop-exit-or-stay-in decision node (the loop back node). They both have a normal alternative block decision node at the left edge. The (...)* is worse as it even has a bypass decision (2 alts: stay in or bypass) node at the extreme left edge. This is not how they get generated in code as a while-loop or whatever deals nicely with either. For error messages (where I need to print the nondeterministic alts) and for interpretation, I need to use the single DFA that is created (for efficiency) but interpret the results differently depending on which of the 2 or 3 decision states uses the DFA. For example, the DFA will always report alt n+1 as the exit branch for n real alts, so I need to translate that depending on the decision state. If decisionNumber>0 then this var tells you what kind of decision state it is.
-
enclosingRule
public Rule enclosingRule
What rule do we live in?
-
description
protected java.lang.String description
During debugging and for nondeterminism warnings, it's useful to know what relationship this node has to the original grammar. For example, "start of alt 1 of rule a".
-
associatedASTNode
public GrammarAST associatedASTNode
Associate this NFAState with the corresponding GrammarAST node from which this node was created. This is useful not only for associating the eventual lookahead DFA with the associated Grammar position, but also for providing users with nondeterminism warnings. Mainly used by decision states to report line:col info. Could also be used to track line:col for elements such as token refs.
-
EOTTargetState
protected boolean EOTTargetState
Is this state the sole target of an EOT transition?
-
endOfBlockStateNumber
public int endOfBlockStateNumber
Jean Bovet needs in the GUI to know which state pairs correspond to the start/stop of a block.
-
-
构造器详细资料
-
NFAState
public NFAState(NFA nfa)
-
-
方法详细资料
-
getNumberOfTransitions
public int getNumberOfTransitions()
- 指定者:
getNumberOfTransitions
在类中State
-
addTransition
public void addTransition(Transition e)
- 指定者:
addTransition
在类中State
-
setTransition0
public void setTransition0(Transition e)
Used during optimization to reset a state to have the (single) transition another state has.
-
transition
public Transition transition(int i)
- 指定者:
transition
在类中State
-
translateDisplayAltToWalkAlt
public int translateDisplayAltToWalkAlt(int displayAlt)
The DFA decision for this NFA decision state always has an exit path for loops as n+1 for n alts in the loop. That is really useful for displaying nondeterministic alts and so on, but for walking the NFA to get a sequence of edge labels or for actually parsing, we need to get the real alt number. The real alt number for exiting a loop is always 1 as transition 0 points at the exit branch (we compute DFAs always for loops at the loopback state). For walking/parsing the loopback state: 1 2 3 display alt (for human consumption) 2 3 1 walk alt For walking the block start: 1 2 3 display alt 1 2 3 For walking the bypass state of a (...)* loop: 1 2 3 display alt 1 1 2 all block alts map to entering loop exit means take bypass Non loop EBNF do not need to be translated; they are ignored by this method as decisionStateType==0. Return same alt if we can't translate.
-
setDecisionASTNode
public void setDecisionASTNode(GrammarAST decisionASTNode)
What AST node is associated with this NFAState? When you set the AST node, I set the node to point back to this NFA state.
-
getDescription
public java.lang.String getDescription()
-
setDescription
public void setDescription(java.lang.String description)
-
getDecisionNumber
public int getDecisionNumber()
-
setDecisionNumber
public void setDecisionNumber(int decisionNumber)
-
isEOTTargetState
public boolean isEOTTargetState()
-
setEOTTargetState
public void setEOTTargetState(boolean eot)
-
isDecisionState
public boolean isDecisionState()
-
toString
public java.lang.String toString()
- 覆盖:
toString
在类中java.lang.Object
-
-