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

[BUG] Fix Error Reporting #4

Open
Khhs167 opened this issue Feb 19, 2024 · 5 comments
Open

[BUG] Fix Error Reporting #4

Khhs167 opened this issue Feb 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Khhs167
Copy link
Member

Khhs167 commented Feb 19, 2024

As of right now, a lot of errors are double-reported within the parser code, and should ideally be resolved as soon as possible(most likely via function return codes)

It isn't of top priority, and can be fixed once the compiler is working

@Khhs167 Khhs167 added the bug Something isn't working label Feb 19, 2024
@mauro-balades
Copy link
Member

Can the parser recover from errors or does it just abort once an error has been found?

@Khhs167
Copy link
Member Author

Khhs167 commented Feb 21, 2024

It keeps on going, aborting because of errors are up to the CLI/compiler interface

@mauro-balades
Copy link
Member

It would be bonkers to add a recovery system

@Khhs167
Copy link
Member Author

Khhs167 commented Feb 24, 2024

What do you mean with recovery system?

@mauro-balades
Copy link
Member

mauro-balades commented Feb 24, 2024

a system where the parser can recover towards a valid grammar state.
For example, when parsing function declarations:

// When parsing arguments, we need to have "identifier ':' type"
// parse the identifier, if we fail to do that, skip till we find a ')'
recovered_expect(TokenType::Identifier, "an identifier", TokenType::OpenParen);

This will allow multiple errors to be reported by the parser:

function a(???: int) {
   var a = ???;
}
error(1): Unexpected `???` while parsing function arguments
error(2): Expected a valid expression but found `???` while declaring a variable

rect has exited with 2 errors and 0 warnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants