<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.5726" name=GENERATOR></HEAD>
<BODY
style="WORD-WRAP: break-word; webkit-nbsp-mode: space; webkit-line-break: after-white-space">
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN class=296350809-23022009><FONT face=Arial color=#0000ff size=2>Hi
Terence,</FONT></SPAN></DIV>
<DIV><SPAN class=296350809-23022009><FONT face=Arial color=#0000ff size=2>thank
you very much for your hint. In the meantime, I found a solution that works fine
for me. I now just pass in three lists in parallel (without a wrapping object)
and apply a anonymous template to them:</FONT></SPAN></DIV>
<DIV><SPAN class=296350809-23022009><FONT face=Arial size=2>entryMethod(once,
cols1, cols2, cols3)::=<<<BR> void
rule_r<first(col1)>(Map\<String, Attribut\> attrs, String
id){<BR> <if(once)><BR>
rule_r<first(col1)>_default(attrs);<BR>
<else><BR>
if(id.equals("<first(col3)>"))<BR>
{<BR>
rule_r<first(col1)>_<first(col2)>(attrs);<BR>
}<BR> <FONT color=#ff0000><rest(col1),
rest(col2),rest(col3):{one,two,three|<BR> else
if(id.equals("<three>")<BR> {<BR>
rule_r<one>_<two>(attrs);<BR>
}<BR></FONT>}><BR> <endif><BR>
}<BR>>></FONT></SPAN></DIV>
<DIV class=Section1>
<P style="MARGIN: 0cm 0cm 0pt"> </P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN class=296350809-23022009><FONT face=Arial
color=#0000ff size=2>Best regards,</FONT></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN class=296350809-23022009></SPAN><SPAN
class=296350809-23022009><FONT face=Arial color=#0000ff
size=2>Claus</FONT></SPAN> <?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></P>
<P>
<P class=MsoNormal style="MARGIN: 0cm -4.05pt 0pt -9pt; TEXT-ALIGN: center"
align=center><B style="mso-bidi-font-weight: normal"><SPAN
style="FONT-SIZE: 6.5pt; COLOR: navy; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt"></SPAN></B></P><FONT
face=Tahoma size=2>-----Ursprüngliche Nachricht-----<BR><B>Von:</B> Terence Parr
[mailto:parrt@cs.usfca.edu]<BR><B>Gesendet:</B> Montag, 23. Februar 2009
03:20<BR><B>An:</B> Seitter Claus-Jochen<BR><B>Cc:</B>
stringtemplate-interest@antlr.org<BR><B>Betreff:</B> Re:
[stringtemplate-interest] How to access properties of an attribute of
<first(multi-valued-attr)><BR><BR></FONT></P></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">if
everything is public then perhaps you're testing .one on some
other object? Perhaps an array of array not an array or something?
<DIV>Ter<BR>
<DIV>
<DIV>On Feb 20, 2009, at 7:03 AM, <<A
href="mailto:seitter.claus@muenchener-verein.de">seitter.claus@muenchener-verein.de</A>>
wrote:</DIV><BR class=Apple-interchange-newline>
<BLOCKQUOTE type="cite">
<DIV>
<DIV><FONT face=Arial size=2><SPAN class=374574114-20022009>Hi
all,</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=374574114-20022009>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</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=374574114-20022009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>if(id.equals("a.b.c"))</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>{</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>
rule_a_b_c();</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>}</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>else if(id.equals("a.b.d"))</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>{</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>
rule_a_b_d();</SPAN></FONT></DIV>
<DIV class=Section1>
<DIV style="MARGIN: 0cm 0cm 0pt"><FONT color=#0000ff> <SPAN
class=374574114-20022009><FONT face=Arial
size=2>}</FONT></SPAN></FONT></DIV>
<P style="MARGIN: 0cm 0cm 0pt"><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009></SPAN></FONT> </P>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009><FONT
face=Arial color=#0000ff size=2>..... .//many of
them</FONT></SPAN></DIV></DIV>
<DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>else if(id.equals("a.b.z"))</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>{</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=374574114-20022009>
rule_a_b_z();</SPAN></FONT></DIV>
<DIV class=Section1>
<DIV style="MARGIN: 0cm 0cm 0pt"><FONT color=#0000ff> <SPAN
class=374574114-20022009><FONT face=Arial
size=2>}</FONT></SPAN></FONT></DIV>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009><FONT
face=Arial size=2></FONT></SPAN> </P>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009><FONT
face=Arial size=2>here are my templates:</FONT></SPAN></DIV>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009><FONT
face=Arial size=2></FONT></SPAN> </P>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009><FONT
face=Arial color=#0000ff size=2>entryMethod(once,
rows3cols)::=<<<BR> void
rule_r<first(rows3cols).one>(Map\<String, Attribut\> attrs,
String id){<BR> <if(once)><BR>
rule_r<first(rows3cols).one>_default(attrs);<BR>
<else><BR>
if(id.equals("<first(rows3col).three>")<BR>
{<BR>
rule_r<first(rows3cols).one>_<first(rows3cols).two>(attrs);<BR>
}<BR>
<rest(rows3cols):entryIfs()><BR> <endif><BR>
}<BR>>><BR>entryIfs()::=<<<BR> else
if(id.equals("<it.two>")<BR> {<BR>
rule_r<it.one>_<it.three>(attrs);<BR>
}<BR>>></FONT></SPAN></DIV>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009><FONT
face=Arial size=2></FONT></SPAN> </P>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009><FONT
face=Arial size=2>the template is called from an antl3 tree
parser:</FONT></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009><FONT
face=Arial size=2><FONT
color=#0000ff>//--------------------------------------------------------------------------------<BR>entrytoken<BR>
: ENTRY<BR> -> entryMethod<BR> (<BR>
once={$rulestart::auths.size()== 1},<BR>
rows3cols={Utils.makeRows3Cols(Utils.makeList(new
Integer($all::ruleCnt).toString(),$rulestart::auths.size()),$rulestart::auths,Utils.dotList($rulestart::auths))}
<BR> )<BR>
;<BR>//--------------------------------------------------------------------------------</FONT></FONT></SPAN></DIV><SPAN
class=374574114-20022009><FONT face=Arial size=2><FONT
color=#0000ff></FONT></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN class=374574114-20022009></SPAN><FONT
face=Arial size=2>t<SPAN class=374574114-20022009>he Object array I
pass in is an Array of </SPAN></FONT></DIV><FONT face=Arial
size=2><SPAN class=374574114-20022009></SPAN></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#0000ff size=2><SPAN class=374574114-20022009>public class Row3Cols
{</SPAN></FONT></SPAN></DIV>
<DIV><FONT color=#0000ff></FONT> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#0000ff size=2><SPAN class=374574114-20022009> public String
one;<BR> public String two;<BR> public String
three;</SPAN></FONT></SPAN></DIV>
<DIV><FONT color=#0000ff></FONT> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#0000ff size=2><SPAN class=374574114-20022009> public
Row3Cols(String one, String two, String three) {<BR>
super();<BR> this.one = one;<BR>
this.two = two;<BR> this.three = three;<BR>
}</SPAN></FONT></SPAN></DIV>
<DIV><FONT color=#0000ff></FONT> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#0000ff size=2><SPAN class=374574114-20022009> public String
getOne() {<BR> return one;<BR>
}</SPAN></FONT></SPAN></DIV>
<DIV><FONT color=#0000ff></FONT> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#0000ff size=2><SPAN class=374574114-20022009> public String
getTwo() {<BR> return two;<BR>
}</SPAN></FONT></SPAN></DIV>
<DIV><FONT color=#0000ff></FONT> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#0000ff size=2><SPAN class=374574114-20022009> public String
getThree() {<BR> return three;<BR>
}</SPAN></FONT></SPAN></DIV>
<DIV><FONT color=#0000ff></FONT> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
size=2><SPAN class=374574114-20022009><FONT
color=#0000ff>}</FONT></SPAN></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
size=2><SPAN class=374574114-20022009><FONT
color=#0000ff></FONT></SPAN></FONT></SPAN> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
size=2><SPAN class=374574114-20022009>What happens is are exceptions on
runtime:</SPAN></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
size=2><SPAN class=374574114-20022009></SPAN></FONT></SPAN> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#ff0000 size=2><SPAN class=374574114-20022009>Class
[Lde.emvau.ruletool.compiler.Row3Cols; has no such attribute: one in
template context [ruleSetClass aliasesBlocksAndMethods
entryMethod]<BR>java.lang.NoSuchFieldException:
one</SPAN></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#ff0000 size=2><SPAN class=374574114-20022009>Exception in thread
"main" java.util.NoSuchElementException: no such attribute: rows3col in
template context [ruleSetClass aliasesBlocksAndMethods entryMethod
else_subtemplate]</SPAN></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#ff0000 size=2><SPAN
class=374574114-20022009></SPAN></FONT></SPAN> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
size=2><SPAN class=374574114-20022009>What am I missing? Any help
appreciated !</SPAN></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
size=2><SPAN class=374574114-20022009>Best
Regards,</SPAN></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
size=2><SPAN class=374574114-20022009>Claus</SPAN></FONT></SPAN></DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
color=#ff0000 size=2><SPAN
class=374574114-20022009></SPAN></FONT></SPAN> </DIV>
<DIV class=Section1><SPAN class=374574114-20022009><FONT face=Arial
size=2><SPAN class=374574114-20022009></SPAN></FONT></SPAN> </DIV><FONT
face=Arial size=2>
<DIV
style="MARGIN: 0cm 0cm 0pt"><BR></DIV></FONT></DIV></DIV>_______________________________________________<BR>stringtemplate-interest
mailing list<BR><A
href="mailto:stringtemplate-interest@antlr.org">stringtemplate-interest@antlr.org</A><BR>http://www.antlr.org/mailman/listinfo/stringtemplate-interest<BR></BLOCKQUOTE></DIV><BR></DIV></BLOCKQUOTE></BODY></HTML>