Re: Standalone Parser for PL/pgSQL

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Matt Miller <mattm(at)epx(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Standalone Parser for PL/pgSQL
Date: 2005-07-13 21:04:34
Message-ID: 20050713210434.GA6201@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jim C. Nasby 2005-07-13 21:11:12 Re: To Postgres or not
Previous Message Richard_D_Levine 2005-07-13 20:53:26 Re: chosing a database name