Related articles |
---|
with or without keywords gergoe@math.bme.hu (Buday Gergely) (1998-03-12) |
Re: with or without keywords vladimir@cs.ualberta.ca (Vladimir Alexiev) (1998-03-15) |
Re: with or without keywords scott@basis.com (1998-03-18) |
Re: with or without keywords Nick.Roberts@dial.pipex.com (Nick Roberts) (1998-03-18) |
Re: with or without keywords os@cs.tu-berlin.de (Olaf Stoyke) (1998-03-18) |
From: | scott@basis.com (Scott Amspoker) |
Newsgroups: | comp.compilers |
Date: | 18 Mar 1998 23:00:08 -0500 |
Organization: | Basis International |
References: | 98-03-110 |
Keywords: | parse |
Buday Gergely <gergoe@math.bme.hu> wrote:
>I'd like to parse a language that allows embedded sql querys. The
>problem is that tokens that are keywords in an sql statement are
>allowed as an identifier outside it.
It gets worse. SQL itself has problems with keywords and "legitimate"
field/table names. I use quotes because there are some legacy
database products that allow all kinds of garbage as identifiers.
Whether or not standard SQL allows it, you should brace yourself for
them. One example is the DESC keyword (short for DESCENDING).
Although it is "reserved", it's not unusual to encounter it as a field
name (short for DESCRIPTION). Another example is 'BY' which is
reserved but only shows up after another keyword ("GROUP BY", "ORDER
BY"). One database product allowed field names to contain a '-':
SELECT CUST-NAME FROM CUSTFILE
You can imagine the problems with the above statement. Let me repeat, this
is *not* called for by SQL but will show up in the real world.
Once you figure out how to keep the embedded SQL separate from the rest of
your grammer (other posts in this thread have suggested ways to do that),
then you must deal with SQL itself. Try to be as liberal as possible with
reserved words. It will save you headaches later.
Scott Amspoker
scott@basis.com
http://www.rt66.com/sda
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.