Thread: Public Domain SQL grammars?

Public Domain SQL grammars?

From
"Terry Van Belle"
Date:
Hi All,
 
I've been trying to automatically parse the SQL'92 grammar, based on the BNF found in the ISO spec.  So far no luck throwing yacc, yay, or JavaCC at it.  Does anyone know what type of grammar it is, and whether there are any public domain grammars out there for it?
 
Terry
 

Re: Public Domain SQL grammars?

From
Tom Lane
Date:
"Terry Van Belle" <vanbelle@freedomintelligence.com> writes:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META content=3D"text/html; charset=3Diso-8859-1" http-equiv=3DContent-Type>
> <META content=3D"MSHTML 5.00.2919.3800" name=3DGENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY bgColor=3D#ffffff>
> <DIV><FONT face=3DArial size=3D2>Hi All,</FONT></DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>I've been trying to automatically parse th=
> e SQL'92=20
> grammar, based on the BNF found in the ISO spec.  So far no luck throw=
> ing=20
> yacc, yay, or JavaCC at it.  Does anyone know what type of grammar it =
> is,=20
> and whether there are any public domain grammars out there for it?</FONT></=
DIV>
> <DIV> </DIV>
> <DIV><FONT face=3DArial size=3D2>Terry</FONT></DIV>
> <DIV> </DIV></BODY></HTML>

(Please people, don't post HTML-ified email on mailing lists.  You think
the rest of us enjoy looking at this stuff?)

My guess is that the grammar shown in the spec is not LR(1), and that
you'll have to transform it into LR(1) form before you will get any
available parsing tool to deal with it.  This generally involves
rearranging productions so that no more than one token lookahead is
needed to tell which production to use next.  You might care to read
the 'bison' (GNU yacc) manual on the subject of removing parse
conflicts.

            regards, tom lane