[antlr-interest] Re: SQL2 and AST
Lubos Vnuk
lubos.vnuk at rts.at
Tue Mar 9 02:34:12 PST 2004
As the author of the SQL2 grammar I just wanted to explain the
missing AST support.
My original idea was to make a few SQL parsers for different dialects
(standard SQL2, SQL3, Oracle, Informix, DB2...) and then make a SQL-
translator to provide the DB server independence.
I chose ANTLR and started with SQL2. I spent a lot of time fixing ALL
the non-determinisms (would have likely been much easier with an LR
parser generator) and making the grammar logically sound, conforming
to the standard and well-documented that I was really happy to put it
all together at all.
As I started thinking about putting the tree-building in I decided to
postpone it because:
1. it would have ruined the readability of the grammar
2. first I wanted to make a few other SQL parsers and decide on the
right AST structure having in mind the goal of the dialect translation
3. there came the prospect of ANTLR3 which should bring interesting
speed and functional enhancements
I tested the SQL2 grammar with buildAst=false and buildAst=true (this
option is still on in the published version I reckon) and encountered
no problems. Of course setting buildAst=true does not bring much in
this version and if you want to use tree-building you should build it
in yourself according to your liking (let me please know of your
ideas).
In the meantime I have built a few SQL BNFs that I can use to
generate raw ANTLR grammars with so if anyone wants to help me with
building SQL3, SQL2003 or DB2 UDB parsers, let me know. More
information on this in http://sqlweb.vnuk.org
Regards,
Lubos.
--- In antlr-interest at yahoogroups.com, "kristoff_tempelaere"
<kristoff_tempelaere at y...> wrote:
> Hello,
>
> I'm a student, new to ANTLR and need it to create a SQL-parser, so
I
> used Lubos Vnuk's grammar (nice one!, only the DML-subset) and
> generate C++ code with Visual Studio 6. I use the latest version
> (20040225) of Ric Klaren...
>
> With buildAst=false it works fine, also with buildAst=true I can
> compile and build it, but when I run it, I get an "access
violation"-
> error. So there must be some (memory-allocating?)-error in the AST-
> code.
>
> Someone who knows how to fix this? Or did someone got it work with
> another compiler? Maybe it can help if I give you the call stack
> when the error occurs, so you find it below...
>
> It would help me a lot, cos I really need the AST :-(
> Kristoff Tempelaere
>
>
>
> -------------------------- Call Stack -------------
> std::vector<std::pair<char const *,antlr::ASTRefCount<antlr::AST>
> (__cdecl*)(void)> *,std::allocator<std::pair<char const
> *,antlr::ASTRefCount<antlr::AST> (__cdecl*)(void)> *> >::begin()
> line 93 + 32 bytes
>
> std::vector<std::pair<char const *,antlr::ASTRefCount<antlr::AST>
> (__cdecl*)(void)> *,std::allocator<std::pair<char const
> *,antlr::ASTRefCount<antlr::AST> (__cdecl*)(void)> *> >::operator[]
> (unsigned int 232) line 132 + 37 bytes
>
> antlr::ASTFactory::create(antlr::RefCount<antlr::Token> {...}) line
> 155 + 49 bytes
> DmlSQL2Parser::query_spec() line 4991 + 50 bytes
> DmlSQL2Parser::simple_table() line 4924
> DmlSQL2Parser::query_primary() line 4898
> DmlSQL2Parser::query_term() line 4786
> DmlSQL2Parser::query_exp() line 579
> DmlSQL2Parser::select_stmt() line 210
> DmlSQL2Parser::sql_data_stmt() line 163
> DmlSQL2Parser::sql_stmt() line 100
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list