how to handle lookahead in JLex?

jwilleke@ix.netcom.com (Jon Willeke)
24 Oct 1998 01:52:45 -0400

          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: 24 Oct 1998 01:52:45 -0400
Organization: ICGNetcom
Keywords: Java, lex, question

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.


Some other lex features that JLex appears to lack are: input(),
unput(c), and REJECT. The generated lexer uses BufferedReader. I
haven't had any luck replacing it with PushbackReader.


I'm not ready to jump ship to JavaCC or ANTLR yet. Any suggestions?


--Jon


Jon Willeke <jwilleke@ix.netcom.com>


Post a followup to this message

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