4 ms·
This is completely contrary to my experience, in which parser generators have not paid for themselves. Writing a parser by hand in C is generally easier and les
by marssaxman 11y ago
This is completely contrary to my experience, in which parser generators have not paid for themselves. Writing a parser by hand in C is generally easier and less time-consuming over the long run than struggling along with a parser generator, especially if you have any interest in producing useful syntax error messages or recovering from other kinds of errors in some useful way.
I agree that almost none of the important aspects of language implementation involve the parser - and that's why I write 'em by hand! It doesn't take much time, and it's much easier to debug whatever problems you run into when you can use your ordinary debugging tools.
- xigency 11y agoI 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.