From: | ncm(at)zembu(dot)com (Nathan Myers) |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Re: Hand written parsers |
Date: | 2001-04-12 07:53:56 |
Message-ID: | 20010412005356.A15434@store.zembu.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Apr 11, 2001 at 10:44:59PM -0700, Ian Lance Taylor wrote:
> Mark Butler <butlerm(at)middle(dot)net> writes:
> > ...
> > The advantages of using a hand written recursive descent parser lie in
> > 1) ease of implementing grammar changes
> > 2) ease of debugging
> > 3) ability to handle unusual cases
> > 4) ability to support context sensitive grammars
> > ...
> > Another nice capability is the ability to enable and disable grammar
> > rules at run time ...
>
> On the other hand, recursive descent parsers tend to be more ad hoc,
> they tend to be harder to maintain, and they tend to be less
> efficient. ... And I note that despite the
> difficulties, the g++ parser is yacc based.
Yacc and yacc-like programs are most useful when the target grammar (or
your understanding of it) is not very stable. With Yacc you can make
sweeping changes much more easily; big changes can be a lot of work in
a hand-coded parser. Once your grammar stabilizes, though, hand coding
can provide flexibility that is inconceivable in a parser generator,
albeit at some cost in speed and compact description. (I doubt parser
speed is an issue for PG.)
G++ has flirted seriously with switching to a recursive-descent parser,
largely to be able to offer meaningful error messages and to recover
better from errors, as well as to be able to parse some problematic
but conformant (if unlikely) programs.
Note that the choice is not just between Yacc and a hand-coded parser.
Since Yacc, many more powerful parser generators have been released,
one of which might be just right for PG.
Nathan Myers
ncm(at)zembu(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Zeugswetter Andreas SB | 2001-04-12 08:24:01 | AW: AW: AW: Truncation of char, varchar types |
Previous Message | Alessio Bragadini | 2001-04-12 07:38:08 | Re: age() function documentation |