Parser and engine for Regular Expressions
This project is a hand-written implementation of a Regular Expression engine. It works in two parts: first the regular expression is parsed into an Abstract Syntax Tree by a recursive-descent parser. Then, the AST is traversed bottom-up to generate the Non-Finite Deterministic Automata (NFA) using Thompton's algorithm. This construction generates an NFA with very nice properties that help us decide if an input belongs to the language or not.
Below you can try the engine yourself. First, define your regular expression and then, write an input to see if it matches or not. The syntax is the same as in formal language theory. You can find examples here or in the Compilers: Principles and Techniques book [1].
Type a pattern and input string above.
References
- A. V. Aho, M. S. Lam, R. Sethi, and J. D. Ullman, Compilers: Principles, Techniques, and Tools, 2nd ed. Boston, MA: Addison-Wesley, 2006.
- R. Cox, "Regular Expression Matching Can Be Simple and Fast," Jan. 2007. [Online]. Available: https://swtch.com/~rsc/regexp/regexp1.html