Thank you Gavin! This is indeed exactly the problem. After I ran into this I caved in and bought the Definitive ANTLR Reference manual, which does have a treatment of this also.
Thanks again: Bill M. > Date: Tue, 10 Mar 2009 21:00:21 +1300 > To: [email protected]; [email protected] > From: [email protected] > Subject: Re: [antlr-interest] Strings as Synthetic Attributes in ANTLR 3.1.2 > and ANTLRWorks 1.2.3. > > 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 _________________________________________________________________ Windows Liveā¢: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
