Closed kfsone closed 7 months ago
@kfsone by the way, could you split this issue to separate issues? It's pretty hard for me to follow...
One issue at a time. :)
It's one issue, the extra information is to show what I tried that also didn't work
I see - I need the <>
s around the field/value regex, but the main fix is to prefix the space token with _
? I couldn't find a description of _
in the README, what does it do?
@kfsone, yes, rules which start with _
won't show up in error messages. I forgot to specify it in the README... I'll update the README.
Excellent - thank you - I can close this, you've already tackled the issue :)
I've been trying to improve the quality of errors reported by some of my earlier peglib grammars, but when I simplified the grammars the error messaging changed, eventually I realized that peglib is currently somewhat variable about what it selects to report as expecting.
given the input
{{1}}
or{{a=1,2}}
I get various different errors depending on what is commented in/outClosest to what I expect:
But if I use a production in whitespace (which I do for comments), suddenly it tells the user it was expecting a space:
Simple whitespace again but without unit, it now gives me an accurate report, but not the one I was expecting: (I expected the error to be that it was expecting
<Object>
)I suspect something else is also going wrong here, because the %whitespace change doesn't affect this 3rd case:
but at the same time, I get a low-quality error from the second match case: (it should be expecting
<ObjectMember>, '}'
)whereas the original combination gives me excessive expectations:
and this slight variation (introducing an extra component from the original grammar) confuses me the most:
The first '{' could be either Unit, Array, or Object. the next token, '{' eliminates unit and Object, only array allows '{' next. So surely when it reaches the 1 it is expecting either '}' or ObjectMember->Field?