Package jflex.core
Class NFA
- java.lang.Object
-
- jflex.core.NFA
-
public final class NFA extends Object
Non-deterministic finite automata representation in JFlex.Contains algorithms RegExp → NFA.
- Version:
- JFlex 1.8.1
- Author:
- Gerwin Klein
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEpsilonTransition(int start, int dest)
void
addRegExp(int regExpNum)
Add a regexp to this NFA.void
addStandaloneRule()
Add a standalone rule that has minimum priority, fires a transition on all single input characters and has a "print yytext" action.void
addTransition(int start, int input, int dest)
boolean
containsFinal(StateSet set)
Returnstrue
, iff the specified set of states contains a final state.String
dotFormat()
void
dumpTable()
StateSet
epsilon(int i)
void
epsilonFill()
Action
getAction(StateSet set)
Returns the action with highest priority in the specified set of states.IntPair
insertNFA(RegExp regExp)
Constructs an NFA for regExp such that the NFA hasint
numEntryStates()
int
numInput()
int
numLexStates()
int
numStates()
StateSet
reachableStates(int currentState, int nextChar)
Returns the set of states that can be reached from currentState with an input nextChar.StateSetEnumerator
states()
StateSet
tempStateSet()
String
toString()
void
writeDot(File file)
-
-
-
Constructor Detail
-
NFA
public NFA(int numInput, int estSize)
Constructor for NFA.
-
NFA
public NFA(int numInput, LexScan scanner, RegExps regExps, Macros macros, CharClasses classes)
Construct new NFA.Assumes that lookahead cases and numbers are already resolved in RegExps.
- Parameters:
numInput
- a int.scanner
- aLexScan
object.regExps
- aRegExps
object.macros
- aMacros
object.classes
- aCharClasses
object.- See Also:
RegExps.checkLookAheads()
-
-
Method Detail
-
epsilon
public StateSet epsilon(int i)
-
numEntryStates
public int numEntryStates()
-
numInput
public int numInput()
-
numLexStates
public int numLexStates()
-
numStates
public int numStates()
-
reachableStates
public StateSet reachableStates(int currentState, int nextChar)
Returns the set of states that can be reached from currentState with an input nextChar.
-
states
public StateSetEnumerator states()
-
tempStateSet
public StateSet tempStateSet()
-
addStandaloneRule
public void addStandaloneRule()
Add a standalone rule that has minimum priority, fires a transition on all single input characters and has a "print yytext" action.
-
addRegExp
public void addRegExp(int regExpNum)
Add a regexp to this NFA.- Parameters:
regExpNum
- the number of the regexp to add.
-
addTransition
public void addTransition(int start, int input, int dest)
-
addEpsilonTransition
public void addEpsilonTransition(int start, int dest)
-
containsFinal
public boolean containsFinal(StateSet set)
Returnstrue
, iff the specified set of states contains a final state.- Parameters:
set
- the set of states that is tested for final states.
-
getAction
public Action getAction(StateSet set)
Returns the action with highest priority in the specified set of states.- Parameters:
set
- the set of states for which to determine the action
-
epsilonFill
public void epsilonFill()
-
dumpTable
public void dumpTable()
-
writeDot
public void writeDot(File file)
-
dotFormat
public String dotFormat()
-
insertNFA
public IntPair insertNFA(RegExp regExp)
Constructs an NFA for regExp such that the NFA hasexactly one start state, exactly one end state, no transitions leading out of the end state no transitions leading into the start state
- Parameters:
regExp
- the regular expression to construct the NFA for- Returns:
- a pair of integers denoting the index of start and end state of the NFA.
-
-