Open Khhs167 opened 8 months ago
Can the parser recover from errors or does it just abort once an error has been found?
It keeps on going, aborting because of errors are up to the CLI/compiler interface
It would be bonkers to add a recovery system
What do you mean with recovery system?
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
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