[antlr-interest] Having a problem with AST construction: rule fromClause alt 1 uses rewrite syntax and also an AST operator

Paul McKee paul.mckee at mckeetech.com
Wed Feb 11 14:22:29 PST 2009




Hello:

I'm a Newbie to ANTLR and I hope someone can offer me some advice. I'm trying to create a T-SQL Parser with output as an AST. I have:
options {
 backtrack=true;
 output=AST;
} 
Lines 410 and 411 of the grammar file are:

fromClause  :
 FROM! tableSource
 ( COMMA! tableSource )* -> ^(FROM tableSource)+
 ;

And this generates the error mesages:

[21:43:33] error(165): Z:\tsql\Tsql_a1.g:410:2: rule fromClause alt 1 uses rewrite syntax and also an AST operator
[21:43:33] error(165): Z:\tsql\Tsql_a1.g:411:4: rule fromClause alt 1 uses rewrite syntax and also an AST operator

However, when I split this into two rules as follows:

fromClause 
 : fromClause1 -> ^(FROM fromClause1);
fromClause1  :
 FROM! tableSource
 ( COMMA! tableSource )*  ;

Then it all works fine.
I am using the latest version of ANTLRworks.
Any help or ideas would be much appreciated.

Best Regards

Paul McKee


__________ Information from ESET NOD32 Antivirus, version of virus signature database 3846 (20090211) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090211/7ce24872/attachment.html 


More information about the antlr-interest mailing list