D grammar as LL(1) grammar ( OT)
BCS
ao at pathlink.com
Sun Sep 16 14:39:40 PDT 2007
Reply to Jascha,
> Furthermore, LR parsers consider multiple potential parse trees at the
> same time, throwing away the wrong guesses, once the necessary tokens
> get available. LL parsers have to check each potential parse tree
> separately.
>
In general that may be true (I'd have to check) but often a specific grammar
can be rearranges to (partly) avoid that, particularly the parts that appear
in several trees.
for instance:
A ::= B c C | B d D | B e E ;
can be rearranged as
A ::= B A_ ;
A_ ::= c C | d D | e E ;
This at a minimum can avoid reparsing the B part of each option.
Admittedly this is actually changing the grammar that is being parsed (so
I can't claim to be doing a better job with the original grammar) but these
can be done automatically.
More information about the Digitalmars-d
mailing list