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

From Leon
Subject Re: [HACKERS] Postgres' lexer
Date
Msg-id 37BD9E41.F9C95EBC@udmnet.ru
Whole thread Raw
In response to RE: [HACKERS] Postgres' lexer  ("Ansley, Michael" <Michael.Ansley@intec.co.za>)
List pgsql-hackers
Ansley, Michael wrote:
>
> Leon, if you manage to find a replacement for this, please let me know.
> I'll probably only pick it up after the weekend.
>
> I think that we need to find another way to tokenise the minus.  First of
> all, though, how is the parser supposed to tell whether this:
> a -2
> means this:
> (a - 2)
> or this:
> a (-2)

I think that the current behavior is ok - it is what we would expect
from expressions like 'a -2'.

I have produced a patch to cleanup the code. It works due to the
fact that unary minus gets processed in doNegate() in parser anyway,
and it is by no way lexer's job to do grammatical parsing - i.e.
deciding if operator is to be treated as binary or unary.

I ran regression tests, everything seems to be ok. It is my first
diff/patch experience in *NIX, so take it with mercy :) But it
seems to be correct. It is to be applied against 6.5.0 (I have
not upgraded to 6.5.1 yet, but hope lexer hasn't changed since
then.) The patch mainly contains nuked code. The only thing added
is my short comment :)

Have I done some right thing? :)

--
Leon.
---------
"This may seem a bit weird, but that's okay, because it is weird." -
Perl manpage.
Attachment

pgsql-hackers by date:

Previous
From: Dmitry Samersoff
Date:
Subject: What does it mean?
Next
From: Leon
Date:
Subject: Re: [HACKERS] Postgres' lexer