In PetitParser2, how do I match a closed set of tokens, like month names? E.g. (in pseudocode)
[ :word | MonthNames anySatisfy: [ :mn | mn beginsWith: word ] ] asParser.
PPPredicateSequenceParser
seemed like a possibility, but it seems you have to know the string size in advance. I guess I could just do something like:
| monthRules |
monthRules := Array streamContents: [ :unamused: |
MonthNames collect: [ :e |
s nextPut: e asString asPParser.
s nextPut: (e first: 3) asPParser ] ].
^ PP2ChoiceNode withAll: monthRules
But I was wondering if there was something built in/straightforward