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

Ric Klaren klaren at cs.utwente.nl
Thu Jul 8 05:15:53 PDT 2004


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 utwente.nl ----- +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