[stringtemplate-interest] set attributes in two templates from one rule

Sanjay Agravat sanjay.agravat at gmail.com
Wed Jan 2 06:32:29 PST 2008


Hi,

I have a template similar to this:

program (statement, instanceVars) ::= <<
  public class Program {
    <instanceVars:{i| private <i>;<\n>}>

    <statement; separator="\n"> <! this is where the inner class is inserted
among other possibilities !>
  }
>>

innerClassDecl(id, attributes) ::= <<
  private class <id; format="capital">  {
    <attributes>
  }
 <! the alternative to my approach is to create the instanceVar here instead
!>
>>

My situation is that I can't set the instanceVars attribute in the program
template until I get to the innerClassDecl rule in my intermediate AST
because the inner class should also be an instance variable in the enclosing
Program class.  The instanceVars should be set every time an inner class is
declared.  The innerClassDecl rule also has to set the statement attribute
so I am wondering if it's possible to set two attributes in two different
templates even after 1 of the templates has already been defined?  I thought
a region would work for me but then had a problem of how to set two
attributes (on two different templates) within 1 rule. I'm sure there must
be something I'm missing here...

Thanks,

Sanjay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org:8080/pipermail/stringtemplate-interest/attachments/20080102/c99613a6/attachment.html 


More information about the stringtemplate-interest mailing list