dbTalk Databases Forums  

OS-SQL-Grammar?

comp.databases.theory comp.databases.theory


Discuss OS-SQL-Grammar? in the comp.databases.theory forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Norbert_Paul
 
Posts: n/a

Default OS-SQL-Grammar? - 07-07-2011 , 02:32 AM






Hi,

is there a handy (and parseable) Open Source SQL-grammar around,
that can be fed into a parser generator without major problems?
I consider ISO 9075:2003 useless for this purpose and don't get
the point of this "standard".

I have (many) problems with the ISO grammar.
Here is one I spotted yesterday: Is the following string

"/* this is */ a strange comment */"

a valid SQL-Comment (according to SQL 2003)?
I think I have to say (reluctantly) yes:

Proof
Excerpts from ISO 9075-2:2003 (with rule numbers attached):

<comment> ::=
<simple comment>
Quote:
bracketed comment> (1)
<bracketed comment> ::=
<bracketed comment introducer> (2)
<bracketed comment contents>
<bracketed comment terminator>

<bracketed comment introducer> ::= /* (3)

<bracketed comment terminator> ::= */ (4)

<bracketed comment contents> ::=
!! See the Syntax Rules
[ { <comment character> | <separator> }... ] (5)

<comment character> ::=
<nonquote character> (6)
Quote:
quote
<nonquote character> ::= !! See the Syntax Rules. (7)

<solidus> ::= / (8)

<asterisk> ::= * (9)


Syntax rules: to (5) and (7)
10) Within a <bracketed comment contents>, any <solidus> immediately followed by an <asterisk> without
any intervening <separator> shall be considered to be the <bracketed comment introducer> of a <separator>
that is a <bracketed comment>.

11) A <nonquote character> is one of:
a) Any character of the source language character set other than a <quote>.
b) Any character other than a <quote> in the character set identified by the <character set specification>
or implied by “N”.

Derivation:
<comment>
--> <bracketed comment> (1)
--> <bracketed comment introducer> (2)
<bracketed comment contents>
<bracketed comment terminator>
--> "/*" (3,4,5)
[ { <comment character> | <separator> }... ]
"*/"
--> "/*" (6) und Syntax rules 10 und 11.
" this is */ a strange comment "
"*/"
--> "/* this is */ a strange comment */"
^
This <solidus> is not immediately followed by an <asterisk>
and it is a <nonquote-character>, too.

Did I (or the authors ouff this _standard_ (n.b.)) miss something I should have norticed?

Norbert

Reply With Quote
  #2  
Old   
Nessi
 
Posts: n/a

Default Re: OS-SQL-Grammar? - 07-07-2011 , 02:54 AM






=== original message ===
from: Norbert_Paul
date: 2011-07-07 09:32

Quote:
Hi,

is there a handy (and parseable) Open Source SQL-grammar around,
that can be fed into a parser generator without major problems?
I consider ISO 9075:2003 useless for this purpose and don't get
the point of this "standard".

I have (many) problems with the ISO grammar.
Here is one I spotted yesterday: Is the following string

"/* this is */ a strange comment */"

a valid SQL-Comment (according to SQL 2003)?
I'd say no. According to the grammer, "/* this is */" is the <bracket
comment> and what's following is not valid.
As soon as a token is found (in this case the first <bracket comment
terminator>) it is processed. Therefore the first "*/" ends the bracket
comment and the following characters are not part of the comment anymore.

Cheers,
Udo

Reply With Quote
  #3  
Old   
Dieter Nöth
 
Posts: n/a

Default Re: OS-SQL-Grammar? - 07-07-2011 , 03:04 AM



Norbert_Paul wrote:

Quote:
is there a handy (and parseable) Open Source SQL-grammar around,
that can be fed into a parser generator without major problems?
Did you try the BNF grammar files at
http://savage.net.au/SQL/index.html

If you happen to succeed could you please post a "how-to"?
I was looking for the same stuff some years ago (to implement a source
code beautifier) and i failed.

Quote:
I consider ISO 9075:2003 useless for this purpose and don't get
the point of this "standard".
They just have the wording of a law code and you must be a lawyer (or
similar) to actually read (and understand) more than just a few
paragraphs ;-)

Quote:
Is the following string

"/* this is */ a strange comment */"

a valid SQL-Comment (according to SQL 2003)?
No.
If you don't remove the double quotes it's an (very strange) identifier
and if you remove them it should result in a syntax error because the
comment ends after the first "*/".

The standard defines nested comments, but not all DBMSes support them:
"/* this is a /* nested */ comment */"

You probably wouldn't consider this as a valid string:
'bla' blabla'

Dieter

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.