5 ms·
You want the parser generator library to automagically produce an AST and fill it in from the grammar description? Tree Sitter (I think) does that but (I belie
by UncleEntity 4y ago
You want the parser generator library to automagically produce an AST and fill it in from the grammar description?
Tree Sitter (I think) does that but (I believe) its output is a parse tree.
For the N:M stuff, if I understand you correctly, sounds like global value numbering could do that as, if I understand it correctly, it gives you subexpression deduplication for free. I think this is a tree transformation step though — haven’t really thought about it before but it could probably be implemented as the parser output but would be destructive as you’d lose line number information and whatnot.
Personally, for my playing around, I use asdl to generate the AST nodes because its a super-simple ‘language’ so I can easily test out new things. I’ve reimplemented it probably five or six times now but that definitely qualifies as yak shaving.
- egberts1 4y agoPrecisely on all counts that you’ve said. Yak shaving. Sigh. It is still a thing at the frontier of leading-edge technology. Will look at TreeSitter (again) and adsl. That reminds me, I’ve been relooking at things from time to time and need to do a summary recap on paper. Blog it, perhaps.