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

Terence Parr parrt at cs.usfca.edu
Wed Feb 11 14:30:37 PST 2009


Hi Paul, don't use ! and ->.  Just remove ! here and life is good.
Ter
On Feb 11, 2009, at 2:22 PM, Paul McKee wrote:

>
>
> 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
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list