logoalt Hacker News

phiretoday at 2:27 AM2 repliesview on HN

It does make it a little hard to understand how the parser/ast_builder works.

But the rest seems easy enough to understand.


Replies

fuhsnntoday at 3:21 AM

> It does make it a little hard to understand

Or much easier to backdoor...

gaigalastoday at 7:00 AM

This is a hand-written parser for the shell itself (portable shell parsing portable shell):

https://gist.github.com/alganet/23df53c567b8a0bf959ecbc7b689...

It's an incomplete idea from around a year ago. The approach taken here (aliases as macro-like evals, AST generation using shell variables) became the backbone for the BNF parser generator.

This one is much simpler to understand. Simpler grammars tend to produce parser code that looks more like this one.