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

Warner Onstine warnero at gmail.com
Tue Aug 28 17:59:49 PDT 2007


Awesome, thanks!

-warner

On 8/28/07, Terence Parr <parrt at cs.usfca.edu> wrote:
> I have updated 3.1 (next version) to do this automatically, but a few
> days ago you'll see in the archives that you need $blocks!=null?
> $block.st:null as the arg.
> Ter
> On Aug 28, 2007, at 4:28 PM, Warner Onstine wrote:
>
> > 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
>
>


-- 
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