[antlr-interest] switching lexer while parsing

mzukowski at yci.com mzukowski at yci.com
Wed Jan 22 08:23:51 PST 2003


The question was if he could switch lexers from the parser, and the answer
is no (I think Ter read it wrong).  Try doing it from the lexer, with lexer
streams as Ter suggests.

Monty

-----Original Message-----
From: Terence Parr [mailto:parrt at jguru.com]
Sent: Tuesday, January 21, 2003 11:07 PM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] switching lexer while parsing



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/ 


 

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



More information about the antlr-interest mailing list