[antlr-interest] Re: Porting from antlr 2.7.1 to 2.7.4

Ric Klaren klaren at cs.utwente.nl
Thu Jul 8 08:23:45 PDT 2004


On Thu, Jul 08, 2004 at 02:18:35PM -0000, Sergey Bogdanov wrote:
> Sorry Ric, but this c++ implementation of heterogeneous asts *is*
> broken.

It's less broken than it was ;)

> One either has to fix it or the <AST=...> functionality should be
> completely removed. As minimum fix, a message should be provided if an AST
> type is changed for a token.

I agree with that. For now I'll add a warning message, which is indeed
something I missed when working on this stuff, I missed one spot. Although
with the current internals it will not be ideal still. (This whole
heterogeneous AST stuff is inside one of the worst parts of the C++
codegen)

> One more comment:
>     The C++ implementation that requires additional initialization,
> cloning and factory function puts to much burden on a programmer and
> maintainer, in particular when a base class could potentially mask
> these functions from c++ compiler.

Well the clone you won't get around whichever way you choose, if you only
got a baseclass pointer and you need to duplicate a node then you need a
clone() or something similar. The old implementation would merrily convert
all heterogeneous ast's to CommonAST's when using the supplied tree
duplication functions. The factory static method was already a requirement
for the old versions of antlr for custom AST's. So anyone mirroring the
antlr classes would already have them.

The 'super' factory is new but it's only a few lines of extra code in
initialization of a parser setup. Yes, a default would have been possible.
But then we'll have to see how many people don't read the documentation and
merrily have disjunct (and out of sync) factories in parsers,
treetransformers and treeparsers, with as result that they shoot themselves
in the foot. Now people have to initialize a few things more and it crashes
if you don't, e.g. clear behaviour. For people who read the docs things
will be ok. For the people who don't well....

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
  Chaos often breeds life, when order breeds habit.
  --- Henry B. Adams, The Education of Henry Adams



 
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