Package dsa

Class 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.
    • Constructor Detail

      • NFA

        public NFA​(String regexp)
        Constructs a nondeterministic finite state automaton (NFA) from regexp.
        Parameters:
        regexp - the regular expression.
    • Method Detail

      • recognizes

        public boolean recognizes​(String text)
        Returns true if this NFA recognizes text, and false otherwise.
        Parameters:
        text - the text.
        Returns:
        true if this NFA recognizes text, and false otherwise.
      • main

        public static void main​(String[] args)
        Unit tests the data type.
        Parameters:
        args - the command-line arguments.