in reply to Re: Backtracking in Parse::RecDescent (solution)
in thread Backtracking in Parse::RecDescent

Thanks, that's a good answer. However, it does not quite do what I want, which is for the parser to try all possible alternatives in a production before failing. I suspect that the answer is that top-down parsers just do not work that way.
  • Comment on Re: Re: Backtracking in Parse::RecDescent (solution)

Replies are listed 'Best First'.
Re: Re: Re: Backtracking in Parse::RecDescent (solution)
by Anonymous Monk on Dec 07, 2002 at 01:47 UTC
    The answer is that RecDescent parsers do not work that way. They don't backtrack on failure; they just fail. Of course, there's nothing to prevent a recursive descent parser from incorporating backtracking too, but RecDescent doesn't.

    So, if you need backtracking in part of your grammar, you need to use plain old regexes there. Sorry.

    Damian

      Thanks Damian. It's one thing to suspect an explanation; quite another to have it confirmed :)

      Kevin