Re:Show HN: How to write a recursive descent parser
by marcosdumay on Monday March 20, 2017 @11:29AM
(#13914971)
What are those "good error messages" in the parsing stage you keep talking about?
I don't remember I've ever used a language that reported anything different from "syntax error at line X" at this stage.
Re:Show HN: How to write a recursive descent parser
by btilly on Monday March 20, 2017 @11:59AM
(#13915224)
As a random example from Perl, Unmatched ( in regex... is the error when you open a capturing group in a regex and fail to close it.
In a recursive descent parser, this type of error is very easy to generate because working top down you know what you are in the middle of trying to do when you hit the error. But a bottom up parser lacks that context - it just knows where it was when it got stuck.
Re:Show HN: How to write a recursive descent parser
by megous on Monday March 20, 2017 @11:43AM
(#13915112)
You can get a parser generator to automagically list you expected (non-)terminals at this point. It may not be helpful though, depending on the location of the error. But it is something at least.
Is there such a thing as a "good parser generator" where "good" includes "generates at least decent error messages"?
> Personal opinion: writing parsers is the least interesting part of an interpreter/compiler, and your grammar should be boring if you want your syntax to be easy to understand by humans.
Hardly. Humans have way less trouble with ambiguity than computers do, as demonstrated by, well, the entire history of programming languages. If syntactic simplicity and regularity were what humans seeked, the primary languages in use would be Lisps, Forths and Smalltalks, not C derivatives.