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

Sergey Bogdanov serge.bogdanov at intel.com
Thu Jul 8 07:18:35 PDT 2004


Sorry Ric, but this c++ implementation of heterogeneous asts *is*
broken. 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.

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.

cheers.

--- In antlr-interest at yahoogroups.com, Ric Klaren <klaren at c...> wrote:
> On Thu, Jul 08, 2004 at 11:39:28AM -0000, Sergey Bogdanov wrote:
> > world : rule1 | rule2; 
> > rule1 : "int" <AST=IntAST>;
> > rule2 : "const"! "int" <AST=ConstIntAST>;
> 
> The C++ implementation only support a one on one mapping of tokentype to
> AST type. Not a matter of being broken but of choice. If you
*really* want
> this you can create the node outside of the ASTFactory though. Another
> option is to make a dummy tokentype for the const version and use
that in
> the tree construction (It might be that a future support lib version
does
> not allow the below code, then the dummy node will still work).
> 
> rule2 : "const"! "int"! { ## = RefAST( new ConstIntAST( ... ) ); }
> 
> If I recall right the rest of the tree copy support etc. should do the
> right thing nowadays and clone it if copied.
> 
> Cheers,
> 
> Ric
> --
>
-----+++++*****************************************************+++++++++-------
>     ---- Ric Klaren ----- j.klaren at u... ----- +31 53 4893755  ----
>
-----+++++*****************************************************+++++++++-------
>   "Good judgement comes from experience.
>      Experience comes from bad judgement." --- Unknown



 
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