Unless you are parsing a set of very very simple statments then the short answer is no. There is no such thing as a simple grammar that can parse SELECT and INSERT statements. The complexity is that practically anywhere you can have a simple identifier (like a column name), you can have a complex expression, up to and including a fully specified subquery. As soon as you hit such a situation, things become very complicated. Because of the way SQL is defined, you are almost guaranteed to hit this situation very quickly- likely when you start to think about the WHERE clause. If you base your parser on the SQL2003 spec, you will need about 600 lexer and parser rules to handle what I would consider the core SQL SELECT, INSERT, UPDATE syntax. Alex Alexander Brown Partner | Analytics 8 | Tel +61 2 9299 4430 | Mob +61 424 043 485| [email protected] | www.analytics8.com
________________________________ From: [email protected] on behalf of [email protected] Sent: Fri 4/3/2009 06:00 To: [email protected] Subject: antlr-interest Digest, Vol 53, Issue 3 ------------------------------ Message: 25 Date: Thu, 2 Apr 2009 23:08:42 +0530 From: Ramakrishnan Venkataramani <[email protected]> Subject: [antlr-interest] ANTLR Grammar for SELECT statement To: [email protected] Message-ID: <[email protected]> Content-Type: text/plain; charset="iso-8859-1" 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 Regards Ramakrishnan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
