3 ms·
> easier to recover from input syntax errors from the Token-based input rather than Unicode-based input Rust has pretty exact mapping from syntax errors to lex
by vlovich123 4y ago
> easier to recover from input syntax errors from the Token-based input rather than Unicode-based input
Rust has pretty exact mapping from syntax errors to lexical placement. Couldn't a similar approach be used if you have a potential recovery path?
- Eliah_Lakhin 4y agoI think it depends on how the recovery path is made. During the lexical scanning stage you can persist the token's source code sites, and later reuse them to indicate syntax or similar errors. For example, in Rust when you parse the syntax from the TokenStream of a procedural macro input, you can bind custom errors to any spans of input tokens, and it works just fine.