| Related articles |
|---|
| Announce: Pyre - A Regular Expression Engine Based on Brzozowski Derivatives clint.olsen@gmail.com (Clint Olsen) (2026-02-08) |
| From: | Clint Olsen <clint.olsen@gmail.com> |
| Newsgroups: | comp.compilers |
| Date: | Sun, 08 Feb 2026 00:58:52 +0000 |
| Organization: | Compilers Central |
| Injection-Info: | gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="59444"; mail-complaints-to="abuse@iecc.com" |
| Keywords: | available, DFA |
| Posted-Date: | 07 Feb 2026 20:40:09 EST |
After working intermittenly on this project for several years, I was
finally able to get it in a state where it's worth sharing. Some of you may
remember me posting about regular expressions and DFA generation here some
time ago.
https://github.com/clintolsen/pyre
Pyre is a Python implementation of a regular-expression engine built using
Brzozowski derivatives. Unlike traditional engines that first translate the
expression into an NFA and then to a DFA, a derivative-based engine
constructs the DFA directly from the expression by repeatedly applying
derivative rules. This also allows novel set operations like language
complement `~RE` and intersection `RE & RE` in an efficient manner. Because
matching is performed on the resulting DFA, the recognizer runs in linear
time and does not require backtracking.
The project includes:
- A lexer and parser written in PLY
- A full AST of regular-expression operators
- DFA construction using derivatives
- Capture-group support
- match() and search() APIs
- A command-line interface called pyre
I got interested in interpreters and translators during an internship at
Intel working on a test pattern generator for IEEE 1149.1 compliant test
access ports. The tool was written using lex & yacc, and I had John's
O'Reilly book as my guide. Since then I've been fascinated with this topic.
Thanks to everyone who participated in the discussions helping me with
pyre.
-Clint
Return to the
comp.compilers page.
Search the
comp.compilers archives again.