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

clay_douglass_at_work clay.douglass at conformative.com
Wed Jun 23 09:25:44 PDT 2004


--- In antlr-interest at yahoogroups.com, "clay_douglass_at_work" 
<clay.douglass at c...> wrote:
> I am implementing an expression parser for an interactive 
debugger. 
> Unfortunately the generated parser causes underactivity issues. 
e.g. 
> It doesn't return the command till I hit return twice. I guess 
this 
> is an obvious side effect of the look-ahead k=2. I had though 
since 
> each command pattern ended in NEWLINE that I would get command 
> returned as soon as the parser saw the NEWLINE. Any helpful 
> suggestion or is my plan to use ANTLR to parse the interactive 
> commands just a bad idea?
> 
> Thank,
> 
> Clay

Well I figured out that

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

was the issue not look ahead in general. Since my input source is 
generating only '\r' when I hit enter the rule needed the next 
character to correctly determine the match. To fix this I removed 
the '\r''\n' part 

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

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() ?






 
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