Sean A supplementary point I have just realised. The basic 'and' idea is correct, but my example is over-simplified. As written, it will reject any string beginning with 'Bar' or 'Baz'. If you use this pattern, you will need to be careful how you define the exclusion.
Peter -----Original Message----- From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of PBKResearch Sent: 06 August 2017 13:28 To: 'Any question about pharo is welcome' <pharo-users@lists.pharo.org> Subject: Re: [Pharo-users] PetitParser: Parse X as long as it's not Y Sean This seems to be what the PPAndParser is designed for. I tried the following: identifier := #letter asParser plus flatten. exclusion := ('Bar' asParser / 'Baz' asParser) negate. restricted := identifier and, exclusion. restricted matches: 'abc'. "--> true" restricted matches: 'Baz'. "--> false" (Note the comma after 'and' is necessary - this wasted me a few minutes in trying.) Hope this helps Peter Kenny -----Original Message----- From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of Sean P. DeNigris Sent: 05 August 2017 21:26 To: pharo-users@lists.pharo.org Subject: [Pharo-users] PetitParser: Parse X as long as it's not Y How do I tell Petit Parser to parse a string of certain allowable characters as long as the final result isn't a particular string? E.g. consume an identifier as long as it's not 'Baz' or 'Bar' Thanks ----- Cheers, Sean -- View this message in context: http://forum.world.st/PetitParser-Parse-X-as-long-as-it-s-not-Y-tp4958895.ht ml Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.