[antlr-interest] how to store parser result

Haiqiang Yan yhq323 at yahoo.com
Thu Feb 7 01:09:46 PST 2002


Hi all:
  I am trying to write a parser to parse the query statement (such as select * from ...) of SQL, and I want to store the structure of the query statement in a java Object. How should I do ? If I ought to embed many java code into .g file ? The following is a part of my .g file, I have add some java code in it to store the result. Please give me some advices. Thanks.
....
...
column_name [] returns [String colname = ""]
 : 
 (
 {Token tmp = null;}:
 tmp = table_name {colname += tmp.getText();}
 DOT   {colname += ".";}
 tmp = column_identifier {colname += tmp.getText();}
 {System.out.println("column_name:"+colname);}
 
 | tmp = column_identifier {colname += tmp.getText();}
   {System.out.println("column_name:"+colname);}
 )
 ;
....
....

regards
yhq323

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20020207/df365920/attachment.html


More information about the antlr-interest mailing list