At 09:45 10/03/2009, Foolish Ewe wrote:
>When I run it I get the output:
>op=<+> (Hardwired!), lhs=<2>, rhs=<3>, result_attr=<+23>
>e.text = <2 + 3>
>
>Note that e.text shows the infix order from the inputs, so I'm 
>guessing the synthetic attribute isn't being successfully 
>transmitted to stat from expr, have I goofed or is this a bug in 
>ANTLR?
[...]
>// Here we should see the prefix version of the synthetic 
>attribute of expr
>stat:   e=expr NEWLINE {System.out.println("e.text = <" + $e.text 
>+ ">");};
>
>// Creates a synthetic string attribute (bottom up).
>// given an infix order sum operation the attribute string 
>reflects a prefix order expression
>expr returns [String result_attr]:    lhs=NUM '+' rhs=NUM
>     {    $result_attr = '+' + $lhs.text + $rhs.text;
>         System.out.println("op=<+> (Hardwired!), lhs=<" + 
> $lhs.text +
>              ">, rhs=<" + $rhs.text + ">, result_attr=<" + 
> $result_attr + ">");
>     }
>     ;

You are assigning your custom text to a return value called 
"result_attr".  This will, naturally enough, appear in the parent 
rule as $e.result_attr, not as $e.text.


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to