[antlr-interest] ANTLR 3.0 tree construction proposal

Martin Probst mail at martin-probst.com
Mon Jan 31 14:34:02 PST 2005


I didn't have the time to really dig into that. Getting rid of #() and
#[] sounds good to me. Also removing {} actions for tree construction
etc. seems to be a good idea. ^^ on subrules is a thing I've been
looking for several times too.
I've never used tree rewriting though so I cannot be any help regarding
that. I'm just feeling uneasy with my ANTLR code because every time I
read it it takes me quite some time to figure out what the heck I'm
doing in there ;-)

> Do you think the new rewrite stuff would be easy to understand? Some of 
> surely would.  For example, build a flat tree with elements reordered:
> r : A B => B A ;

You really should use a different operator in this case. Parsers and
Lexers share the same operators (as they are basically the same as far
as I understand) so the user assumes this for tree parsers too. 
And this just looks like a wrong syntactic predicate.

Loring's stuff looks a little bit more consistent - ^{ } for actions,
^() for trees, ^[] for nodes. I'm not enough into it to decide what's

BTW is there currently a way of specifying that a (sub-)rule should stop
matching and exit? I've found myself trying to specify:
( A B => subruleB
| A C => subruleC
| else => return


More information about the antlr-interest mailing list