[EMAIL PROTECTED] wrote:

> Hi Petr, 6-Jan-2000 you wrote:
>
> [...]
> >> How about this:
> >>
> >> >> a: [skip a | "ing"]
> >> == [skip a | "ing"]
> >> >> parse "ringin" a
> >> == false
> >> >> parse "ringing" a
> >> == true
> >>
> >> It should do the job. So actually backtracking in Parse can be achieved by
> use
> >> of the "|" operator in Parse blocks.
>
> >What? | is simple OR or am I wrong? You will end up in recursion imho.
>
> That was the very point.

Aha, I just thought that you thought "ing" is matched or skip is performed, not
knowing of recursion. Well, I should look better at your email adress, as I would
recognize, you are experienced reboller :-)

Anyway ... your example will fail with "ing" being present somewhere in middle of
the text ... I would even sincerely dare to say - it has no sense. You are nesting
to recursion while end of string is not matched (let's imagine some 1000 chars =
1000 subrules) and then backtracking by one char, while "ing" or we are not back
at the beginning of string ... Or am I wrong?

> I just don't see what the problem is. The examples above do exactly as I
> wanted. I used "|" as "a backtracker", since it appears to do this:
>
> First, call recursively on the left side of the "|". If the match succeeds,
> return success.

No, no chance, You have no chance to match "ing". It will always reach the end of
the string. Once returning to upper levels from recursion, backtracking starts

>
> If the first call didn't return success,

It can't because of the reasons mentioned above ...

> call recursively on the right side of
> the "|" (starting from the same position in the input stream as for the call
> on the left side of the "|"). If the match succeeds, return success,
> otherwise return failure.
>
> This is effectively the same as backtracking.
>

pretty ineffective seems to me ...

... no offense ...


>
> >See ya,
>
> >PS: I am somehow tired today to study and comment another examples, sorry :-)
>
> Me too, I still have to read quite a few pages (of _really_ boring statistics)
> before I can go to bed ;-)
>

I think still better than really bad toothache :-)

-pekr-

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

Reply via email to