Simon Cozens wrote:
> It's time to drag out my quote of the week:
> 
>     Recursive-descent, or predictive, parsing ONLY works on grammars
>     where the first terminal symbol of each subexpression provides
>     enough information to choose which production to use.

Recursive-descent parsers are nice because they are *much* easier to
generate errors with. They are also much easier to generate segmented
grammars which is nice for something like Perl because there are so
many quiet shifts into several different sub-languages.

The only real problem is prediction and that is *easily* solved with
look-ahead and/or back-tracking. IMHO back-tracking is preferable,
especially if there are cut-points where the search tree can be pruned.
I think it's very powerful to think of a grammar as a declarative
program which searches for the best-fit between itself and the input
stream.

> So, while I don't doubt that, with the state of Perl's regexes these
> days, it's possible to create something with enough sentience to
> tokenize Perl, I've really got to wonder whether it's sane.

I think the goal would be to increase the power of the regexes to
handle Perl grammar. This could be the coolest language tool since
yacc. (I'm intentionally not comparing Perl's regex to lex. We shouldn't
make the same stupid mistake as lex/yacc by splitting a language into
a token specification and a grammar with incompatible syntax.)

- Ken

Reply via email to