Hi Konrad, A somewhat similar issue is present in an XML grammar: the closing element must match the opening element. In PPXmlGrammar, you have a condition that matches it and throws a failure otherwise:
element "[39] element ::= EmptyElemTag | STag content ETag" ^ $< asParser , qualified , attributes , whitespace optional , ('/>' asParser / ($> asParser , content , [ :stream | stream position ] asParser , '</' asParser , qualified , whitespace optional , $> asParser)) ==> [ :nodes | nodes fifth = '/>' ifTrue: [ Array with: nodes second with: nodes third with: #() ] ifFalse: [ nodes second = nodes fifth fifth ifTrue: [ Array with: nodes second with: nodes third with: nodes fifth second ] ifFalse: [ PPFailure message: 'Expected </' , nodes second qualifiedName , '>' context: nil at: nodes fifth third ] ] ] Cheers, Doru > On Jan 27, 2019, at 4:38 PM, Konrad Hinsen <konrad.hin...@fastmail.net> wrote: > > Dear Tomo, > >> This post might help you. In case of PetitParser2, it's PP2Failure instead >> of PPFailure. >> https://stackoverflow.com/questions/15371334/how-can-a-petitparser-parse-rule-signal-an-error > > That's indeed a possible solution: parse for arbitrary operators, and then > add a test for equality that can make everything fail in the end. I will try > it out! > > Thanks, > Konrad. > > -- www.feenk.com "Not knowing how to do something is not an argument for how it cannot be done."