[antlr-interest] AST/rewrite rule question

Johannes Luber jaluber at gmx.de
Fri Jan 18 15:56:58 PST 2008


Ashish schrieb:
> Hi,
> If the start rule is specified without any rewrite rules all the queries 
> from the
> input are parsed and nodes are created for the select queries as expected.
> However if the start rule is modified to use the rewrite rule to create 
> the AST ie
>  
> from
>   selectQueries :  (selectQuery)*;
> to
>   selectQueries :  (sq+=selectQuery)* -> ^(SELECT_QUERIES $sq);
>  
> then, only the first query in the file seems to be parsed. The rest seem 
> to be ignored.
> Test file contents/program/grammar snippet  below.
>  
> Thanks
> Ashish

Did you try

selectQueries :  (sq+=selectQuery)* EOF -> ^(SELECT_QUERIES $sq);

?

Johannes


More information about the antlr-interest mailing list