Hi, When you have questions like these, you can also use the built-in debugging facilities. For example, in your case, you can see that the #any parser consumed everything like this:
Cheers, Doru > On Jan 20, 2017, at 4:38 PM, Norbert Hartl <norb...@hartl.name> wrote: > > >> Am 20.01.2017 um 15:24 schrieb Peter Uhnak <i.uh...@gmail.com>: >> >> Is PetitParser eager by default? >> >> I've used PetitParser countless times so I am really baffled why this >> doesn't work >> >> str := 'a0b'. >> #any asParser star, #digit asParser, #any asParser star parse: str. >> >> -> PPFailure (input expected at: 3) >> > > PetitParser is not greedy per default. But back tracking only works if a > parser fails. Using , creates a sequence of combined parsers. If one fails > the whole sequence fails. As a star parser always succeeds it would be huge > luck if your rule would succeed. The probability that the parser consumes > exactly one character is not high. Maybe negating the first sequence part is > what you want > > Norbert > > -- www.tudorgirba.com www.feenk.com "What we can governs what we wish."