3 ms·
I wrote a parser-generator in C and it took less than 42 days. Your mileage may vary. https://github.com/gregtour/parsergenerator https://github.com/gregtour/p
by xigency 11y ago
I wrote a parser-generator in C and it took less than 42 days. Your mileage may vary.
https://github.com/gregtour/parsergenerator 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.
- rswier 11y agoMany years ago I played around with something called PRECC - A PREttier Compiler Compiler. I remember it was(is) pretty elegant. I wonder if anyone else has experience using it. http://preccx.sourceforge.net/ 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.