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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new regular expression to the set of expressions matched by this automaton.intAdds a new state to the NFA, returning its index.get(int index) Gets a NFA state from its index.intMatches a string against all of the regexes added to this NFA.it.unimi.dsi.fastutil.ints.IntListreplace(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 theshadowstates.
-
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 theshadowstates. -
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.
-