Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!mcnc!decvax!ucbvax!hplabs!hp-pcd!uoregon!omepd!pcm From: pcm@iwarpo3.intel.com (Phil C. Miller) Newsgroups: comp.lang.fortran Subject: Re: Wanted: Fortran Specification Message-ID: <2785@omepd> Date: 2 Feb 88 21:32:00 GMT References: <6592@oberon.USC.EDU> Sender: news@omepd Reply-To: pcm@iwarpo3.UUCP (Phil C. Miller) Distribution: na Organization: Intel Corp., Hillsboro Lines: 31 Keywords: Fortran grammar 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.