sregx icon indicating copy to clipboard operation
sregx copied to clipboard

Structural PEGs

Open lobre opened this issue 1 year ago • 2 comments

Loving so far all the explorations you have around parsing and manipulating structured text! Thanks a lot for documenting and open-sourcing all of that.

I see in the "Future Work" section of the README that you mention "Structural PEGs". I have to say that I am intrigued, as I have recently dug a lot around "simple" text editors with great leverage (small footprint, restricted set of features for a lot of power). I have come across kakoune and vis and discovered structural regular expressions. Then I also spent time discovering Rob Pike's editors acme and sam. They are by nature following this philosophy of bringing a lot while staying simple.

And I am currently exploring what could be a more interactive version of sam. Vis is a great take, but it "just" mixes two different concepts: vim-like operations (motions/text objects) and structural regex. But I don't find them especially integrated with each other. Ideally, there should be only one language for describing a selection/change in the structure of a file, for both small ad-hoc changes or more complex "sam-like" operations. Kakoune does a better job of unifying both interfaces.

I recently stumbled upon a comment on the kakoune forum from @Screwtapello where he describes what an editor could be if the concepts of selection/extraction were a little bit nicer than regex in terms of interface while staying minimalist and hackable.

I definitely think the next killer feature of Vi-lineage editing will be structural knowledge, but I think it needs to be more like writing a regex or a Kakoune syntax highlighter than writing “real” code. I’d like to tell my editor that comment = "//" not("\n")* and then anywhere I write a regex I can write $comment to mean “text spans tagged as comments”.

Some people mention PEG afterwards.

I don't know what you have in mind with "structural pegs", but it seems it could correlate with this philosophy. That would be great if you could describe what it means to you, and how it could apply to a tool like sregx. As it seems you spent a lot of time in that space, I am sure that your take on "what could be a structural pegs editor compared to a structural regex editor" would be very valuable.

lobre avatar Nov 06 '23 11:11 lobre