[antlr-interest] Re: look ahead side effects on interactive parsers

Monty Zukowski monty at codetransform.com
Wed Jun 23 09:36:34 PDT 2004


NEWLINE :
	(
		'\n' {if (!prevWasReturn) newline();}
		| '\r' { newline(); }
	);

then override match() in your lexer and do something like this:

match(?)
{
	super.match();
	if matched character was '\r' then prevWasReturn=true;
	else prevWasReturn=false;
}

Give it a try & let me know.

Monty

On Jun 23, 2004, at 9:25 AM, clay_douglass_at_work wrote:

>
> Now it work right except it counts lines wrong on some
> systems/files. Is there an easy mechanism to look at the previous
> character to decide if I should call newline() ?

ANTLR & Java Consultant -- http://www.codetransform.com
ANSI C/GCC transformation toolkit -- 
http://www.codetransform.com/gcc.html
Embrace the Decay -- http://www.codetransform.com/EmbraceDecay.html



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

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



More information about the antlr-interest mailing list