[antlr-interest] ANTLR3 Null variables in ST rewrite

Terence Parr parrt at cs.usfca.edu
Fri Mar 23 07:59:19 PDT 2007


good question.  Hm...try labeling accessModifier and then using  
{$label} inside the rewrite.
Ter
On Mar 23, 2007, at 7:41 AM, Kailey Joanette wrote:

> If I have a rule rewrite like:
>
>
>
> ^(CLASS_MEMBER accessModifier? (m+=modifier)* methodDeclaration)
>
>                                 -> classMember( access= 
> {$accessModifier.st}, mods={$m}, declare={$methodDeclaration.st} )
>
>
>
> If accessModifier doesn’t exist the .st will produce a null pointer  
> exception (correct?)  How do I avoid this?  Do I have to split the  
> rule into two?  One that has it and one that doesn’t?  Same goes  
> for the modifier* do I need to split it into modifier+ and no  
> modifier?
>
>
>
> Kailey
>
>
>
>



More information about the antlr-interest mailing list