Closed kfsone closed 4 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:![image](https://github.com/yhirose/cpp-peglib/assets/323009/df57c7f4-dbb7-4f55-b105-ebac99188403)
But if I use a production in whitespace (which I do for comments), suddenly it tells the user it was expecting a space:![image](https://github.com/yhirose/cpp-peglib/assets/323009/56b2997b-1086-45fd-a902-f2ca4d968185)
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:![image](https://github.com/yhirose/cpp-peglib/assets/323009/d550d28f-5b69-4afb-84d3-7ac8c78c2e6b)
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:![image](https://github.com/yhirose/cpp-peglib/assets/323009/7be31286-ceb5-4b7d-b538-c2dc9809a66e)
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?