dimfeld / lezer-json5

MIT License
4 stars 2 forks source link

Adding human-readable error messages #1

Open wylieconlon opened 2 years ago

wylieconlon commented 2 years ago

I've been finding it difficult to figure out how to get proper error messages from a parser implemented with lezer. I noticed that you've included the standard JSON5 test suite, but it seems like this parser doesn't generate the same errors as the regular JSON5 parser.

For example, most of the time this parser throws errors like SyntaxError: No parse at 34 instead of:

SyntaxError: JSON5: invalid character '\"' at 1:35 SyntaxError: Unexpected string in JSON at position 34

Also, because lezer is an error-tolerant parser it would be ideal if we could get human-readable messages without needing strict mode.

I'm not sure if these requests are possible, what do you think?

dimfeld commented 2 years ago

It definitely could be better. I don't have any time to look into it for now but if you come up with something I'd love to integrate some improvements.