News for hackers. Stuff that matters.
Re:Teaching Compilers Backward by todd8 on Tuesday February 23, 2021 @01:21PM (#26240698)
After working with real-world compilers in industry I was surprised to hear CS professors that taught the compiler class say that no one should be writing parsers by hand because compiler writers should just build a table driven parser using YACC.

The error messages are so much better coming out of recursive descent parsers. (I know that there are all sorts of mechanisms for better error messages, but back when I heard this statement there was nothing that really worked well. Does any compiler with good error messages today really use LR parsing?)

Re:Teaching Compilers Backward by PartiallyTyped on Tuesday February 23, 2021 @02:50PM (#26241996)
A professor in gradschool insisted on us writing hand-written parsers to better understand associativity, operant ordering and so on and identify useful patterns, then implementing ASTs and interpreters directly ontop of the parsers. It was a tough class, but to be honest it was one of the most fun ones as well.

In undergrad, I asked the professor assigned the compilers class whether he would offer it during fall, but he said that unless he managed to completely revamp the class into more real-world and practical stuff like using LLVM backend instead of wasting time on parsers like in the dragon book and the tiger book, he wouldnt offer it.

Re:Teaching Compilers Backward by hctaw on Tuesday February 23, 2021 @01:38PM (#26240975)
This has been my experience as well, but I'd extend it to parsing in production. There are a million reasons why you need to write custom parsing code and 99% of them are faster and better implemented by hand than using a generator.
Re:Teaching Compilers Backward by CalChris on Tuesday February 23, 2021 @04:51PM (#26243366)
Moreover, buggy parsing code is massive security hole.
Re:Teaching Compilers Backward by hctaw on Tuesday February 23, 2021 @06:19PM (#26244393)
well anything that takes untrusted input that might need to be validated with parsing is a massive security hole. Parsing generators don't fix this class of bug, they just change how it manifests.
Re:Teaching Compilers Backward by tester756 on Tuesday February 23, 2021 @05:02PM (#26243492)
why?
Re:Teaching Compilers Backward by not2b on Tuesday February 23, 2021 @03:44PM (#26242630)
gcc ripped out its bison-generated parsers in favor of recursive descent parsers long ago, for exactly this reason (also, because C++ isn't LR-n for any n, so to get bison to work as well a third pass called "spew" sat between the lexer and the Bison parser so it could do arbitrary lookahead to figure out what the tokens were).