lark
lark copied to clipboard
Show values of terminals in errors, instead of names, when appropriate
So, first thing would be to define "apropiate" .
Something like :
- If terminal comes from a simple string and string length is less than some integer, except from debug mode in that case show full string
- If terminal comes from union of strings and total length less than some int... same a before.
- If terminal comes from anon regex it would be great to show them in debug mode or at least show them as
anon_regex_n - if terminal is an anon mix strings and regex show something like
anon_mix_n
Is there other kinds of terminals?
Even when not in debug mode, /[A-Z]+\-\d+/ is still more informative than __ANON_17. But if you stick with ANON, then can we get them numbered by their line and column in the grammar? So __ANON_17 would be __ANON_L45_C23 or similar. Actually, that labeling scheme for anonymous terminals is probably a good idea regardless of what we do with error messages.
@charles-esterbrook That's a nice idea!
Is someone working on this right now? Otherwise I will give it a try.
Go ahead. I didn't get started yet, and I don't think anyone else did.