[antlr-interest] Problem with $type in final ANTLR 3.0
Jose San Leandro
jose.sanleandro at ventura24.es
Thu Jun 21 03:18:19 PDT 2007
Hi,
I've been using a grammar which used $type keyword (the replacement of ANTLR2
setType()[1]) to guide the lexer and define explicitly the type of the
matched token:
fragment AT
: ( ('@static') => STATIC {$type = STATIC;}
| ('@isa') => ISA {$type = ISA;}
| ('@isatype') => ISATYPE {$type = ISATYPE;}
| '@')
;
With ANTLR 3.0 (Relased May 17), I get compilation errors in the generated
lexer:
[..]
switch (alt1) {
case 1 :
// PerComment.g:575:11: ( '@static' )=> STATIC
{
mSTATIC(); if (failed) return ;
if ( backtracking==0 ) {
_type = STATIC;
}
[..]
The _type variable is not defined.
This issue has a different flavour on non-"fragment" rules:
[..]
this.type = _type;
}
finally {
}
}
// $ANTLR end AT
The compilation stops since type is not a declared attribute.
Do you have any suggestions?
Kind regards,
Jose.
More information about the antlr-interest
mailing list