On Tue, Apr 20, 2010 at 03:21:00PM +0200, Giampaolo Tomassoni wrote:
> > Oops, I see placed the { after the $ earlier, where it should
> > be outside the $paramater, like {$parameter}, as in:
> > 
> > protected
> > conditionalExpression[CommonTree TheActualASTRoot]
> >     :   QMARK t=expression COMMA f=expression
> >             -> ^(ITE {$TheActualASTRoot} $t $f)
> >     |
> >     ;
> 
> Ah, that's it!
> 
> Right, it works. Thank you.
> 
> I'm a bit astonished with that, then: why a {$var} notation is needed here?
> What's the difference with $t and $f, in example?
> 
> Giampaolo

There are subtle differences in syntax depending on the context
of the variable, and in this case whether it is a parameter or not.

Another extension of the example shows another ANTLR feature,
with associated subtle syntax.  Say the conditionalExpression
was being called with TheActualASTRoot being optional, then
ANTLR supports this with semantic predicates on the tree generation
options:

protected
conditionalExpression[CommonTree TheActualASTRoot]
    :   QMARK t=expression COMMA f=expression
            -> {(TheActualASTRoot != null)}? ^(ITE {$TheActualASTRoot} $t $f)
            -> {(TheActualASTRoot == null)}? ^(ITE $t $f)
            ->
    |
    ;


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to