Post #2150499
2025-11-10 12:45 UTC
So, I made a thing: https://github.com/sminez/structex
Structural regular expressions for Rust inspired by @robpike's 1987 paper that I was talking about a few weeks ago, but as a generic engine that you can
a) back by the regex engine of your choice
b) define what actions to apply to each match in your own code, rather than hard coding things in the engine
https://crates.io/crates/structex
As an example of how you can use this I put together a couple of hacky demos of what grep and sed look like with this setup:
https://github.com/sminez/structex/tree/main/examples/sgrep
https://github.com/sminez/structex/tree/main/examples/ssed
I've also just updated ad to replace its engine with the one from this crate 😄
I'm planning on writing a blog post about this over the next week or so when I have time so if this all seems completely bonkers / opaque then hopefully it'll make a little more sense there(!)
#rust #rustlang
Replies (1)
-
@lobre@mastodon.social 2025-11-10 21:50
@sminez@hachyderm.io @robpike@hachyderm.io Intriguing!!