[antlr-interest] feeding conditional terms to stringtemplate

Terence Parr parrt at cs.usfca.edu
Thu Feb 14 17:22:53 PST 2008


On Feb 14, 2008, at 2:07 PM, siemsen at ucar.edu wrote:

> I've got this rule in an ANTLR 3 grammar:
>
> qualifierDeclaration
> 	: QUALIFIER qualifierName COLON qualifierType qualifierFlavorList?  
> SEMICOLON
>         {
> 		qualifierDefinition qDef = new qualifierDefinition(
> 			$qualifierName.text,
> 			$qualifierType.type,
> 			$qualifierFlavorList.fList);
> 	}
>     ;
>
> It works fine when a qualifierFlavorList exists in the input  
> stream.  When it doesn't, I get a NullPointerException because  
> $qualifierFlavorList.fList isn't defined.  To make it work, I did  
> this:

3.1 will have the null ptr guard done automatically.
Ter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080214/c1590611/attachment.html 


More information about the antlr-interest mailing list