4 ms·
Rather enjoyed flicking through that. I wish there was more of an overview for those of us who haven't thought about this stuff for a few years.
by aidos 11y ago
Rather enjoyed flicking through that. I wish there was more of an overview for those of us who haven't thought about this stuff for a few years.
- tptacek 11y agoI recommend: just read and reread, commenting it as you go, until it all makes sense. It's written in a very limited dialect of C --- most notably, it doesn't use structs --- because it compiles itself. The expression parser in particular would be clearer with structs rather than array offsets. But once you realize that's why it's so gnarly in places, it's straightforward to mentally translate. It's a very simple design: a simple lexer with a "pull" API (next()) feeds a precedence-climbing expression parser that spits out bytecode for a simple stack machine. If you grok expr(), you grok the whole thing.