Accurate list of Keywords / Datatypes?

Started by Robins Tharakanover 9 years ago6 messages
#1Robins Tharakan
tharakan@gmail.com

Hi,

While creating a Syntax Highlighting XML for Notepad++ (something like a
PLSQL one here http://goo.gl/UBbHdt ), I was looking for a list of Keywords
(& separately list of Datatypes) that Postgres uses in a given version (Say
DEVEL branch).

I did find the Reserved Keyword list (
http://www.postgresql.org/docs/devel/static/sql-keywords-appendix.html) but
it doesn't look like what I need, because:

1. The ones marked as 'Reserved' isn't all the words I am interested in
(since these are just 'Reserved')
2. The entire list seems like an overkill (since it has words such as K
and ROUTINE_CATALOG, which aren't really what I'd like highlighted when I
am working on an SQL file in NPP)

Should I be looking somewhere else? Parse keywords from Git Source file (if
so where)? Parse PG Documentation?

I tried ( https://goo.gl/OYeYuE ) parsing HTML Tags (such as VARNAME /
TOKEN / LITERAL / COMMAND) in PG Documentation but is there's a simpler
(more accurate) way for this?

Any pointers would be great!
-
​thanks
robins

#2Euler Taveira
euler@timbira.com.br
In reply to: Robins Tharakan (#1)
Re: Accurate list of Keywords / Datatypes?

On 07-05-2016 22:53, Robins Tharakan wrote:

Should I be looking somewhere else? Parse keywords from Git Source file
(if so where)? Parse PG Documentation?

src/include/parser/kwlist.h

--
Euler Taveira Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3David G. Johnston
david.g.johnston@gmail.com
In reply to: Euler Taveira (#2)
Re: Accurate list of Keywords / Datatypes?

On Saturday, May 7, 2016, Euler Taveira <euler@timbira.com.br> wrote:

On 07-05-2016 22:53, Robins Tharakan wrote:

Should I be looking somewhere else? Parse keywords from Git Source file
(if so where)? Parse PG Documentation?

src/include/parser/kwlist.h

http://www.postgresql.org/docs/9.5/interactive/functions-info.html

SELECT * FROM pg_get_keywords();

I don't know how the docs, this function, and the source code relate to
each other.

David J.

#4Michael Paquier
michael.paquier@gmail.com
In reply to: David G. Johnston (#3)
Re: Accurate list of Keywords / Datatypes?

On Wed, May 11, 2016 at 10:22 AM, David G. Johnston
<david.g.johnston@gmail.com> wrote:

On Saturday, May 7, 2016, Euler Taveira <euler@timbira.com.br> wrote:

On 07-05-2016 22:53, Robins Tharakan wrote:

Should I be looking somewhere else? Parse keywords from Git Source file
(if so where)? Parse PG Documentation?

src/include/parser/kwlist.h

http://www.postgresql.org/docs/9.5/interactive/functions-info.html

SELECT * FROM pg_get_keywords();

I don't know how the docs, this function, and the source code relate to each
other.

ScanKeywords is fed directly from kwlist.h, have for example a look at
the top of src/common/keywords.c. Then NumScanKeywords is calculated
from the list generated. pg_get_keywords is at the end making use of
those structures generated.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#5Euler Taveira
euler@timbira.com.br
In reply to: David G. Johnston (#3)
Re: Accurate list of Keywords / Datatypes?

On 10-05-2016 22:22, David G. Johnston wrote:

I don't know how the docs, this function, and the source code relate to
each other.

Function is built around ScanKeywords structure which in turn is built
using parser/kwlist.h.

--
Euler Taveira Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#6Robins Tharakan
tharakan@gmail.com
In reply to: Euler Taveira (#2)
Re: Accurate list of Keywords / Datatypes?

On 8 May 2016 at 07:38, Euler Taveira <euler@timbira.com.br> wrote:

src/include/parser/kwlist.h

​Thanks Everyone.

Kwlist.h got me going as to where to look, but I had to improvise (quite) a
bit. Any and all advice about any other authoritative lists (like kwlist.h)
would be a big help, since currently much is kludgy.

Created a GitHub Repo in case someone's interested (
https://github.com/robins/npp-lang-plpgsql).

​For PLPGSQL, (src/pl/plpgsql/src/pl_scanner.c)​

For DataTypes, (src/interfaces/ecpg/preproc/c_keywords.c
; src/backend/bootstrap/bootstrap.c) as well as parse all HTML pages under
http://www.postgresql.org/docs/devel/static/datatype.html.

For Config Parameters (recovery.sample.conf ; postgresql.sample.conf) as
well as parse all HTML pages under
http://www.postgresql.org/docs/devel/static/runtime-config.html ;
http://www.postgresql.org/docs/devel/static/libpq-connect.html

For Extensions (Parse HTML:
http://www.postgresql.org/docs/devel/static/contrib.html)

-
robins