New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Use new parser API #4
base: master
Are you sure you want to change the base?
Conversation
else | ||
string(chars[1], chars[2]^(width-2), chars[3]) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are probably aware but I'll mention there is printstyled(io, str, color=:underline)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's an interesting option - perhaps worth doing, especially for multi-line errors. We could use underline, red,bold or some other styling. (It's even an option to have syntax highlighting combined with error reporting - Tokenize + CSTParser gives us more than enough tooling for that.)
The thing which I find nice about the box chars is that they work in black and white, and they can be colored separately from the source code. But the need to format multi-line errors may override that consideration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can see in the screencast, I've tried in-situ highlighting in the latest version which is an easier option when the error spans multiple lines.
Hightlight errors in situ, rather that with separate text. This won't work well without ANSI highlighting.
These changes allow CSTParser to be connected up as the main Julia parser.
To use it, you currently need both a branch of the Julia runtime and of CSTParser:
Then run
FancyDiagnostics.enable!()
, and we can have errors such as:Dev notes
Early screenshot:
Note that the current implementation is pretty rough and diagnostic printing will still crash at the drop of a hat (I still need to understand how CSTParser uses ErrorToken a lot better and figure how to cleanly deal with offsets at EOF which are very common)
TODO:
Expr(:incomplete)