petitparser2
petitparser2 copied to clipboard
Skip-Until
I had suggested this API addition to the original PP after repeatedly needing it:
PPParser>>skipUntil
^ self negate plus, self ==> [ :nodes | nodes second ].
To be used like:
parser2 := 'dd' asParser skipUntil.
parser2 parse: 'kslkxjclkxjcdd'. "Returns 'dd’"
Do we now have this with island parsing, or could this be a useful addition?
Hi Sean, that sounds like a nice extension.
I find 'dd' asPParser skipUntil
a bit unintuitive. Would something like #any asPParser skipUntil: 'dd' asPParser
work for as well? It's clearer for me what I want, but the syntax is longer. Maybe 'dd' asPParser skipAnyUntil
🤔. But that sounds as good as skipUntil
... 🤷
I will add it as soon as I figure out why Pharo stopped rendering properly my Chromebook (yes, I use chromebook 🙄)
I wonder if this is still needed now that we have island parsing, @kursjan. Thoughts? I guess this is slightly different in that it only considers sea before and not necessarily after...