Search on
Java "SQL parser"
on groups.google.com, sort by date. There doesn't seem to be
terrifically high demand for this, oddly. Even so, I find myself in
need of one.
The most common reference I've seen is to something called ZQL.
However, half the time, the link to it goes 404. The other half of
the time, I find something several years old, and apparently quite
incomplete.
I've been lending some consideration for about a week now to beginning
an open-source Java SQL parser project on Sourceforge. I would go for
pure SQL2 compliance (using the docs I found at
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt and
http://www.contrib.andrew.cmu.edu/~shadow/sql/sql2bnf_aug92.txt as
guides). I would try to implement the parser in such a way that it
could subclassed reasonably easily, to allow vendor-specific parsers,
as well as a SQL3-compliant version. I'm sure this would be a massive
undertaking. The BNF doc alone is over 60Kb.
I'm ambivalent on whether to use JavaCC - it's the only parser
generator I know of, but I know it only by name. I would also guess
it's very generic; it wouldn't generate instances of a nice
SQL-specific class library (I think; I skimmed the FAQ). I went to
the JavaCC Grammar Repository, and found two SQL grammars, but they're
both Oracle-specific.
Would there be any community interest in an OS Java SQL parser
project?
Paul Brinkley