[antlr-interest] Problems with Antlr3 rewrite rules

shmuel siegel antlr at shmuelhome.mine.nu
Mon Jun 4 03:40:53 PDT 2007


It seems that the problems were introduced with the move to 
RewriteRuleSubtreeStream. I don't see any other substantive changes in 
the generated parser code.

Shmuel Siegel wrote:
>
> I have upgraded my production grammar from 3.0b6 to the release 
> version. I am having two problems with the rewrite rules. Hopefully I 
> just missed a specification change.
>
>  
>
>     * Problem 1: When I have subclauses that do rewrites, the final
>       rewrite gets a null pointer exception. The following rule used
>       to work but now throws an exception. I avoid the exception if I
>       extract the parenthesized sub-rule and make it a named rule.
>
> assignEntityAttr:
>
>             (
>
>                         thisNode->thisNode
>
>                   |     symbolTableElement->symbolTableElement
>
>                   |     positionalElement->positionalElement
>
>             )
>
>             '.' a='attr' op='=' attr=attrValue     
>
>             -> ^(ASSIGN[$op] ^($assignEntityAttr PROPERTY[$a]) $attr)
>
>             ;
>
>  
>
>     * Problem 2: Tree construction seems to have changed. I used to be
>       able to write
>           o ^($ent PROPERTY[$a]) where $ent was itself a tree. When I
>             do it now, I keep the head of the $ent tree but its
>             children are replaced by the PROPERTY token.
>
>  
>
>  
>
> What has changed since b6?
>
>  
>
> Shmuel
>




More information about the antlr-interest mailing list