[antlr-interest] Re: Updated version of C# codegen 2.7.2a2 now on ANTLR site
Micheal J
open.zone at virgin.net
Wed Jul 17 21:42:06 PDT 2002
> -----Original Message-----
> From: Kpako [mailto:kpako at yahoo.com]
> Sent: 18 July 2002 03:26
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Re: Updated version of C# codegen 2.7.2a2 now
> on ANTLR site
>
>
> The following Lexer rule
>
> IDENT_OR_RULE_BEGIN
> : (IDENT "::=") => RULE_BEGIN {$setType(RULE_BEGIN); }
> | IDENT { $setType(IDENT); }
> ;
>
> generates
>
> if ( synPredMatched30 )
> {
> mRULE_BEGIN(false);
> if (0==inputState.guessing)
> {
> _ttype = RULE_BEGIN;
> }
> }
>
>
> among others instead of
>
>
> if ( synPredMatched30 )
> {
> mRULE_BEGIN(false);
> if (0==inputState.guessing)
> {
> _ttype = FooTokenTypes.RULE_BEGIN;
> }
> }
>
>
> is this a bug or am I doing something wrong?
Thank you for the feedback on the C# code generator. This is actually a
documented (?) feature. ;-)
You need to prefix the token name with the TokenTypes class name in the
"$setType" statement (as well as other references to tokens in the .g file).
This is due to differences in the way interface inheritance works in Java
and C#. In C# you have to specify the name of the class as a prefix.
Your example should read:
IDENT_OR_RULE_BEGIN
: (IDENT "::=") => RULE_BEGIN {$setType(FooTokenTypes.RULE_BEGIN); }
| IDENT { $setType(FooTokenTypes.IDENT); }
;
Thanks,
Micheal
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list