Package icyllis.arc3d.compiler.lex
Class NFA
java.lang.Object
icyllis.arc3d.compiler.lex.NFA
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
-
Method Summary
Modifier and TypeMethodDescriptionint
Adds a new state to the NFA, returning its index.void
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 byindex
, we instead transition to all of theshadow
states.
-
Constructor Details
-
NFA
public NFA()
-
-
Method Details
-
add
Adds a new regular expression to the set of expressions matched by this automaton. -
add
Adds a new state to the NFA, returning its index. -
get
Gets a NFA state from its index. -
replace
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 byindex
, we instead transition to all of theshadow
states. -
match
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.
-