4 ms·
Just about all parser generators allow for custom error so this one does too. "Hand written parsers have better errors" is just an internet meme, not the actual
by sanxiyn 4y ago
Just about all parser generators allow for custom error so this one does too. "Hand written parsers have better errors" is just an internet meme, not the actual state of the technology.
- bsder 4y agoIs this really a meme? If so, I'd like a counterexample of a compiler that people regard as having actively good error messages that uses a parser generator. It seems like all the compilers I know of got much better errors when they switched to a fully custom generated intermediate language rather than one from a parser generator.
- duped 4y ago...so users write specific rules in their grammars for error cases and then add custom error messages? The actual state of the technology are tools like tree sitter, which doesn't generate an abstract syntax tree like this one does. I've written many parsers in my life. They're almost exclusively recursive descent because a generated parser is inferior in many, many ways. A lot of parser generators miss the forest for the trees - lexers are usually trivial to write and a hand rolled recursive descent parser takes about a day (and lets you handle precedence in a sane way that can be extensible!) - usually for better performance, easier maintainability, and good error handling. What's super hard to do is an incremental query oriented parser and compiler with a concrete syntax tree that doesn't use ungodly amounts of memory and has bad performance. Generative tools for that architecture are few and far between but much more useful than lex/yacc alternative.