[antlr-interest] Re: Manually insert a node into an automatically contructed tree
Terence Parr
parrt at cs.usfca.edu
Sat Mar 13 16:27:59 PST 2004
On Mar 13, 2004, at 11:31 AM, oliver_kellogg wrote:
> Terence Parr wrote:
>>
>> Oh, sorry about that...that rule has no content to match. Put this
>> imaginary root generation code in the rule where you actually match
>> stuff that needs an imaginary root.
>
> Ah, just to make sure I am understanding you:
> I changed the original
>
> component_list [boolean has_discrim]
> : component_items ( variant_part { has_discrim }? )?
> | empty_component_items variant_part { has_discrim }?
> ;
>
> to
>
> component_list [boolean has_discrim]
> : component_items ( variant_part { has_discrim }? )?
> |! vp:variant_part { has_discrim }?
> { #component_list =
> #(#[COMPONENT_LIST, "COMPONENT_LIST"],
> #(#[COMPONENT_ITEMS, "COMPONENT_ITEMS"]), #vp); }
> ;
>
> Is that what you had in mind?
Yup...if you only want the imag node on the second alt (that action
goes in 2nd alt, don't forget) :)
Ter
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list