Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


I 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.


Alight then, I will - though I may have to come back to you if I get stuck :) (I haven't written anything in C for about 15 years)





Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: