[antlr-interest] Template for optional element
Mark Volkmann
r.mark.volkmann at gmail.com
Tue Jan 29 04:57:38 PST 2008
On Jan 29, 2008 1:57 AM, Oscar Pérez <oscar at perex.org> wrote:
> Hi.
>
> I'm new in ANTLR.
>
> I want to use a template for a rule like this:
>
> func: ^( Func ID params* body ) -> func(name={$ID.text},
> par={$params.st}, block={$body.st});
>
> but if there aren't params in source text, then broken!!!
>
> ¿How can I write a template for optional elements?
Does it solve the problem to use something like this in your template?
<if(params)><params><endif>
--
R. Mark Volkmann
Object Computing, Inc.
More information about the antlr-interest
mailing list