hawkw / decaf

like Java, but less so
hawkweisman.me/decaf
Other
18 stars 4 forks source link

Prettyprint errors #36

Closed ArcticLight closed 10 years ago

ArcticLight commented 10 years ago

We need to implement a prettyprinter for our errors that prints things with the program line, location, and carrots underlining the specific offending lines.

The Scala standard lib does this for its error reporting when you throw errors during a parse, so presumably there exists code that does the correct printing. Therefore, we should look for this code and see if we can make it work in our typechecker.

hawkw commented 10 years ago

This appears to be the answer - it looks like the Position.longString method is what we want. Too tired to actually write the method atm though.

ArcticLight commented 10 years ago

That looks exactly right to me.

hawkw commented 10 years ago

Getting it to caret underline the whole token is actually gonna be Hard - we need to somehow pass the offset up all the way from the DecafToken to the ASTNode to the TypeAnnotation which is gonna be a pain.

ArcticLight commented 10 years ago

Does it really really matter about the full offset? By that I mean, we indicate the position with a good amount of clarity. If JJ doesn't like the way that we do it, then yeah, we might have to put more carets under the phrase in question. But - if this is just about underlining the specific DecafToken, it really shouldn't matter all that much. You could just repeat the caret for the number of characters in the token's text. We should only actually need the full offset IF we were required to underline the complete expression, etc

hawkw commented 10 years ago

This should be closable as of 385196