[antlr-interest] dealing with an optional token and StringTemplates

Warner Onstine warnero at gmail.com
Tue Aug 28 16:28:55 PDT 2007


Ok, I've managed to get around some of my issues but I am now running
into one that I can't find an example to base it off of for ST use.

I have this rule:
selectStatement
	:	'Select' '(' ')' block? -> select_statement(block={$block.st})
	;

But when my Select() is not followed by a code block I get a
null-pointer exception when it tries to load this in my parser:
                retval.st = templateLib.getInstanceOf("select_statement",
              new STAttrMap().put("block", block11.st));

Which makes sense, I'm just trying to figure out how to call two
different ST calls (one for select_statement which has a  block and
one for when it doesn't). Or is there a better way to do this?

-warner

-- 
Warner Onstine - Programmer/Author
New book on Tapestry 4!
Tapestry 101 available at
http://sourcebeat.com/books/tapestrylive.html
warner at warneronstine.com
http://warneronstine.com/blog


More information about the antlr-interest mailing list