Re: Backtracking through the source
[email protected] (Tom Hughes) Mon, 27 Nov 2000 23:49:30 GMT
| Newsgroups | perl.perl6.internals.api.parser |
|---|---|
| Message-ID | <[email protected]> |
In message <[email protected]> Dan Sugalski <[email protected]> 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 -- Tom Hughes ([email protected]) http://www.compton.nu/ ...Lonely men seek companionship. Lonely women sit at home - they never meet.