3 ms·
My biggest beef is the lack of AST output generator after defining the TOKEN input parser for a lot of Open Source parsers. It pertains to counting duplicate n
by egberts1 5y ago
My biggest beef is the lack of AST output generator after defining the TOKEN input parser for a lot of Open Source parsers.
It pertains to counting duplicate nested blocks as well as enforcing 1+, 1:M and N:M combinatorial of syntax block.
I once did the entire ISC Bind9 named.conf parser into PyParsing (named is a handrolled parser, not a Bison/Flex).
But it cannot do N:M nor enforcing 1:M.
So, can TatSu help with that AST-output part?
- UncleEntity 5y agoYou 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 5y 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.