<div>>def : ^(DEF name expr) -> ^(DEF name $expr.value)<br>I tried some additional experiments. I don['t think you can access the attribute 'value' in the context of a tree rewrite.</div>
<div> </div>
<div>I reviewed my own experiements with tree rewriting. I found one can only reference tokens and rules(which are trees). I think you'll need to approach your rewrite in a different direction.</div>
<div> </div>
<div>hth,</div>
<div>Bernardo<br></div>
<div class="gmail_quote">On Tue, Jul 1, 2008 at 2:45 PM, Bernardo Elayda <<a href="mailto:belayda@gmail.com">belayda@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hmmmm.....<br>try this:<br>def : ^(DEF name mylabel=expr) -> ^(DEF name $mylabel.token.value)<br><br>Sometimes Antler 3.x has trouble figuring out where to get a value. In theory, I agree with your original code that $expr.value should have worked. Let me know if it still doesn't work. I've run into this issue myself, but I don't have any of my grammars here. I'll have to check this later this evening.<br>
<br>regards,<br><font color="#888888">Bernardo</font>
<div>
<div></div>
<div class="Wj3C7c"><br><br>
<div class="gmail_quote">On Tue, Jul 1, 2008 at 10:24 AM, Alvaro Egana <<a href="mailto:alvarorama@gmail.com" target="_blank">alvarorama@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Bernardo,<br><br>Thanks for yor quick answer. I did what you said but it didn't work. I<br>
get the same error (about the undefined rule 'value').<br><br>Alvaro<br><br>2008/7/1 Bernardo Elayda <<a href="mailto:belayda@gmail.com" target="_blank">belayda@gmail.com</a>>:<br>
<div>
<div></div>
<div>> Hi!<br>> Try this instead:<br>><br>> def : ^(DEF name mylabel=expr) -> ^(DEF name $mylabel.value)<br>><br>> hth,<br>> Bernardo Elayda<br>><br>><br>> ----------------------------<br>
> def : ^(DEF name expr)<br>> ;<br>> name : <<some rules>>;<br>><br>><br>> expr returns [String value]<br>> : <<some rules>><br>> ;<br>><br>><br>> I've been trying to do this rewrite:<br>
><br>> def : ^(DEF name expr) -> ^(DEF name $expr.value)<br>><br>> (I'm writing a name resolver ...)<br>><br>><br>><br>> But antlr complains saying there is a reference to an undefined rule<br>
> 'value'.<br></div></div></blockquote></div><br></div></div></blockquote></div><br>