OS-SQL-Grammar?

From: Norbert_Paul <norbertpauls_spambin_at_yahoo.com>
Date: Thu, 07 Jul 2011 09:32:52 +0200
Message-ID: <iv3nf4$jbv$2_at_dont-email.me>



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>
   | <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>

<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 Received on Thu Jul 07 2011 - 09:32:52 CEST

Original text of this message