[antlr-interest] Bug for C-Target on $tree usage
Jim Idle
jimi at temporal-wave.com
Wed Nov 26 18:35:47 PST 2008
On Wed, 2008-11-26 at 23:42 +0100, Christian Hoffmann wrote:
> Hello,
>
> converting from antlr2 to antlr3 becomes a horror! ;-)
>
>
> Now I am tumbling over some c-codegeneration.
> Don't know if its me or a real bug...
Could be a real bug - I'll look on Friday.
Try $declaration rather than $tree though.
Jim
>
>
> declaration
> : declSpecifiers variableDeclarations
> -> ^(TOK_VAR_DEF declSpecifiers variableDeclarations)
> { m_Symbols.AddVarDef($tree); } // add the variable
> ^^^^problem is here
> ;
>
>
> should result to somthing like
> { m_Symbols.AddVarDef(retval.tree); } // add the variable
>
> instead the resulting c-code becomes
> m_Symbols.AddVarDef(((pANTLR3_COMMON_TOKEN)retval).tree); );
>
> 2 Bugs in one line!
> 1. bug: retval.tree is not a pANTLR3_COMMON_TOKEN, its of type pANTLR3_BASE_TREE
>
> Bugfix??: C.stg lines 3013 and 3035 ??
> line 3013> rulePropertyRef_tree(scope,attr) ::= "retval.tree"
> line 3050> ruleSetPropertyRef_tree(scope,attr,expr) ::= "retval.tree=<expr>;"
>
> 2. bug:
> original code:
> ADAPTOR->addChild(ADAPTOR, root_0, pVMCompiler->m_Symbols.AddVarDef(((pANTLR3_COMMON_TOKEN)retval).tree); );
> look at the end of the line,
> somthing like func(... func(...); ); would not compile ;)
> Bugfix:
> Swapping the lines helps, but...
> declaration
> : declSpecifiers variableDeclarations
> { m_Symbols.AddVarDef($tree); } // add the variable
> -> ^(TOK_VAR_DEF declSpecifiers variableDeclarations)
> ;
>
>
> Thx in advance for your comments...
>
>
> ---
> Christian Hoffmann
> D-38118 Braunschweig
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081126/8ed8949b/attachment.html
More information about the antlr-interest
mailing list