2 ms·
Many parts of this are clearly autogenerated, but that in no way diminishes the sickening impressiveness of it!
by dmitrygr 7mo ago
Many parts of this are clearly autogenerated, but that in no way diminishes the sickening impressiveness of it!
- phire 7mo agoIt does make it a little hard to understand how the parser/ast_builder works. But the rest seems easy enough to understand.
- fuhsnn 7mo ago> It does make it a little hard to understand Or much easier to backdoor...
- gaigalas 7mo agoThis is a hand-written parser for the shell itself (portable shell parsing portable shell): https://gist.github.com/alganet/23df53c567b8a0bf959ecbc7b68997c0 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.
- userbinator 7mo agoIt would be far more interesting to look at what this was "compiled" from; it looks like the output of a state-machine generator.
- gaigalas 7mo agoThe source for BNF generator is here: https://gist.github.com/alganet/4dfd501a3377a60f7825901114d65c77 https://gist.github.com/alganet/4dfd501a3377a60f7825901114d6... Roughly 70% of c89cc was generated from it (parser, emitter). It can generate parsers for C, ES6 and XML for example (subsets but not missing a lot). It's still a mess though and I have lots of work to do to a proper release.
- gaigalas 7mo agoYes! The main parser and emitter come from a BNF parser generator, also written in portable shell (to be released though).