[antlr-interest] @init actions in "C Target" have problems with MSVS compilers
Jim Idle
jimi at temporal-wave.com
Thu Mar 22 15:08:28 PDT 2007
No - it is just that in Java and C++ you can "get away" with doing that
so they can be placed there - besides if I say you can't do that in the
C target then you can't ;-P. Perhaps we should update those examples so
they don't do that. But it is horses for courses mate - C requies
certain ways of doing things and Java another.
We are subject to the rules of the target language and most C compilers
do not let us declare things inline, despite what the standard says
about that. However the best solution (if you need a variable that is in
scope for the whole rule) is to have @declarations, which I will
guarantee to insert before any code. This way everyone is happy and
nobody gets nailed to a cross.
Jim
-----Original Message-----
From: Gavin Lambert [mailto:antlr at mirality.co.nz]
Sent: Thursday, March 22, 2007 1:58 PM
To: Jim Idle; antlr-interest at antlr.org
Subject: Re: [antlr-interest] @init actions in "C Target" have problems
with MSVS compilers
At 08:19 23/03/2007, Jim Idle wrote:
>This is not really how you are supposed to use the @init rule
:-)
Oh yes it is. I've seen examples in the distribution and the
documentation that do exactly that :)
Though see my other post for a possible idea out of this, if you
really don't want to move where @init gets applied.
More information about the antlr-interest
mailing list