Re: how to handle lookahead in JLex?

jwilleke@ix.netcom.com (Jon Willeke)
30 Oct 1998 13:10:04 -0500

          From comp.compilers

Related articles
how to handle lookahead in JLex? jwilleke@ix.netcom.com (1998-10-24)
Re: how to handle lookahead in JLex? jwilleke@ix.netcom.com (1998-10-30)
Re: how to handle lookahead in JLex? cfc@world.std.com (Chris F Clark) (1998-10-30)
Re: how to handle lookahead in JLex? kleing@informatik.tu-muenchen.de (Gerwin Klein) (1998-11-01)
| List of all articles for this month |

From: jwilleke@ix.netcom.com (Jon Willeke)
Newsgroups: comp.compilers
Date: 30 Oct 1998 13:10:04 -0500
Organization: ICGNetcom
References: 98-10-155
Keywords: Java, lex

JLex doesn't advertise support for lookahead, but I've found that the
generated lexer stores the next input character as yy_lookahead. This
is adequate for the posted example.


It is not, however, adequate for another case. Consider this line of
code:


        h 2 h


The first "h" is an abbreviated form of the "hang" command, which
takes an argument. The second is an abbreviated form of the "halt"
command, which does not. I need two characters of lookahead.


--Jon


I wrote:


>I'm using JLex to write a lexer for M. I have a case that calls for
>lookahead, which JLex doesn't support. For example, consider this
>line of code:
>
> write $p($p,",")
>
>The first "$p" is an abbreviated form of the special function
>"$piece." The second "$p" is an abbreviated form of the special
>variable "$principal." I'd like the lexer to be smart enough to tell
>the difference, and it's easy with lookahead: functions are always
>followed by an open paren.


Jon Willeke <jwilleke@ix.netcom.com>


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.