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

From Brook Milligan
Subject Re: [HACKERS] Postgres' lexer
Date
Msg-id 199908201457.IAA11086@biology.nmsu.edu
Whole thread Raw
In response to RE: [HACKERS] Postgres' lexer  ("Ansley, Michael" <Michael.Ansley@intec.co.za>)
Responses Re: [HACKERS] Postgres' lexer
List pgsql-hackers
I think that we need to find another way to tokenise the minus.  First of  all, though, how is the parser supposed
totell whether this:  a -2  means this:  (a - 2)  or this:  a (-2)
 
  i.e.: does the unary - operator take precedence over the binary - operator  or not?  Is there even a difference.  If
theparser runs into this: 'a -2',  perhaps we could replace it with 'a + (-2)' instead.
 
  How does a C compiler tokenize this?  Or some other standard SQL parser?

For the C compiler a -2 can only mean (a - 2); a (-2) must explicitly
be a function call and isn't generated by the compiler from a -2.

I think the question for SQL is, does the language allow an ambiguity
here?  If not, wouldn't it be much smarter to keep the minus sign as
its own token and deal with the semantics in the parser?

Cheers,
Brook


pgsql-hackers by date:

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