[antlr-interest] @init actions in C Target have problems with MSVS compilers
Gavin Lambert
antlr at mirality.co.nz
Thu Mar 22 13:55:37 PDT 2007
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