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.


Reply via email to