Class NFAtoDFA

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

public class NFAtoDFA extends Object
Converts a nondeterministic finite automaton to a deterministic finite automaton. Since NFAs and DFAs differ only in that an NFA allows multiple states at the same time, we can find each possible combination of simultaneous NFA states and give this combination a label. These labelled nodes are our DFA nodes, since we can only be in one such unique set of NFA states at a time.

As an NFA can end up in multiple accept states at the same time (for instance, the token "while" is valid for both WHILE and IDENTIFIER), we disambiguate by preferring the first matching regex (in terms of the order in which they were added to the NFA).

  • Field Details

  • Constructor Details

    • NFAtoDFA

      public NFAtoDFA(NFA NFA)
  • Method Details

    • convert

      @Nonnull public DFA convert()
      Returns a DFA created from the NFA.