C.java:2: error: ’;’ expected
int x y;
^
C.java:2: error: <identifier> expected
int x y;
^
This is a common problem, but the solution here for the example shown is for the parser not to attempt to recover that statement and ignore everything until it reaches the "synchronization point" (I call them "landmarks"), which sounds like what their were arguing for at first. Doing that would make the AST be marked with a node along the lines of "some int named x with errors", and would completely skip everything between the `x` and the `;`. Because an error has been reported, there will be no output binary, but the second error will not be emitted.Beyond the parser, the AST needs to keep around a lot of extra information for error recovery that would otherwise not be needed. An example from rustc[1] (what I'm familiar with) is structs and struct variants that have had some parse error. We recover the parse and keep a node for the variant in the AST signaling the existence of a parse error, which means that later passes of the compiler can type and borrow check, but if it finds a use that is either missing or adding fields we do not emit an error for it[2][3] under the assumption that the parse error caused the field being used to not be captured in the AST node for the variant. This can have quite dramatic impact on the quantity of errors being emitted.
[1]: https://github.com/rust-lang/rust/blob/7e11379f3b4c376fbb9a6...
[2]: https://github.com/rust-lang/rust/blob/7e11379f3b4c376fbb9a6...
[3]: https://github.com/rust-lang/rust/blob/7e11379f3b4c376fbb9a6...