Thanks, Sam... That works - never used those ST operators before.
On Sep 14, 2011, at 15:09 , Sam Harwell wrote: > I believe <if(rest(args))> will evaluate to true if args has more than one > item. > > Sam > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Bill Andersen > Sent: Wednesday, September 14, 2011 1:26 PM > To: antlr-interest > Subject: [antlr-interest] Need quick ANTLR/ST3 hack > > Folks > > I want to write a template containing a conditional expansion for a > multi-valued attribute that does one thing if the attribute is singleton and > another if there are more than 1 element > > For example, in an ANTLR grammar with ST output > > rule > : FOO (bars+=bar)+ -> foo(args={$bars}) > ; > > where the template looks like > > foo(args) ::= << > <if(???)> > something > <else> > something else > <endif> >>> > > I want some expression for ??? to test for args being singleton. > > Is this possible in ST3? Else I imagine I could write: > > rule > : FOO (bars+=bar)+ -> foo(args={$bars},singleton={$bars.size() == 1}) > ; > > and > > foo(args,singleton) ::= << > <if(singleton)> > something with args > <else> > something else with args > <endif> >>> > > ... but I would really rather not. > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > 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.
