-
Notifications
You must be signed in to change notification settings - Fork 4
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
Error report enhancement #312
base: master
Are you sure you want to change the base?
Conversation
Another thing I'd like to point out is: isn't every error message a perfect diagonal line? What I mean is there are no instances where a CST node has errors in multiple of its children, we just bail as soon as we encounter one. If this is not expected to change, maybe we can ditch the tabulations increase in each successive child. Another, perhaps interesting and useful thing, may be to write the line number of every error. I am not sure about this one, but at least I can throw it out there. |
Yeah that's a fair point. Parsing errors are usually simple enough that you don't need tree-shaped errors. I designed ErrorReport with the possibility of a backtracking or error-correcting parser in mind (where tree-shaped errors make a lot of sense), but that's so hypothetical that it's not worth making the current error messages more complicated and uglier than they need to be. EDIT: On second thought, I kinda like how the indentation looks, but I think there are way too many levels that don't provide valuable information. Rather than removing the indentation, we should try to nest errors less deeply.
Yeah I totally agree (hence Keep the ideas coming! |
When a syntax error (or any kind of error, really) is found, we'd like to show the place in the file where it happened. These functions can be as inefficient as we like because, given that we exit right after, they run at most one time per run of the executable.
191595b
to
a95abdb
Compare
😎 😎 😎 😎 😎
|
We can, in the future, add colors to the output, presuming that all output goes to a terminal that accepts said color codes. Copying the error style of, say, gcc. May not be worth the effort tho. |
When compared with pretty much any other statically checked language, Jasper's errors are straight-up laughable. I intend to change that. To improve the situation, I'm building a bunch of utilities that will help generate nicer errors. In particular I thought that printing the line where the error happened, with a caret pointing at the exact token would be a great addition.
Supporting this change, I extended ErrorReport to store multiple lines of error messages per node.
I just stuffed all this in
parser.cpp
for now, but it probably deserves its own file.A little example: