Re: Standalone Parser for PL/pgSQL - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Standalone Parser for PL/pgSQL
Date
Msg-id 20050713210434.GA6201@alvh.no-ip.org
Whole thread Raw
In response to Standalone Parser for PL/pgSQL  (Matt Miller <mattm@epx.com>)
Responses Re: Standalone Parser for PL/pgSQL
Re: Standalone Parser for PL/pgSQL
List pgsql-general
On Wed, Jul 13, 2005 at 08:33:59PM +0000, Matt Miller wrote:
> I'd like (to find or make) a utility that inputs the code of a Pl/pgSQL
> function (e.g. from a text file or from STDIN, and then parses the
> function definition, building a complete symbol table.  I would then
> write C code that walks that symbol table and does stuff.  As a starting
> point I'd be happy if I could just visit each node in the symbol table
> and dump that node out to another file.
>
> I'm thinking that the code in src/pl/plpgsql/src is where to start, but
> I need some guidance sorting through that stuff.  I understand (in
> theory, anyway) how flex and bison work, so maybe I just need a bit of
> hand-holding to get a simple standalone PL/pgSQL parser up and running.

I don't think you can use just plpgsql's parser.  The problem is that it
relies on the main backend parser to figure out anything it doesn't
understand.  So you'd have to mix both parsers somehow.  The only
thought that comes to my mind is start with the backend's parser and add
productions for PL/pgSQL's constructs.

The main parser depends (at least) on the List handling and memory
handling.  So your "simple standalone parser" will have to contain both
things at least.

See src/backend/parser/README.

--
Alvaro Herrera (<alvherre[a]alvh.no-ip.org>)
A male gynecologist is like an auto mechanic who never owned a car.
(Carrie Snow)

pgsql-general by date:

Previous
From: Richard_D_Levine@raytheon.com
Date:
Subject: Re: chosing a database name
Next
From: "Jim C. Nasby"
Date:
Subject: Re: To Postgres or not