hi...been looking at this carefully. Only $type and $channel are ever
set with regularity. Setting those should not affect an invoking
lexer rule as in:
X : ID WS? '=' ID ; // result is X on normal channel
WS : ' '+ {$channel = HIDDEN; } ;
STRING : '"' (ESC|.)* '"' ; // result is STRING not ESC
FLOAT : INT '.' INT? ; // should be FLOAT
INT : Digit+ ;
fragment
Digit : '0'..'9' ;
So i made $channel also a local. At end of each nonfragment lexer
rule, i copy locals to state object. You might set line or char
position etc... but those are likely global attributes. This is an
inconsistent impl perhaps but a *minimal* runtime template change at
this late stage.
Jim, it still won't work for
X : ... {$type=Y; emit();} ;
but, shouldn't you really do:
X : ... {$type=Y; emit(A_TOKEN);} ;
as emit() is default at end of X?
I only changed two lines to make this work "better" now. Later we can
optimize out local alloc/copy.
Pushed. Fixes: http://www.antlr.org:8888/browse/ANTLR-225
edit //depot/code/antlr/main/CHANGES.txt#54
edit //depot/code/antlr/main/src/org/antlr/codegen/templates/Java/
Java.stg#128
edit //depot/code/antlr/main/src/org/antlr/test/TestLexer.java#12
Change 4840 submitted.
Ter
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org:8080/mailman/listinfo/antlr-dev