[antlr-interest] Problem with ASTLabelType option and getAST method (C++)

Ric Klaren klaren at cs.utwente.nl
Thu Oct 28 06:50:42 PDT 2004


Hi Bryan,

On Wed, Oct 20, 2004 at 05:04:36AM -0400, Bryan Ewbank wrote:
> Found what I think is a bug in C++ code generation... Given the following:
> 
> 	class MyParser extends Parser;
> 	options { buildAST=true; ASTLabelType="RefTreeNode"; }
> 	...
> 
> The generated method MyParser::getAST() has the wrong type - it ends
> up as antlr::BaseAST, rather than using the type provided by the user
> in the ASTLabelType option.
> 
> I ended up coding around this by adding a getMyAST() method...

I tinkered a bit with this stuff a while ago probably in the release
candidates. It once did the thing you expected. But this gave trouble with
recent compilers that did not accept the return type of getAST changing
from the one specified in the base class (probably due to the reference
counter used not 100% sure, I still need to try the new reference counters
and see if that works, snapshots only use the new one for tokens so far) 

I could have moved the getAST into the generated parser class (and leave it
out of the base parser class) but that might break stuff for people that
need it in the base class.

Doing this should work though:

const RefMyAST the_ast = RefMyAST(parser->getAST());

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
     "Never argue with an idiot, for they will bring you down to their
              level and beat you with experience." --- 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