[stringtemplate-interest] How to access properties of an attribute of <first(multi-valued-attr)>

seitter.claus at muenchener-verein.de seitter.claus at muenchener-verein.de
Fri Feb 20 07:03:56 PST 2009


Hi all,
I just got stuck with the syntax of accessing properties of an attribut that is the result of an operation like <first(multi-valued-attr)>. My intention is to output text for java if clauses like
 
if(id.equals("a.b.c"))
{
    rule_a_b_c();
}
else if(id.equals("a.b.d"))
{
    rule_a_b_d();

 }

 

.....    .//many of them

 
else if(id.equals("a.b.z"))
{
    rule_a_b_z();

 }

 

here are my templates:

 

entryMethod(once, rows3cols)::=<<
  void rule_r<first(rows3cols).one>(Map\<String, Attribut\> attrs, String id){
   <if(once)>
     rule_r<first(rows3cols).one>_default(attrs);
   <else>
       if(id.equals("<first(rows3col).three>")
       {
         rule_r<first(rows3cols).one>_<first(rows3cols).two>(attrs);
       }
     <rest(rows3cols):entryIfs()>
   <endif>
  }
>>
entryIfs()::=<<
  else if(id.equals("<it.two>")
  {
    rule_r<it.one>_<it.three>(attrs);
  }
>>

 

the template is called from an antl3 tree parser:

//--------------------------------------------------------------------------------
entrytoken
  : ENTRY
  -> entryMethod
  (
    once={$rulestart::auths.size()== 1},
    rows3cols={Utils.makeRows3Cols(Utils.makeList(new Integer($all::ruleCnt).toString(),$rulestart::auths.size()),$rulestart::auths,Utils.dotList($rulestart::auths))} 
  )
  ;
//--------------------------------------------------------------------------------

the Object array I pass in  is an Array of 

public class Row3Cols {
 
  public String one;
  public String two;
  public String three;
 
  public Row3Cols(String one, String two, String three) {
    super();
    this.one = one;
    this.two = two;
    this.three = three;
  }
 
  public String getOne() {
    return one;
  }
 
  public String getTwo() {
    return two;
  }
 
  public String getThree() {
    return three;
  }
 
}
 
What happens is are exceptions on runtime:
 
Class [Lde.emvau.ruletool.compiler.Row3Cols; has no such attribute: one in template context [ruleSetClass aliasesBlocksAndMethods entryMethod]
java.lang.NoSuchFieldException: one
Exception in thread "main" java.util.NoSuchElementException: no such attribute: rows3col in template context [ruleSetClass aliasesBlocksAndMethods entryMethod else_subtemplate]
 
What am I missing? Any help appreciated !
Best Regards,
Claus
 
 




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20090220/38b8a51f/attachment.html 


More information about the stringtemplate-interest mailing list