[antlr-interest] Representations of AST

Alexander Brown abrown at analytics8.com
Thu Apr 2 08:00:52 PDT 2009


Hi,
 
Perhaps this will sound like a rather stupid question, but I am wondering if there is a better way to approach the problem I am trying to solve.
 
I am interested in parsing SQL.  I have developed a grammar based on the (overly complex) SQL2003 specification for my corpus (something like 1GB+) of SQL statements. I've also built a treewalker that walks my AST.  
 
My application is currently converting my AST into a Java-based semantic object model that, for all intents and purposes, reflects the structure of the AST on a 1:1 basis.  For my application, I need an object model based representation of SQL.
 
Building the object model and matching stringtemplate library has been extremely time consuming- there are something like 1000 rules in the SQL2003 spec and I have also built composite grammars that handle a superset of the spec such as DB specific constructs (old-school Oracle outer join syntax, for example) and procedural wrappers like PLSQL.   My treewalker has thus become intermingled with vast amounts of Java that builds my  sematic model and my Java object model has, of course, a large number of classes.  I am beginning to think that I have done this wrong.
 
After the horse has bolted, I am wondering- was there a better way to approach this?  I am particularly keen to encapsulate my semantic representation code and embed little or no Java in my TreeWalker (even if the 1:1 mapping remains).  I think I have missed a step somewhere.
 
Thanks for your input.

Regards,
 
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090402/bb363a40/attachment.html 


More information about the antlr-interest mailing list