[antlr-interest] [C] scope pop function

Gonzague Reydet gonzague.reydet at gmail.com
Wed Nov 30 08:41:13 PST 2011


After a more deeper look into the ANTLR codegen template, I suspect this is
a bug in the C.stg file.
There is a typo error in the globalAttributeScopeFuncMacro. The template
call a "bscopeStack" subtemplate instead of "scopeStack" subtemplate.
Do you want me to fill a bug for this issue in jira?

Is it possible to get this bug quickly fixed somehow in a nightly build?
I did not find any nightly build download nor public access to the ANTLR
SCM.

Is there a workaround on this issue appart from modifying generated code
manually?

2011/11/30 Gonzague Reydet <gonzague.reydet at gmail.com>

> Hi all,
>
> When I try to use a scope in my tree parser, I encounter an error in the
> generated code.
> The scope pop function is generated as follow (I removed the generated
> comments to make it more readable) :
>
> void pmyparser_tree_myScopePop(pmyparser_tree ctx)
> {
>     if    (SCOPE_TOP(myScope)->free != NULL)
>     {
>         SCOPE_TOP(myScope)->free(SCOPE_TOP(myScope));
>     }
>
>     ctx->pmyparser_tree_myScopeStack_limit--;
>     SCOPE_TOP(myScope) =
> (pmyparser_tree_myScope_SCOPE)(ctx->pmyparser_tree_myScopeStack->get(ctx->,
> ctx->pmyparser_tree_myScopeStack_limit - 1));
> }
>
> As you can see in the last function line, the first parameter of the get
> function call is missing a field descriptor: "get(ctx->, ...)".
> Is there something wrong in my parser to provoque this issue? Is this a
> known issue of ANTLR 3.4?
>
> The tree parser generator outputs the following messages that I don't
> really understand :
>
> ASTTreeParser.stg 321:25: anonymous template has 0 arg(s) but mapped
> across 1 value(s)
> ASTTreeParser.stg 323:25: anonymous template has 0 arg(s) but mapped
> across 1 value(s)
> context [/outputFile /treeParser /genericParser /_sub50
> /globalAttributeScopeFuncMacro] 24:112 no such template: /bscopeStack
> context [/outputFile /treeParser /genericParser /_sub50
> /globalAttributeScopeFuncMacro] 24:113 passed 1 arg(s) to template null
> with 0 declared arg(s)
> context [/outputFile /treeParser /genericParser /_sub50
> /globalAttributeScopeFuncMacro] 24:113 attribute sname isn't defined
> context [/outputFile /treeParser /genericParser /rule /ruleCleanUp] 13:5
> passed 1 arg(s) to template /_sub16 with 0 declared arg(s)
> context [/outputFile /treeParser /genericParser /rule /ruleCleanUp] 15:5
> passed 1 arg(s) to template /_sub17 with 0 declared arg(s)
> ...
> context [/outputFile /treeParser /genericParser /rule /ruleCleanUp] 13:5
> passed 1 arg(s) to template /_sub16 with 0 declared arg(s)
> context [/outputFile /treeParser /genericParser /rule /ruleCleanUp] 15:5
> passed 1 arg(s) to template /_sub17 with 0 declared arg(s)
>
>
> Regards,
> Gonzague
>



-- 
Tél : +33 (0)6 21 02 90 48


More information about the antlr-interest mailing list