[stringtemplate-interest] Including optional keywords as parameters to String Template

jevitha jevitha at gmail.com
Fri May 15 18:37:05 PDT 2009


Hi ,

ya .. but that should be sent only if it exists in my input ... so is there
an equivalent of ? in string template rewrite rules?
So that in the example

className : (('.module')? name1 ) slashedName ;

.module will be sent only if it occurs ?

in parser and tree grammar ? is supported, is it the same with string
template rewrite rule ...


On Fri, May 15, 2009 at 10:43 PM, Terence Parr <parrt at cs.usfca.edu> wrote:

> I'd label it with t='.module' and then pass it in as $t.Ter
> On May 14, 2009, at 10:48 PM, jevitha wrote:
>
>
> Hi,
>
>   I have a rule in my tree grammar (same in my parser grammar) which has
> optional attribute which can occur in my input :
>
> className : (('.module')? name1 ) slashedName ;
>
> How can i construct a string template to include the optional attribute
> (here its .module) to be sent as a parameter to the template only if it
> occurs ... Since it is a keyword, and there is no separate lexer rule
> written to match '.module' separately, I dono how to pass the .module
> keyword as optional parameter to the template.
>
> .module keyword should be filled in the blank space of the following
> rewrite rule:
>
> className : (('.module')? name1 ) slashedName
>        -> className(....... assemblyname = {$name1.st}
> methodname={$slashedName.st})
>       ;
>
> Kindly suggest.
>
> Best Regards,
> Jevitha
>
>  _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
>
>


-- 
Best Regards,
Jevitha

"Faith is to believe what you do not see; the reward of this faith is to see
what you believed in."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20090516/8a9db0f8/attachment.html 


More information about the stringtemplate-interest mailing list