程序包 org.antlr.tool
类 FASerializer
- java.lang.Object
-
- org.antlr.tool.FASerializer
-
public class FASerializer extends java.lang.Object
An aspect of FA (finite automata) that knows how to dump them to serialized strings.
-
-
字段概要
字段 修饰符和类型 字段 说明 protected Grammar
grammar
protected java.util.Set<State>
markedStates
To prevent infinite recursion when walking state machines, record which states we've visited.protected int
stateCounter
Each state we walk will get a new state number for serialization purposes.protected java.util.Map<State,java.lang.Integer>
stateNumberTranslator
Rather than add a new instance variable to NFA and DFA just for serializing machines, map old state numbers to new state numbers by a State object → Integer new state number HashMap.
-
构造器概要
构造器 构造器 说明 FASerializer(Grammar grammar)
This aspect is associated with a grammar; used to get token names
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 java.lang.String
serialize(State s)
java.lang.String
serialize(State s, boolean renumber)
Return a string representation of a state machine.protected void
walkFANormalizingStateNumbers(State s)
In stateNumberTranslator, get a map from State to new, normalized state number.protected void
walkSerializingFA(java.util.List<java.lang.String> lines, State s)
-
-
-
字段详细资料
-
markedStates
protected java.util.Set<State> markedStates
To prevent infinite recursion when walking state machines, record which states we've visited. Make a new set every time you start walking in case you reuse this object. Multiple threads will trash this shared variable. Use a different FASerializer per thread.
-
stateCounter
protected int stateCounter
Each state we walk will get a new state number for serialization purposes. This is the variable that tracks state numbers.
-
stateNumberTranslator
protected java.util.Map<State,java.lang.Integer> stateNumberTranslator
Rather than add a new instance variable to NFA and DFA just for serializing machines, map old state numbers to new state numbers by a State object → Integer new state number HashMap.
-
grammar
protected Grammar grammar
-
-
构造器详细资料
-
FASerializer
public FASerializer(Grammar grammar)
This aspect is associated with a grammar; used to get token names
-
-
方法详细资料
-
serialize
public java.lang.String serialize(State s)
-
serialize
public java.lang.String serialize(State s, boolean renumber)
Return a string representation of a state machine. Two identical NFAs or DFAs will have identical serialized representations. The state numbers inside the state are not used; instead, a new number is computed and because the serialization will walk the two machines using the same specific algorithm, then the state numbers will be identical. Accept states are distinguished from regular states.
-
walkFANormalizingStateNumbers
protected void walkFANormalizingStateNumbers(State s)
In stateNumberTranslator, get a map from State to new, normalized state number. Used by walkSerializingFA to make sure any two identical state machines will serialize the same way.
-
walkSerializingFA
protected void walkSerializingFA(java.util.List<java.lang.String> lines, State s)
-
-