dabeaz / sly

Sly Lex Yacc
Other
817 stars 108 forks source link

Feature idea: better error messages for yacc #28

Open Akuli opened 5 years ago

Akuli commented 5 years ago

Currently the only error information I can report to the user of my compiler from a sly.Parser is "invalid syntax at this line and this column in this file". That's not as good as it could be IMO. Before using sly I had a hand-written parser, and its error messages were way better than "syntax error", as in "trailing comma not allowed in argument list" or "you can't do a == b == c, you need to do a == b and b == c instead".

Even though parser generators can't give very good error messages compared to hand-written parsers, some kind of error messages other than calling everything "syntax error" would be nice. For example, I would guess that it's easy to implement some kind of error message handling for a == b == c when there is precedence = (..., ('nonassoc', EQ), ...) in the sly.Parser subclass.