Elektrine lite

← Feed

@sminez@hachyderm.io

Post #2150501

2025-10-29 17:13 UTC

I've spent the last few days overhauling my structural regular expression engine that is inspired by @robpike 's 1987 paper (available here: http://doc.cat-v.org/bell_labs/structural_regexps/) and Sam/Acme editors. This time round I'm correctly handling the parallel execution side of things which is fun, but I'm also thinking about how to add a few extensions to the original system to address some of the issues called out in the paper. I know about the "Vis" editor, but other than that and my own "ad" does anyone know of implementations outside of plan9's Sam and Acme? I'm still surprised that this concept didn't catch on more as it's incredibly useful.

Replies (3)

  • @sminez@hachyderm.io 2025-10-29 20:08

    The in-progress PR for the rewrite is here: https://github.com/sminez/ad/pull/156 I need to add a _lot_ more tests and sort out the error reporting but for now its a decent start I think. Ideally I'd like to be able to run "structex" scripts from the command line over streaming inputs but I still have the same limitation that I think the original Sam / Sam helper scripts had which is that the full input needs to be read prior to execution which is...not ideal. You could avoid that if you got rid of the parallel execution semantics of groups but that's a _really_ nice feature of the engine that I'd like to keep, so maybe my hopes of ending up with the "awk of the future" as Rob originally proposed are a pipe dream?

    Open ##2280766

  • @sminez@hachyderm.io 2025-11-13 13:35

    OK, I now have a blog post up that attempts to explain what this structural regular expressions stuff is and why it can be a lot of fun to play around with https://www.sminez.dev/match-it-again-sam/ If you find the kinds of things being discussed in this thread interesting then you should give it a read and see what you think! #rust #rustlang

    Open ##2280769

  • @sminez@hachyderm.io @robpike@hachyderm.io I have a concept beyond structural editing, to that of a lexically typed file system. For a file to be accepted as more than just a byte stream, say as a GIF, it must be verified as conforming to the correct syntax. My pattern matching library can't yet handle arbitrary binary, but I have a plan for that, and I want it to be able to both match and generate arbitrary network protocols too. It uses PEG with no backtracking so doesn't need the Thompson parallelism

    Open ##2280781