Re: Hand written parsers - Mailing list pgsql-hackers

From Mark Butler
Subject Re: Hand written parsers
Date
Msg-id 3AD53124.D0923FAC@middle.net
Whole thread Raw
In response to Re: Yacc / Bison difficulties  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: Re: Hand written parsers  (Ian Lance Taylor <ian@airs.com>)
List pgsql-hackers
Bruce Momjian wrote:

> Interesting.  What advantages would there be?

As any one who has ever attempted to build a C++ parser using Yacc or Bison
can attest, it is very difficult to get an LALR based parser to correctly
parse a sophisticated grammar.  The advantages of using a hand written
recursive descent parser lie in four areas:

1) ease of implementing grammar changes 
2) ease of debugging
3) ability to handle unusual cases
4) ability to support context sensitive grammars

Context sensitivity is useful for handling things like embedded programming
languages without having to escape whole procedures as string literals, for
example.  We could support procedural language plugins without the current
limitations on syntax.

Another nice capability is the ability to enable and disable grammar rules at
run time - you could add run time options to disable all non SQL-92 grammar
rules for application portability testing or emulate Oracle's outer join
syntax, as a couple of examples.
- Mark Butler


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Yacc / Bison difficulties
Next
From: Ian Lance Taylor
Date:
Subject: Re: Re: Hand written parsers