[antlr-interest] ANTLR Grammar for SELECT statement
Sam Barnett-Cormack
s.barnett-cormack at lancaster.ac.uk
Thu Apr 2 10:41:42 PDT 2009
Ramakrishnan Venkataramani wrote:
> Hello,
> I am new to ANTLR. I am looking for a very simple SQL statement like
> SELECT and INSERT written in ANTLR grammar. I am also looking for the
> corresponding lexer, parser, and the test file (which reads the lexer,
> parser files and produces output). I saw the grammar _for
> PL/SQL_http://www.antlr.org/grammar/1209225566284/PLSQL3.g, it was so
> good, but it was humongous. so if possible can you please send me a
> simple ANTLR grammar for SELECT, INSERT.
>
> Thanks a lot for your kindly help
Well, I would advise you to:
1) Read the ANTLR documentation, preferably the book
2) Analyse the SQL statement syntax for the subset you want to work with
3) Specify that syntax in ANTLR
4) Add tree rewrites to get a meaningful AST
5) Write a tree parser to take action based on the AST
And then you're done.
Seriously, is this a coursework assignment or something?
Sam
More information about the antlr-interest
mailing list