You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First let me say thanks to all contributors for your great work.
Pigeon has been a great tool and many times have I found myself appreciating the crystal clear documentation!
However, I might have a request.
Request
I'm working on a project where I'm trying to use go constants for input matching in pigeon.
For example:
I'm trying to avoid having to repeat all the go definitions in pigeon, so I match liberally on the regex and then narrow it down within the predicate code block.
This works like a charm for parsing valid inputs and correctly returns errors on invalid inputs.
However, the suggestions made in the expected field of the parserError are purely based on the regex and I cannot modify these suggestions through the predicate code block. Since the predicate block is more restrictive than the regex, I'd like to be able to return custom suggestions.
What I tried
I have tried to return errors from the predicate code block, but this does not have the same effect (when returning false, err, the resulting errors of Parse(...) still contains the regex suggestion in the expected block and the predicate block must return false to allow potential subsequent rules to try and match the input).
I have also tried using the labeled failures, but find them hard to work with in more complicated grammar scenarios with many rules.
Conclusion
Since the predicate and regex both affect the outcome of an attempted match, I thought it might be sensible to provide more control in the predicate code block such that it can return its own suggestions in the expected field of a parserError.
Thanks for your detailed issue report. My initial reflex was to suggest labeled failures for your case, but I understand, that you have already tried those and you found it hard to work with them. I guess you have already consulted the provided examples as well.
In regards to you proposal, the issue is, that this is not backwards compatible. In order to consider a change to the way predicate code blocks work, we would need to find an API, that is backwards compatible with existing grammars.
First things first
First let me say thanks to all contributors for your great work.
Pigeon has been a great tool and many times have I found myself appreciating the crystal clear documentation!
However, I might have a request.
Request
I'm working on a project where I'm trying to use go constants for input matching in pigeon.
For example:
I'm trying to avoid having to repeat all the go definitions in pigeon, so I match liberally on the regex and then narrow it down within the predicate code block.
This works like a charm for parsing valid inputs and correctly returns errors on invalid inputs.
However, the suggestions made in the
expected
field of theparserError
are purely based on the regex and I cannot modify these suggestions through the predicate code block. Since the predicate block is more restrictive than the regex, I'd like to be able to return custom suggestions.What I tried
I have tried to return errors from the predicate code block, but this does not have the same effect (when returning
false, err
, the resulting errors ofParse(...)
still contains the regex suggestion in theexpected
block and the predicate block must returnfalse
to allow potential subsequent rules to try and match the input).I have also tried using the labeled failures, but find them hard to work with in more complicated grammar scenarios with many rules.
Conclusion
Since the predicate and regex both affect the outcome of an attempted match, I thought it might be sensible to provide more control in the predicate code block such that it can return its own suggestions in the
expected
field of aparserError
.For example:
The text was updated successfully, but these errors were encountered: