[antlr-interest] Scopes in lexers don't work
Johannes Luber
jaluber at gmx.de
Sun Jul 22 10:12:24 PDT 2007
Hello!
I've discovered that scopes declared in lexer grammar are generated only
half correct. There is simply no code which pushes a new object on the
stack. This results in an access violation every time I want to use the
scope. Below is Kay's grammar for testing purposes. I find it strange
that one can use scopes in pure lexers, if they aren't entirely
supported. Did this bug just fall through the cracks or am I forced to
use some global variables instead?
Best regards,
Johannes Luber
lexer grammar TestScope;
scope Scope {
int foo;
}
TOKEN
scope Scope;
: ('A' {$Scope::foo = 0;} |'B' {$Scope::foo = 1;}) SUBFOO 'B'
;
fragment
SUBFOO
: ({$Scope::foo > 0}? 'SUB') 'FOO'
;
More information about the antlr-interest
mailing list