Package jflex.dfa
Class DFA
java.lang.Object
jflex.dfa.DFA
- Direct Known Subclasses:
DeprecatedDfa
Deterministic finite automata representation in JFlex. Contains minimization algorithm.
- Version:
- JFlex 1.8.2
- Author:
- Gerwin Klein
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The 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) void
addTransition
(int start, int input, int dest) addTransition.void
checkActions
(LexScan scanner, LexParse parser) Checks that all actions can actually be matched in this DFA.int
entryState
(int i) boolean
int
hashCode()
boolean
isFinal
(int i) boolean
boolean
void
minimize()
Implementation of Hopcroft's O(n log n) minimization algorithm, follows description by D.int
numInput()
int
int
void
Sets the action.void
setEntryState
(int eState, int trueState) Sets the state of the entry.void
setFinal
(int state, boolean isFinalState) setFinal.int
table
(int i, int j) toString()
toString
(int[] a) Returns a representation of this DFA.void
Writes 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
Sets the action.- Parameters:
state
- a int.stateAction
- aAction
object.
-
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
public int hashCode() -
equals
-
writeDot
Writes a dot-file representing this DFA.- Parameters:
file
- output file.
-
checkActions
Checks that all actions can actually be matched in this DFA. -
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
-