Tudor Girba <tu...@tudorgirba.com> writes: > But, does it solve your problem?
Not yet. Not sure it will. >> More generally, there seems to be a bug in how PetitParser handles >> PPFailure return values. The actually reported error is always different >> from what is passed to PPFailure. I love software ;-) > > What do you mean? If I return PPFailure message: 'whatever' at: 0 from my parser, then it does fail but it reports a different error. After some more experiments, it looks like this is perhaps not a bug, but a feature that makes returning failures not so useful after all. I suspect that PetitParser simply backtracks after my failure and tries a different rule that then fails as well. A simple example: | p | p := #digit asParser plus flatten ==> [ :value | value asSet size = 1 ifTrue: [ value ] ifFalse: [ PPFailure message: 'not equal' at: 0 ]]. p parse: '22233' The reported failure is "digit expected at 5". On the other hand, if there is no path for backtracking, the reported failure is the expected one: | p | p := (#digit asParser, #digit asParser) flatten ==> [ :value | value first = value second ifTrue: [ value ] ifFalse: [ PPFailure message: 'not equal' at: 0 ]]. p parse: '23' Konrad.