|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectre.NFA
public class NFA
A class to represent an NFA. You should create an NFA from a regular expression using this class. States are represented as numbers (with 0 always being the start state). Transitions can be lablled with 'a' - 'z', or '@' to indicate an epsilon transition. The constructor for NFA creates an automaton containing only state 0 and no transitions. The other NFA methods permit you to add new states and edges to the NFA, as well as to print out an NFA in a form suitable for the NFASimulator (or for viewing with dot).
Constructor Summary | |
---|---|
NFA()
Create a new NFA with state 0. |
Method Summary | |
---|---|
void |
addTransition(int start,
int end,
char c)
Add a transition to the NFA. |
int |
newState()
Add a new state to the NFA and return its id number. |
void |
printDot()
Creates a file nfa.dot containing a graphical description of the NFA. |
void |
setAcceptState(int state)
Set the accepting state for the NFA. |
String |
toString()
Return a String representing the NFA in a way that can be read in by nfa.NFASimulator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NFA()
Method Detail |
---|
public void setAcceptState(int state)
public void addTransition(int start, int end, char c)
start
- must be a valid state in the NFAend
- must be a valid state in the NFAc
- the character on the edge. 'a' <= c <= 'z', or c == '@' for epsilonpublic int newState()
public String toString()
toString
in class Object
public void printDot()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |