[comp.lang.fortran] Wanted: Fortran Specification

jchen@pollux.usc.edu (Joseph S. Chen) (01/30/88)

Hi,

   Does anyone have or know how to get a copy of Fortran-77 lexical
definition in regular expression form and syntatic definition in BNF?
It's fine if the specifications are not "lex" and "yacc" compatible.
Thanks in advance.

					Joe Chen


Phone (213) 743-2957
University Computing Services, University of Southern California
UUCP: {sdcrdcf, uscvax}!usc-oberon!joec
ARPA: joec@oberon.usc.edu, jchen@pollux.usc.edu, joec@cse.usc.edu

pcm@iwarpo3.intel.com (Phil C. Miller) (02/03/88)

In article <6592@oberon.USC.EDU> jchen@pollux.usc.edu (Joseph S. Chen) writes:
>   Does anyone have or know how to get a copy of Fortran-77 lexical
>definition in regular expression form and syntatic definition in BNF?
>It's fine if the specifications are not "lex" and "yacc" compatible.
>Thanks in advance.
 
Unfortunately, Fortran is a bit too convoluted for lexing with regular
expression-based lexers (this point is actually mentioned in the document
describing Lex).

The problem is that determining whether a token, say "DO", is a keyword or
a variable depends on the surrounding context.  Therefore, a regular expression
cannot capture the essential information about a token.

Additionally, since Fortran ignores blanks, it is sometimes difficult to
determine whether a token has ended.  For example,

	  DO 10 i = 1, 100

is equivalent to

	  DO10i=1,100

It is not possible to determine  whether "DO" is a keyword or a variable until
the comma is scanned (the fifth following token).

As a result, lexical analyzers for Fortran have to be "hand-rolled".

Phil Miller
{...}!tektronix!omepd!omepd!iwarp!pcm
My employer is not responsible for my opinions.