Re: [HACKERS] Postgres' lexer

From: Brook Milligan <brook(at)biology(dot)nmsu(dot)edu>
To: Michael(dot)Ansley(at)intec(dot)co(dot)za
Cc: leon(at)udmnet(dot)ru, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Postgres' lexer
Date: 1999-08-20 14:57:31
Message-ID: 199908201457.IAA11086@biology.nmsu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.e.: does the unary - operator take precedence over the binary - operator
or not? Is there even a difference. If the parser 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-08-20 16:18:18 Re: [HACKERS] Postgres' lexer
Previous Message Ansley, Michael 1999-08-20 14:34:30 RE: [HACKERS] Postgres' lexer