[antlr-interest] Bug in ANTLR C# implementation

Bryan Ewbank ewbank at synopsys.com
Wed Dec 1 06:39:05 PST 2004


> Furthermore it's not always a simple matter which factory 
> should be used, at least in C++ you have to make sure you 
> share the factory over the various treeparsers you have to 
> prevent 'funny' behaviour..

My "solution" to this (I use a homogeneous AST) is to create a constructor
(target is C++) that accepts a Parser as an argument:
     /**
      * make this tree parser use the same ASTFactory as the given parser
      */
     SymScan(antlr::LLkParser& parentParser) : antlr::TreeParser()
     {
        antlr::ASTFactory *p_factory = parentParser.getASTFactory();
	  initializeASTFactory(*p_factory);
	  setASTFactory(p_factory);
     }

This way I avoid the excess code in the client, and all TreeParsers use the
same factory.



 
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