This is a simple (and presumably very slow) compiler of regular expressions. It supports minimal numbers of regex operators: ?, *, +, |
.
make
./comp "input string" "regex"
(ex:./comp "abcabcabc" "(abc)*"
)
The transformation from the regex to the nondeterministic finite automaton with ε-moves is based on the Thompson algorithm, the details of which are clearly explained in this article by Russ Cox.
The implementation of the parser and tokenizer mimics the one used in the early version of chibicc by Rui Ueyama.