Support emitting multiple parser errors
Chriscbr opened this issue · 2 comments
Hi there!
I tried writing some code in the playground that had multiple parsing errors, but only the last error was surfaced to me:
// https://kaleidawave.github.io/ezno/playground/?id=32i0hs
let a =
let b =
if true {
}
// Expected OpenParentheses found Keyword(True)
I was wondering if error recovery and trying to surface multiple parser errors is something in scope for the project or not.
Since the project's focus is on static analysis and runtime performance, I imagine the friendliness of parsing errors might be more of a backlog thing (especially given that any error recovery mechanism is a best guess). But I figured I'd ask anyway since surfacing more errors can sometimes improve the live coding experience with a compiler.
Feel free to close if this issue isn't relevant. Thanks again for working on this project!
Awesome, thanks for trying it out.
Yes in January I merged a PR (can't find it now) which under a partial_syntax
option allowed certain sections (like the expression for let a =
to be skipped. This builds a valid AST so that you can still do type checking in the playground or LSP. It currently doesn't report anything about it though which could be improved in the future.
At the moment it doesn't account for parser errors though. Like the missing parenthesis around the if statement (which I always forget when I go from Rust -> JS).
I will have a look more places where under partial_syntax
it can skip things. Missing {[(
can be hard to retain though.
N.B. I think I remember mention that red-green trees are effective for parsing partially valid text?
https://willspeak.me/2021/11/24/red-green-syntax-trees-an-overview.html