Re: Is Fortran90 LL(1)?

Robert.Corbett@Eng.Sun.COM (Robert Corbett)
18 Apr 1996 13:42:05 -0400

          From comp.compilers

Related articles
Is Fortran90 LL(1)? rutzinger@takefive.co.at (Christian Rutzinger) (1996-04-04)
Re: Is Fortran90 LL(1)? mjohnson@samson.tx.hac.com (1996-04-08)
Is Fortran90 LL(1)? dave@occl-cam.demon.co.uk (Dave Lloyd) (1996-04-08)
Re: Is Fortran90 LL(1)? dlmoore@ix.netcom.com (1996-04-16)
Re: Is Fortran90 LL(1)? Robert.Corbett@Eng.Sun.COM (1996-04-18)
| List of all articles for this month |

From: Robert.Corbett@Eng.Sun.COM (Robert Corbett)
Newsgroups: comp.compilers
Date: 18 Apr 1996 13:42:05 -0400
Organization: Sun Microsystems Computer Corporation
References: 96-04-024 96-04-101
Keywords: parse, Fortran

>[To parse Fortran, you have to tell whether a statement is an
>assignment (or statement function) or something else. First, if you
>accept the old 3Hfoo Hollerith constants, you strip them out, being
>careful not to be confused by REAL*4HELLO. Then you look for an equal
>sign not protected by parentheses, and not followed by a comma which
>also must not be protected by parentheses. If you find the equal
>sign, and no comma, it's an assignment or a statement function. If
>not, it's something else. Once you've decided that, the lexing and
>parsing are pretty straightforward, with the parser at each stage
>having to tell the lexer what kind of tokens to look for. See my
>sample Fortran subset parser in the archives for an example of all
>this nonsense. -John]


There are still some tricky points in writing a Fortran grammar.
One problem is distinguishing a complex constant from an implied
DO-loop in a WRITE statement.


            WRITE (*, *) (1.0, 0.0)


and


            WRITE (*, *) (1.0, I = 1, 10)


look quite similar up to the second comma. A common way of dealing
with this case is to relax the restriction that the first part of a
complex constant must be a real or integer constant. Semantic routines
can report the error later if desired.


Sincerely,
Bob Corbett
[Yeah, in my compiler I allowed (exp,exp) as a general complex constructor,
and enforced the constant restriction semantically in places where I had to,
e.g. data statements. -John]




--


Post a followup to this message

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