[EMAIL PROTECTED] wrote:

> It is true that we get a ridiculously deep recursion. In effect, we first go
> to the end of the string (by recursion), then we step backwards and each time
> look if the string from the position we're at is "ing". So:
>
> 1: If we have a string with n chars, ending in "ing":
> First make n recursive calls. On the third character on the way back, we find
> out that our string ends with "ing", and we therefore return "success" all
> the way up back through the recursion.
>

No. look at my previous post. Look at console outputs - we are not going back
anymore, once succesfull. That's the main point where we differ.

> Why haven't I got a chance of matching "ing"? When we're at the point where we
> have reached the end of the string, the part left to "|" will fail
> immediately, since 'skip fails. Then we try to match "ing", which will fail.
> Only when we go three steps back (i.e. we're at the position in the string
> where we can see the last 3 characters in the string), the match on "img"
> might succeed.

Sory for confusion, I meant exactly the same ...

> If so, the "succeed" result is propagated all the way through
> our recursive calls, since "skip a" has then succeeded for all the calls
> above.

No ... or at least, it doesn't seems so. Once "ing" is matched, it returns 'true
one level higher, no ALL levels higher. So, returning 'true one level higher means
parsers tries to continue at that level, skipping the rest of the rule | ....],
and then? No more code here, not "to end" here, so we matched "ing", but still not
at the end of the string, so it returns false. Not returning to upper levels
though!

-pekr-

>
> Kind regards,
> --
> Ole Friis <[EMAIL PROTECTED]>
>
> "Ignorance is bliss"
> (Cypher, The Matrix)

Reply via email to