dxinteractive/xenpaper

Better parser errors

Closed this issue · 5 comments

As a beginner getting started, whatever you can do to make parse errors more specific would be a big help as people getting started (i.e. me) don't really understand when they're misusing the language.

Example:

(env:0158)0"-.....

Error: Unexpected token at 1:13.

The problem is that " goes before the note not after, but it took a while to figure out.

A possible different fix might be highlighting on specifically what the error is about; right now I think the line color changes a little bit but it isn't visually obvious what the problem is

Screen Shot 2021-05-24 at 10 36 57 AM

Have a look at this intentional error (emoji). The second line (not the problem) is red, drawing my eye.

Hi, perhaps I could colour the offending character rather than all subsequent characters? That should draw attention to the problem a bit more clearly.

As for the content of the error message itself, I can't really make it elaborate on what the cause of the error is because the rd-parse library I'm using doesn't give me anything more meaningful that the position of the incorrect character so it's outside of my control. All it knows is that the " wasn't expected in the position that it was found. Although I could always pull that character out so it reads something like Unexpected token " at 1:11?

highlighting just the error rather than everything after would help. Another possibility is that if the error is "Unexpected token" it might be possible to give an example in context of how that token is correctly used. For example if the token is " you might see:

Usage example:  "0

Or something like that.

That's a good idea too. It's tricky to do that for characters that change usage based on context, but with xenpaper they're pretty straight forward. Thanks for the suggestions!

Hi @moxious , I've partially fixed this one in 1.4.1 (see https://xenpaper.com/#0_2_4_!_8_10) , although there is more I want to do so I'll leave the ticket open.

I might split out the error parsing giving an example in context into a separate ticket. Closing this one.