by xigency · 10y ago · 0 comments
https://github.com/gregtour/parsergenerator
Most of the C code is less than 1.5k LOC for the functional part, and this minimal, self-compiling C compiler has a parser that is nearly 3,000 lines long.
Even if it took 1,000 lines of extra code for the non-LR aspects of C's grammar, I think it would be the same amount of work.
This just leaves you in a better position to write a C++, Go, or Java compiler at the end.
http://preccx.sourceforge.net/
This was long before I discovered the simple joys of squeezing out unnecessary CPU cycles from my own hand-rolled self-directed lexer/parsers.