Fortran Analysis Overview

Return to the Fortran tools home page

The analysis of code in a programming language is conventionally divided into three parts:

Fortran is unusual in that it was initially developed before techniques were developed to separate and simplify the three stages. It now has two source forms, fixed (the original Fortran source form), and free (a source form incorporating most modern concepts about language design). However, even the free source form has aspects that are recognized as awkward for analysis:

In addition, the fixed form has several other problems:

As a result the lexical analysis requires a subset of the information normally obtained from the parser, and the lexical analysis of a statement can sometimes require two passe. Note, however that normal code is sufficiently regular that it is very rare that a statement will require more than one pass by a well written Lexer. After the lexical analysis the syntactic analysis of Fortran is comparable to other large languages, and the semantic analysis is perhaps simpler, as almost all properties of interest (except potential benefits from inlining) can be determined by local analysis at the procedure level.

The detailed description of the lexical analysis of Fortran was given by Arthur H. J. Sale, "The Classification of FORTRAN Statements" The Computer Journal 14(1): 10-12 (1971), which was revised for Fortran 77 by J. K. Slape and Peter J. L. Wallis, "A Modification of Sale's Algorithm to Accommodate FORTRAN 77," The Computer Journal (34)1: 373-376 (1991). This algorithm, with a minor correction, is the basis of William Waite's analysis available as part of Eli's online documentation, and the online documentation for G77 by Craig Burley, particularly the section on "The Gnu Fortran Language".

Return to the Fortran tools home page



Comments and questions to wclodius@aol.com

W.B. Clodius, wclodius@aol.com, Revised 1999-12-03