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 parser errors #113

Open
jfecher opened this issue Jun 23, 2022 · 2 comments
Open

Improve parser errors #113

jfecher opened this issue Jun 23, 2022 · 2 comments
Labels
good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement

Comments

@jfecher
Copy link
Owner

jfecher commented Jun 23, 2022

They are awful.

To elaborate, currently the parser will usually issue an error in the form "failed trying to parse a [foo]" where [foo] may be term, expression, pattern, etc. Sometimes it will give even worse errors resembling "parser expected end of input, but got ..." which does not explain well what the user did that was wrong. The parser also stops after 1 error currently. A recoverable parser is desirable such that parsing never actually fails. Instead expressions that fail to parse should either be left out or replaced with a new Ast::Error construct so we can continue to name resolution and type checking. This greatly helps IDE support since most of the time when a user is typing code there will be parse errors and we don't want that to cause other type errors to no longer appear. To recover from a statement/expression that failed to parse, the parser can skip to the next Newline token.

This is a larger change, but I'm marking it as a good first issue because the parser is early enough in the compiler that you don't have to learn about earlier passes first.

To summarize, there are a few issues here that should probably be addressed separately:

  • Improve quality of parser error messages
  • Make parser recoverable
  • Make parser infallible, and update name resolution and type checking to operate on Error terms.
@jfecher jfecher added the good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement label Jun 23, 2022
@ArbilGit
Copy link
Contributor

Are you set on implementing the parser from scratch? We'd get a lot of stuff for free (I think, haven't tested) by using say Chumsky

@jfecher
Copy link
Owner Author

jfecher commented Jun 24, 2022

I'm not set on the current parser and we can replace it if beneficial. That being said I've used chumsky and while it would give us some of these things it is not a silver bullet and would still be a large effort to setup, use, and maintain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement
Projects
None yet
Development

No branches or pull requests

2 participants