Thread: Fwd: How parser works and to add keyword to keywords.h

Fwd: How parser works and to add keyword to keywords.h

From
Pankaj Bagul
Date:
Hello,
Can anyone tell about how parser works and if we want to add a new keyword to the keywords.h,
and how to use that keyword ? How the all process works ?

--
Pankaj B.

Re: Fwd: How parser works and to add keyword to keywords.h

From
Tom Lane
Date:
Pankaj Bagul <bagul.p.a@gmail.com> writes:
> Can anyone tell about how parser works and if we want to add a new keyword
> to the keywords.h,
> and how to use that keyword ? How the all process works ?

The minimum requirements are as stated in gram.y: add the keyword to
kwlist.h, to the "%token <keyword>" list near the head of gram.y, and
to the appropriate one of the keyword category lists near the bottom
of gram.y.  Presumably you want to use this keyword in some production
or other, so you'll also need to add or modify parsetree node struct types
to represent the output from the production.  Best bet really is to
identify some existing SQL language feature that is somewhat related
to what you want to do, and then grep the PG source code for all mentions
of the related parse node type(s).  There's usually a pretty fair amount
of boilerplate support code that you'll need to add or modify, but copy
and paste is your friend for that.
        regards, tom lane