This seems to be what the PPAndParser is designed for. I tried the
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
Hope this helps
From: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] On Behalf Of
Sean P. DeNigris
Sent: 05 August 2017 21:26
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'
View this message in context:
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.