Class NFA

java.lang.Object
icyllis.arc3d.compiler.lex.NFA

public class NFA extends Object
A nondeterministic finite automaton for matching regular expressions. The NFA is initialized with a number of regular expressions, and then matches a string against all of them simultaneously.
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    NFA()
     
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    int
    add(NFAState state)
    Adds a new state to the NFA, returning its index.
    void
    add(RegexNode node)
    Adds a new regular expression to the set of expressions matched by this automaton.
    get(int index)
    Gets a NFA state from its index.
    int
    Matches a string against all of the regexes added to this NFA.
    it.unimi.dsi.fastutil.ints.IntList
    replace(int index, it.unimi.dsi.fastutil.ints.IntList shadow)
    When we transition to the NFA state which is given by index, we instead transition to all of the shadow states.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

    • NFA Link icon

      public NFA()
  • Method Details Link icon

    • add Link icon

      public void add(@Nonnull RegexNode node)
      Adds a new regular expression to the set of expressions matched by this automaton.
    • add Link icon

      public int add(NFAState state)
      Adds a new state to the NFA, returning its index.
    • get Link icon

      public NFAState get(int index)
      Gets a NFA state from its index.
    • replace Link icon

      public it.unimi.dsi.fastutil.ints.IntList replace(int index, it.unimi.dsi.fastutil.ints.IntList shadow)
      When we transition to the NFA state which is given by index, we instead transition to all of the shadow states.
    • match Link icon

      public int match(@Nonnull String s)
      Matches a string against all of the regexes added to this NFA. Returns the index of the first (in addRegex order) matching expression, or -1 if no match. This is relatively slow and used only for debugging purposes; the NFA should be converted to a DFA before actual use.