[antlr-interest] Token Streams, multiple lexers - how does lexer access selector?

David Penton djplists at arrowsash.com
Wed Dec 18 20:52:53 PST 2002


I am busy trying to set up multiple lexers to mimic lex/flex lexer
states.

In the antlr reference manual chapter on Token Streams, under Multiple
Lexers, the following example lexer fragment is given to "switch to the
JavaDoc lexer":

JAVADOC_OPEN
    :   "/**" {selector.push("doclexer");}
    ;

My question is: how does the lexer java class generated by antlr know
about selector, which is an antlr.TokenStreamSelector?  I mean, other
than editing the generated lexer class source files manually.  I don't
see anything that is intended to do this automatically, nor do I see a
way to embed code in the generated parser or lexer files. Thus the
reference the method call "selector.push(...)" prevents my lexer class
from compiling unless I edit it manually to have a selector instance
variable and an accessor method to set it.

Thanks.

- Dave Penton -






 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list