[antlr-interest] @init actions in "C Target " have problems with MSVS compilers
Jim Idle
jimi at temporal-wave.com
Thu Mar 22 14:15:30 PDT 2007
Actually, I did fix the problem you reported and I emailed you to tell
you that it was fixed. Your problem was that when action code was in the
lexer rule the declarations were out of order. This is different - you
cannot DECLARE variables in @init.
Jim
-----Original Message-----
From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Gavin Lambert
Sent: Thursday, March 22, 2007 12:16 PM
To: Alexander Stasenko; antlr-interest at antlr.org
Subject: Re: [antlr-interest] @init actions in "C Target " have problems
with MSVS compilers
At 01:34 23/03/2007, Alexander Stasenko wrote:
>Consider the following rule with @init action:
>
> CharacterConstant @init {
> char c; int o;
> }
[...]
>MSVS 2005 compiler can not compiler it since "char c; int o;"
>declarations are placed after executable statements. This
>restriction was relazed in C99 standart which is unfortunately
>is not supported even in MSVS 2005 in its C-mode. Trying to
>compile in C++ mode causes other problems in other places,
>so usage of C++ mode is not a solution here.
I reported this one a couple of months back, but sadly it still
doesn't seem to have been fixed.
I did work around it by compiling in C++ mode, though, although it
required adding a lot of extern "C" blocks. But really the
codegen templates need to get fixed. Or we need to get another
code-insertion block that inserts at the top of the generated
function instead of further down.
More information about the antlr-interest
mailing list