Module nfa

Provides non-deterministic finite automata (NFA) and regex engines that use them.

While NFAs and DFAs (deterministic finite automata) have equivalent theoretical power, their usage in practice tends to result in different engineering trade offs. While this isn't meant to be a comprehensive treatment of the topic, here are a few key trade offs that are, at minimum, true for this crate:

There are likely other differences, but the bottom line is that NFAs tend to be more memory efficient and give easier opportunities for increasing expressive power, where as DFAs are faster to search with.

Why only a Thompson NFA?

Currently, the only kind of NFA we support in this crate is a Thompson NFA. This refers to a specific construction algorithm that takes the syntax of a regex pattern and converts it to an NFA. Specifically, it makes gratuitous use of epsilon transitions in order to keep its structure simple. In exchange, its construction time is linear in the size of the regex. A Thompson NFA also makes the guarantee that given any state and a character in a haystack, there is at most one transition defined for it. (Although there may be many epsilon transitions.)

It possible that other types of NFAs will be added in the future, such as a Glushkov NFA. But currently, this crate only provides a Thompson NFA.

Modules