Обсуждение: Accurate list of Keywords / Datatypes?

Поиск
Список
Период
Сортировка

Accurate list of Keywords / Datatypes?

От
Robins Tharakan
Дата:
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

Re: Accurate list of Keywords / Datatypes?

От
Euler Taveira
Дата:
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,
Suporte24x7 e Treinamento
 



Re: Accurate list of Keywords / Datatypes?

От
"David G. Johnston"
Дата:
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

 

SELECT * FROM pg_get_keywords();

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

David J.

Re: Accurate list of Keywords / Datatypes?

От
Michael Paquier
Дата:
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



Re: Accurate list of Keywords / Datatypes?

От
Euler Taveira
Дата:
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,
Suporte24x7 e Treinamento
 



Re: Accurate list of Keywords / Datatypes?

От
Robins Tharakan
Дата:

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


-
robins