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

David Penton djplists at arrowsash.com
Thu Dec 19 13:51:39 PST 2002


Thanks.

I'm jut learning my way around the documentation & examples.

I am a bit abashed to realize, now that I read your email and look at
the example, that my question was really a java question rather than an
antlr question - of course, a public static selector in Main would be
accessible from a lexer.

As a former college prof of mine one said "There is such a thing as a
stupid question.  Please be afraid to ask such questions."

- Dave -
On Thu, 2002-12-19 at 11:05, mzukowski at yci.com wrote:
> Look at the examples\java\multiLexer example.  You have to create the
> selector instance variable yourself or provide a public static class that
> can hold it.
> 
> Monty
> 
> -----Original Message-----
> From: David Penton [mailto:djplists at arrowsash.com]
> Sent: Wednesday, December 18, 2002 8:53 PM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Token Streams, multiple lexers - how does
> lexer access selector?
> 
> 
> 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/ 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 



 

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



More information about the antlr-interest mailing list