[antlr-interest] switching lexer while parsing

Terence Parr parrt at jguru.com
Tue Jan 21 23:06:34 PST 2003


On Tuesday, January 21, 2003, at 10:18 PM, rmsanjivp 
<rmsanjivp at yahoo.com> wrote:

> Hi!
>
> can I switch lexer depending upon the context? I have a problem
> where in one mode a/b is to be treated as ID DIVIDE ID whereas in
> another place it must be treated as mere ID. I was thinking or
> having something that will switch the lexer while parsing depending
> upon the context.
>
> Is it possible?

Sure.  Easiest way is to use token streams.  See my javadoc example to 
see how I switch lexers for an embedded language.

Terence
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Lecturer in Comp. Sci., University of San Francisco


 

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



More information about the antlr-interest mailing list