[antlr-interest] Tree construction

Ruth Karl ruth.karl at gmx.de
Mon Jul 2 04:04:29 PDT 2007

Dear all,

I think it is amazing and very good to kno that some people in this 
world spend so much time and effort in open source projects and in 
making great tools available for everyone.
I do not think at all that it is of any help to bother them with 
complaints. The ones who do are free to do a better job - if they think 
that is easy!

Because it is so sad to read the "Lack of "-thread this morning (how 
about lack of politeness?), I feel the urgent need to start my mail with 
this remark and pay BIG THANKS to everyone who is actively contributing 
to make life better for others, too.

Maybe someone can give me a clue about the following issue:
I made up some parser rules with different alternatives that can be 
repeated in any possible order.
One of those rules looks like this:

    htmltag    :    OPENTAG (SLASH)? ((text | bracketexpr | quoted |
    scriptlet)+ (PERCENT)* )*  CLOSETAG ;

No if I add the following tree construction rule:

    ->^(HTMLTAG text* bracketexpr* quoted* scriptlet*)

and parse something like

    <meta http-equiv="Content-Type" content="text/html">

I get a result that sorts texts and quotes, like:

    <HTMLTAG meta http-equiv=  content= <QUOTE Content-Type> <QUOTE

This does not really surprise me, but I would like to find out how I 
should put the tree construction rule in order to get the child nodes in 
the order of their appearance in the parsed text.
Is there a way to do it without touching/splitting the parser rule?

Thanks in advance for any kind of help, as always,



More information about the antlr-interest mailing list