EmberRegex: Compile Time Optimized Regex

I have posted about this in the past, but I figured it was time to give an update in hopes of getting some eyes on this and feedback.

Inspired by this article The Impossible Optimization, and the Metaprogramming To Achieve It, I’ve had Claude progressively chip away at implementing a deeply optimized regex library that is built entirely at compile time.

The current state of the library features several different engines that are dynamically selected based on the features of the given pattern. Including support for multi-pattern matching. Inspired by the hyperscan library. Though admittedly severely limited in the number of patterns you can use at once due to exploding compile times in the current implementation.

var re = Regex["cat|dog"]()
var multi = RegextSet[["cat", "dog", "rabbit"]]()

With my current set of benchmarks, it beats pcre2 on nearly all cases, and splits with hyperscan about 50/50.

This is awesome @bgreni! Have you run it against the hyperscan or pcre test suites to see how complete the implementations are?

No I haven’t actually. I don’t think doing all of them wholesale would be effective since they might disagree on some semantics (like leftmost match priority vs longest match) but I could see if there are any in either project that my current test suite doesn’t cover!