that has been my experience as well with tree rule rewrites.<br>the re-written node must be composed of pre-existing rule reference(no parameters) or the construction of a new token.<br><br>-Bernardo<br><br><br><div class="gmail_quote">
On Wed, Jul 2, 2008 at 2:06 PM, Gavin Lambert <<a href="mailto:antlr@mirality.co.nz">antlr@mirality.co.nz</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
At 14:57 2/07/2008, Bernardo Elayda wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>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.<br>
</blockquote>
<br>
Have you tried this:<br>
<br>
def : ^(DEF name expr) -> ^(DEF name {$expr.value}) ;<br>
<br>
(Not sure if that's right either, but I have seen some examples using something similar.)<br>
<br>
Having said that, AST nodes can usually only be tokens -- you can't add a raw string to it. So you'll probably need to do something like this instead:<br>
<br>
def : ^(DEF name expr) -> ^(DEF name STRING[$expr.value]) ;<br>
<br>
(Not entirely sure about that syntax, but it's something like that.)<br>
<br>
</blockquote></div><br>