[antlr-interest] Check for null ?

Vincent Dupuis vincedupuis at hotmail.com
Thu Aug 6 14:40:21 PDT 2009


Hello,

I would like to know if I need to "check for null" for every 
optional sub rule return value.

Like in the following example:

event
@init
{
    StringTemplate ddd = new StringTemplate();
    StringTemplate iii = new StringTemplate();
    String ggg = new String();
}
    :   'on' n=IDENT ('if' i=identifierList)? ('do' d=identifierList)? ('goto' g=IDENT)?
        {
            if (d != null) ddd = $d.st;
            if (i != null) iii = $i.st;
            if (g != null) ggg = $g.text;
        }
        -> event(eventName={$n.text}, doList={ddd}, ifList={iii}, gotoSate={ggg})
    ;

Thank you,

Vincent


_________________________________________________________________
Avec Windows Live, vous gardez le contact avec tous vos amis au même endroit.
http://go.microsoft.com/?linkid=9660830
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090806/0055b0be/attachment.html 


More information about the antlr-interest mailing list