Re: [HACKERS] Postgres' lexer - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Postgres' lexer
Date
Msg-id 15312.936107873@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Postgres' lexer  (Thomas Lockhart <lockhart@alumni.caltech.edu>)
List pgsql-hackers
Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
> I added the <xm> exclusive state to accomodate the possibility of a
> unary minus. The change was provoked by Vadim's addition of CREATE
> SEQUENCE, which should allow negative numbers for some arguments. But
> this just uncovered the tip of the general problem...

It seems awfully hard and dangerous to try to identify unary minus in
the lexer.  The grammar at least has enough knowledge to recognize that
a minus *is* unary and not binary.  Looking into gram.y, I find that the
CREATE SEQUENCE productions handle collapsing unary minus all by
themselves!  So in that particular case, there is still no need for the
lexer to do it.  AFAICT in a quick look through gram.y, there are no
places where unary minus is recognized that gram.y won't try to collapse
it.

In short, I still think that the whole mess ought to come out of the
lexer...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] File descriptor leakage?
Next
From: "Ansley, Michael"
Date:
Subject: RE: [HACKERS] Postgres' lexer