[antlr-interest] @init actions in "C Target " have problems with MSVS compilers

Jim Idle jimi at temporal-wave.com
Thu Mar 22 15:04:03 PDT 2007


Yes - I can do that (add a new @declarations). I have not had much time
until recently to work on this other than to keep up to date with the
Java side. There are a few bugs to iron out and this is an enhancement
that may well be useful. However, the patch to the C.stg isn't quite as
simple as that, but it isn't too drastic - I'll see if I can put that
together today.

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 1:56 PM
To: Tobias Pape
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] @init actions in "C Target " have problems
with MSVS compilers

At 08:13 23/03/2007, Tobias Pape wrote:
 >What about patching ;) the C.stg ??
[...]
 >     ANTLR3_UINT32	    _type;
 >     ANTLR3_UINT64	    _start;
 >     ANTLR3_UINT64	    _end;
 >     ANTLR3_UINT64	    _line;
 >     ANTLR3_UINT32	    _charPosition;
 >     ANTLR3_UINT32	    _channel;
 >
 >     <ruleInitializations()>
 >     <ruleLabelInitializations()>
 >     ctx->pLexer->ruleNestingLevel++;
 >     _type	    = <ruleName>;
 >     _start	    = getCharIndex();
 >     _end	    = 0;
 >     _line	    = getLine();
 >     _charPosition   = getCharPositionInLine();
 >     _channel	    = ANTLR3_TOKEN_DEFAULT_CHANNEL;
 >
 >     <ruleDescriptor.actions.init>
 >     <ruleMemoization(name=ruleName)>

In actual fact, if I'm reading the wiki page right (and it's only 
briefly mentioned in one sentence, so could be wrong), actions can 
be defined on a target-specific basis.  So probably all that needs 
to get done is that *above* the <ruleInitializations()> line, add 
a new line with <ruleDescriptor.actions.decls> or similar.  Then 
you should be able to declare local variables in a @decls block 
rather than the @init block.



More information about the antlr-interest mailing list