Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error messages by antlr #17

Open
konnov opened this issue Nov 14, 2021 · 3 comments
Open

Improve error messages by antlr #17

konnov opened this issue Nov 14, 2021 · 3 comments
Assignees
Labels
effort-medium Can be completed within about 3 days error messages Collects issues steming from poor error messages impact-high High impact parser Quint parser usability Usability issues

Comments

@konnov
Copy link
Contributor

konnov commented Nov 14, 2021

The default messages by antlr are hardly readable:

examples/ReadersWriters/ReadersWriters.tnt:22:65 - error no viable alternative at input 'NumActorsdefToSet(s)=s.keys().map(i->s[i])defread(s)=s[1]=="read"defwrite(s)=s[1]=="write"valWaitingToRead=ToSet(waitingselectread)map(p->p._2)'
examples/ReadersWriters/ReadersWriters.tnt:22:57 - error extraneous input '->' expecting {'module', '{', '}', 'const', 'var', 'assume', 'type', 'import', 'val', 'def', 'pred', 'action', 'temporal', '(', '|', '[', '^', 'if', '&', STRING, BOOL, INT, 'and', 'or', 'iff', 'implies', 'subseteq', 'in', 'notin', '+', '-', '*', '/', '%', '>', '<', '>=', '<=', '!=', '==', '<-', IDENTIFIER}

For reference: syntax error, parsing, parser error

@konnov konnov added the tla+ transpilation Quint to TLA+ transpiler label Nov 14, 2021
@konnov konnov self-assigned this Nov 14, 2021
@konnov konnov added W5 usability Usability issues labels Nov 16, 2021
@konnov konnov added parser Quint parser and removed tla+ transpilation Quint to TLA+ transpiler labels Jul 15, 2022
@konnov konnov added effort-medium Can be completed within about 3 days impact-high High impact labels Nov 30, 2022
@konnov konnov added this to the Language design milestone Nov 30, 2022
@konnov konnov mentioned this issue Apr 1, 2023
34 tasks
@shonfeder
Copy link
Contributor

Here are some useful references:

The last seems very clean!

@konnov
Copy link
Contributor Author

konnov commented Oct 13, 2023

Having spent over two days on exploring the ways to improve error reporting with antlr4, I must say that I am close to giving up. I had a bit of success in #1221. However, it is still quite hard to figure out how to tell antlr4 to report reasonable errors about even trivially looking rules like declaration. Moreover, the interaction between syntax listeners, notifyErrorListeners, and BailErrorStrategy is quite tricky.

My conclusion is that we should use antlr4 for the happy path, that is, to produce an AST. The error explanation should be done via a different parser that is tuned to error explanation.

@konnov
Copy link
Contributor Author

konnov commented Oct 13, 2023

I have tried Peggy. It is producing nice error messages, but it does not have a real lexer. This makes error messages not so nice. There is also Ohmjs. Let's see how fast I hit its limitations.

@shonfeder shonfeder added the error messages Collects issues steming from poor error messages label Jan 9, 2024
@shonfeder shonfeder removed the W5 label Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort-medium Can be completed within about 3 days error messages Collects issues steming from poor error messages impact-high High impact parser Quint parser usability Usability issues
Projects
None yet
Development

No branches or pull requests

2 participants