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

Jim Idle jimi at temporal-wave.com
Wed Feb 1 09:44:35 PST 2012


Could well be a bug - when 3.4 changed template engines there were updates
to the templates and I am beginning to feel that we did not test it quite
well enough. I have added it to the list. I have fixed one or two other
small template items and have a fix to find for tree rewriting templates
too. I will discuss with Ter as to a reasonable time for a 3.4 bug fix
release.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Iron Bug
> Sent: Wednesday, February 01, 2012 8:13 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Problem when using scopes in C with ANTLR 3.4
>
> 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