[antlr-interest] Re: Tree weirdness C++ mode
Brad Schick
schick at robotbattle.com
Tue May 4 00:25:08 PDT 2004
>In a parser with C++ as a target, building a tree the
>following way does not work:
>
> ##->addChild(#[EMPTY,"empty"]);
>
>Instead I have do to this:
>
>astFactory->addASTChild(currentAST, #[EMPTY,"empty"]);
I can think of two possible work arounds that are more language
agnostic.
1) Add a bogus empty rule that injects the fake node:
rule: A B empty;
empty : { ##=#[DECLARE,"empty"]; };
2) Label everything and build the entire tree manually:
rule : a:A b:B {##=#(#antlr::nullAST,#a,#b,#[EMPTY,"empty"]);};
The second solution messes with your grammar less, but it still
language dependent. It seems cleaner than the calling astFactory
directly though.
-Brad
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