JuliaSyntax.jl
JuliaSyntax.jl copied to clipboard
Diagnostics for string->value conversion
With #77, #80, and #81, the only remaining parsing errors are escape sequence errors like https://github.com/JuliaLang/JuliaSyntax.jl/issues/67.
Imho unescape_julia_string should never throw an exception. Instead, we should already check escape sequence validity when parsing (so that we can emit the correct diagnostics) and then emit ErrorVals during SyntaxNode construction.
https://github.com/JuliaLang/JuliaSyntax.jl/pull/83 handles part of this and makes unescape_julia_string non-throwing. Diagnostics still aren't emitted though.
we should already check escape sequence validity when parsing
This leads to processing all escapes twice which seems unfortunate. Also the same problem arises for numeric parsing (to detect overflow, for example).
I'd potentially favor doing this as a postprocessing pass over the token stream instead, maybe with a Diagnostics type separated off from ParseStream to collect any errors. This could be run during or prior to tree building:
- When producing
GreenNodeto get correct diagnostics (discarding any values) - When producing
SyntaxNodeto get both diagnostics and parsed values