Re: is lex useful?

Robert.Corbett@Eng.Sun.COM (Robert Corbett)
30 Jun 1996 16:39:51 -0400

          From comp.compilers

Related articles
[13 earlier articles]
Re: is lex useful? scooter@mccabe.com (Scott Stanchfield) (1996-06-27)
Re: is lex useful? Scott.Nicol@infoadvan.com (1996-06-27)
Re: is lex useful? Scott.Nicol@infoadvan.com (1996-06-27)
Re: is lex useful? 72510.2757@CompuServe.COM (Stephen Lindholm) (1996-06-27)
Re: is lex useful? kanze@lts.sel.alcatel.de (1996-06-27)
Re: is lex useful? bart@time.cirl.uoregon.edu (1996-06-30)
Re: is lex useful? Robert.Corbett@Eng.Sun.COM (1996-06-30)
Re: is lex useful? leichter@smarts.com (1996-06-30)
Re: is lex useful? trd@murlibobo.cs.mu.OZ.AU (1996-06-30)
Re: is lex useful? WStreett@shell.monmouth.com (1996-06-30)
Re: is lex useful? dmr@bell-labs.com (1996-06-30)
Re: is lex useful? clark@quarry.zk3.dec.com (1996-07-01)
Re: is lex useful? bromage@cs.mu.OZ.AU (1996-07-02)
[3 later articles]
| List of all articles for this month |
From: Robert.Corbett@Eng.Sun.COM (Robert Corbett)
Newsgroups: comp.compilers
Date: 30 Jun 1996 16:39:51 -0400
Organization: Sun Microsystems Computer Corporation
References: 96-06-094 96-06-129
Keywords: lex

In article 96-06-129,
>[Yup, that's what I said. Fortran needs a multi-pass lexer to correctly
>recognize that REAL*4HELLO doesn't contain the string constant 'ELLO'. -John]


A poor example. A lexer can recognize this case in a single
left-to-right scan with one character lookahead. The sequence


        letter+
        *
        digit+


at the start of a statement can be followed only by an identifier.


A better example is


            DO10I = expr1, expr2


Since the length of expr1 is bounded only by the number of characters
allowed in a statement, either a multipass lexer or practically
unbounded lookahead are needed.


Because Fortran limits the maximum size of a statement, a lexer for
Fortran can analyze any Fortran statement in constant time.


Sincerely,
Bob Corbett
[Right, thanks for the correction. In the DO10I example, note that just
looking ahead for a comma isn't sufficient. You have to look for a comma
not enclosed in parens, which lex can't do, because REs can't count. -John]


--


Post a followup to this message

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