Closed lukego closed 7 years ago
Hi, is this what are you looking for?
Open the PP2SmalltalkGrammarTest
and add your own test method:
testIdentifierSea
| id |
id := self parserInstanceFor: #identifier.
self assert: id parse: 'foo'.
self assert: id fail: '...bar...'.
self assert: id islandInSea parse: '...bar...'
BTW, feel free to post relevant questions to stackoverflow with the petitparser2
tag, if you think it is more appropriate.
Thanks! That looks like exactly what I want.
I'm happy using Github but can switch to stackoverflow on request. Personally I feel like mailing lists are too old fashioned, Discourse is too new-fangled, and stuff in between is mostly okay ;-).
Whatever works for you,... stackoverflow was an idea... sounds a bit more community-friendly to me (but it is just personal opinion)
Is there an easy way to test a production such that it is an island in a sea?
That is, I would like to test like this:
except that I want to allow for
self x
to contain extra text and so to really test the productionx islandInSea
.Trick is that I don't want to define a whole new production for the island version (there are too many) and I don't know how to specify the
islandInSea
because the rule is expected to be a symbol rather than a parser.The workaround I am using is to prune all the leading/trailing text from my test cases but I feel like leaving it there and making it irrelevant would be more in the spirit of parsing with islands and seas?