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

Terence Parr parrt at cs.usfca.edu
Sun Feb 22 18:20:03 PST 2009


if everything is public then perhaps you're testing .one on some other  
object?  Perhaps an array of array not an array or something?
Ter
On Feb 20, 2009, at 7:03 AM, <seitter.claus at muenchener-verein.de> wrote:

> 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
>
>
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20090222/03e67c1b/attachment.html 


More information about the stringtemplate-interest mailing list