Package jflex.dfa
Class DFA
- java.lang.Object
-
- jflex.dfa.DFA
-
- Direct Known Subclasses:
DeprecatedDfa
public class DFA extends Object
Deterministic finite automata representation in JFlex. Contains minimization algorithm.- Version:
- JFlex 1.8.1
- Author:
- Gerwin Klein
-
-
Field Summary
Fields Modifier and Type Field Description static int
NO_TARGET
The code for "no target state" in the transition table.
-
Constructor Summary
Constructors Constructor Description DFA(int numEntryStates, int numInputs, int numLexStates)
Constructor for a deterministic finite automata.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Action
action(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
equals(Object obj)
int
hashCode()
boolean
isFinal(int i)
boolean
isMinimized()
boolean
lookaheadUsed()
void
minimize()
Implementation of Hopcroft's O(n log n) minimization algorithm, follows description by D.int
numInput()
int
numLexStates()
int
numStates()
void
setAction(int state, Action stateAction)
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)
String
toString()
String
toString(int[] a)
Returns a representation of this DFA.void
writeDot(File file)
Writes a dot-file representing this DFA.
-
-
-
Field Detail
-
NO_TARGET
public static final int NO_TARGET
The code for "no target state" in the transition table.- See Also:
- Constant Field Values
-
-
Method Detail
-
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
public void setAction(int state, Action stateAction)
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()
-
writeDot
public void writeDot(File file)
Writes a dot-file representing this DFA.- Parameters:
file
- output file.
-
checkActions
public void checkActions(LexScan scanner, LexParse parser)
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
public String toString(int[] a)
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
public Action action(int i)
-
-