develooper Front page | perl.perl6.internals.api.parser | Postings from November 2000

Re: Backtracking through the source

Thread Previous | Thread Next
Tom Hughes
November 27, 2000 16:16
Re: Backtracking through the source
Message ID:
In message <>
          Dan Sugalski <> wrote:

> Is there any reasonable case where we would need to backtrack over
> successfully parsed source and redo the parsing? I'm not talking about the
> case where regular expressions run over text and ultimately fail, but
> rather cases where we need to chuck out part of what we have and restart?

That's effectively analogous to asking how much lookahead you need
to have, and the answer to that is that it depends entirely on the
grammar you're trying to parse.

With infinite lookahead you would never need to backtrack as you
could, if necessary, look right to the end of the program to decide
what the next token meant. Equally with no lookahead you will quite
likely need to backtrack unless your grammar is fairly restrictive, and
we all know that perl's grammar is anything but restrictive ;-)


Tom Hughes (
...Lonely men seek companionship.  Lonely women sit at home - they never meet.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About