Class NFA<T extends Comparable<T>>

java.lang.Object
org.openzen.zenscript.lexer.NFA<T>
Type Parameters:
T - final state type (for a TokenStream, a TokenType)

public class NFA<T extends Comparable<T>> extends Object
Represents an NFA. NFAs can be compiled from a list of regular expressions.
  • Field Details

  • Constructor Details

    • NFA

      public NFA(List<String> regexp, List<T> finals, Class<T> tokenClass)
      Converts a list of regular expressions to an NFA. Each regular expression can have its own final class. The length of both arrays must match.
      Parameters:
      regexp - regular expression array
      finals - final classes
  • Method Details

    • toDFA

      public DFA<T> toDFA()
      Converts this NFA to a DFA. The resulting DFA is not optimal. If the NFA is ambiguous, the token with lowest value will receive preference.
      Returns:
      this NFA as DFA
    • compile

      public CompiledDFA<T> compile()
      Converts the NFA to a DFA and optimizes and compiles it into an efficient format.
      Returns:
      compiled DFA