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