[antlr-interest] [C] scope pop function

Jim Idle jimi at temporal-wave.com
Wed Nov 30 17:28:16 PST 2011


You can just download the source code, change the template, then build it
(Maven), or you can extract the jar, change the template and rebuild the
jar. Or you can place the new template in a file on the system and include
it in the classpath and it should be loaded before the one in the jar.

Jim

-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Gonzague Reydet
Sent: Thursday, December 01, 2011 12:41 AM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] [C] scope pop function

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(c
> tx->,
> 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

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list