Package dsa
Class NFA
- java.lang.Object
-
- dsa.NFA
-
public class NFA extends Object
A a data type for creating a nondeterministic finite state automaton (NFA) from a regular expression and testing whether a given string is matched by that regular expression.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(String[] args)
Unit tests the data type.boolean
recognizes(String text)
Returnstrue
if this NFA recognizestext
, andfalse
otherwise.
-
-
-
Constructor Detail
-
NFA
public NFA(String regexp)
Constructs a nondeterministic finite state automaton (NFA) fromregexp
.- Parameters:
regexp
- the regular expression.
-
-
Method Detail
-
recognizes
public boolean recognizes(String text)
Returnstrue
if this NFA recognizestext
, andfalse
otherwise.- Parameters:
text
- the text.- Returns:
true
if this NFA recognizestext
, andfalse
otherwise.
-
main
public static void main(String[] args)
Unit tests the data type.- Parameters:
args
- the command-line arguments.
-
-