Class DFA
java.lang.Object
jflex.dfa.DFA
- Direct Known Subclasses:
DeprecatedDfa
Deterministic finite automata representation in JFlex. Contains minimization algorithm.
- Version:
- JFlex 1.9.1
- Author:
- Gerwin Klein
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe code for "no target state" in the transition table. -
Constructor Summary
ConstructorsConstructorDescriptionDFA(int numEntryStates, int numInputs, int numLexStates) Constructor for a deterministic finite automata. -
Method Summary
Modifier and TypeMethodDescriptionaction(int i) voidaddTransition(int start, int input, int dest) addTransition.voidcheckActions(LexScan scanner, LexParse parser) Checks that all actions can actually be matched in this DFA.intentryState(int i) booleaninthashCode()booleanisFinal(int i) booleanbooleanvoidminimize()Implementation of Hopcroft's O(n log n) minimization algorithm, follows description by D.intnumInput()intintvoidSets the action.voidsetEntryState(int eState, int trueState) Sets the state of the entry.voidsetFinal(int state, boolean isFinalState) setFinal.inttable(int i, int j) toString()toString(int[] a) Returns a representation of this DFA.voidWrites a dot-file representing this DFA.
-
Field Details
-
NO_TARGET
public static final int NO_TARGETThe code for "no target state" in the transition table.- See Also:
-
-
Constructor Details
-
DFA
public DFA(int numEntryStates, int numInputs, int numLexStates) Constructor for a deterministic finite automata.
-
-
Method Details
-
setEntryState
public void setEntryState(int eState, int trueState) Sets the state of the entry.- Parameters:
eState- entry state.trueState- whether it is the current state.
-
setAction
-
setFinal
public void setFinal(int state, boolean isFinalState) setFinal.- Parameters:
state- a int.isFinalState- a boolean.
-
addTransition
public void addTransition(int start, int input, int dest) addTransition.- Parameters:
start- a int.input- a int.dest- a int.
-
lookaheadUsed
public boolean lookaheadUsed() -
toString
-
hashCode
-
equals
-
writeDot
Writes a dot-file representing this DFA.- Parameters:
file- output file.
-
checkActions
-
minimize
public void minimize()Implementation of Hopcroft's O(n log n) minimization algorithm, follows description by D. Gries.Time:
O(n log n)Space:O(c n), size < 4*(5*c*n + 13*n + 3*c) byte -
isMinimized
public boolean isMinimized() -
toString
Returns a representation of this DFA. -
numInput
public int numInput() -
numStates
public int numStates() -
numLexStates
public int numLexStates() -
entryState
public int entryState(int i) -
isFinal
public boolean isFinal(int i) -
table
public int table(int i, int j) -
action
-