[antlr-interest] Re: Is there an ANTLR trick/hack to specify "NEWLINE or EOF" in Lexer

micheal_jor <open.zone at virgin.net> open.zone at virgin.net
Tue Feb 4 16:39:06 PST 2003


--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at j...> 
wrote:
> Hi Michael,
> 
> What if you just made NEWLINE normal and then subclass your lexer 
and 
> override nextToken so that you detect the EOF_TYPE coming in the 
token 
> and replace it with a NEWLINE token?

I did considered this option. At the time I felt it was equivalent to 
simply appending a NEWLINE to all input files automatically. I think 
I'll go with this now since Ric suggested something similar too. 
Thanks guys.

Incidentally, what's your opinion of point (2) below. You know, about 
ANTLR supporting a "virtual EOF char" that Lexers can match in rules.

NEWLINE
:  '\n'
|  '\r' ('\n')?
|  EOF                 // or $EOF or $eof
;

Cheers,

Micheal

> > 2. Perhaps ANTLR should support a "virtual EOF char" that can be
> > matched like any other char in Lexer rules in addition to the 
current
> > [upon]EOF end-of-file condition mechanism?



 

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



More information about the antlr-interest mailing list