Chapter 3: Lexical Analysis

 

- The first line is a variable assignment

DO10I=1.25

- second line is beginning of a

Do loop

- Reading from left to right one can not distinguish between the two until the ";" or "." is reached

. Fortran white space and fixed format rules came into force due to punch cards and errors in punching

In the example (previous slide),

DO 10 I = 1.25    DO 10 I = 1,25

The first line is a variable assignment DO10I = 1.25. The second line is the beginning of a Do loop. In such a case, we might need an arbitrary long lookahead. Reading from left to right, we can not distinguish between the two until the " , " or " . " is reached.

FORTRAN has a language convention which impacts the difficulty of lexical analysis. The alignment of lexeme may be important in determining the correctness of the source program; the treatment of blank varies from language to language such as FORTRAN and ALGOL 68. Blanks are not significant except in little strings. The conventions regarding blanks can greatly complicate the task of identified tokens.