[antlr-interest] Problem when using scopes in C with ANTLR 3.4

Gonzague Reydet gonzague.reydet at gmail.com
Wed Feb 1 08:50:15 PST 2012


Hi!

See the following thread: http://antlr.markmail.org/thread/kq766wc2mbzuji2u
It is a bug in the C target generation template. I worked around this issue
applying a hotfix in the C.stg file contained in the antlr jar.
I don't know if Jim already treated this issue in antlr source tree.

Regards,
Gonzague

2012/2/1 Iron Bug <death.iron.bug at gmail.com>

> Greetings, everybody!
>
> I have found a problem with C code generation in ANTLR 3.4 (I used pure
> 3.4 from standard downloads).
>
> A simple grammar (just to show the problem):
>
> //////////////////////////////////////////////////////////////////////
> grammar test;
>
> options
> {
>  language              = C;
> }
>
> scope GlobalScope
> {
>        int scope;
> }
>
> @header
> {
> #include "antlr3.h"
> }
>
> command
> scope GlobalScope;
> @init
> {
>        $GlobalScope::scope = 10;
> }
>        :
>        VALUE
>        ;
>
> VALUE
>        :       ('0'..'9')+
>        ;
>
> /////////////////////////////////////////////////////////////////
> The grammar produces code with error in generated file testParser.c,
> line 321:
>
> SCOPE_TOP(GlobalScope) =
> (ptestParser_GlobalScope_SCOPE)(ctx->ptestParser_GlobalScopeStack->get(ctx->,
> ctx->ptestParser_GlobalScopeStack_limit - 1));
>
> (the ctx with reference to nowhere in the first parameter of get()).
> It goes all right in 3.3, though. Have I missed some changes in 3.4 or
> is this a bug?
>
> Sincerely, Yana A. Kireyonok
>
>
> 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