The current rules for do-constructs work perfectly well for standard modern Fortran syntax but there are two use cases missing from the older punchcard Fortran (Fortran 77) standards.
In most cases do-constructs are writen like
do i = 1, 10, 1
...
end do
However, one could also replace the enddo statement with a continue statement
do i = 1, 10, 1
...
continue
and still be correct. This change on it's own would be rather trivial to make in the rules however there is one last form of the do-construct that complicates things significantly.
The previous two examples are both forms of un-labeled do-constructs. A do-construct can also be written as a labeled do-construct, such as:
do 99 i = 1, 10, 1
...
99 k = k + i
When written in this format the line terminating the loop can be almost any executable statement (including continue and end do). Furthermore multiple labeled do-constructs can terminate on the same line. For instance
do 99 i = 1, 10, 1
do 99 j = 2, 20, 2
...
99 k = k + i
where both the inner and outer loop terminate on line 99.
I've spent a little time toying around with fixed for this but I haven't come up with anything particularly satisfying that didn't involved abandoning the more structured rules approach (i.e., getting rid of the multi-line do-construct rules and replacing them with the old do/enddo keywords.
The current rules for do-constructs work perfectly well for standard modern Fortran syntax but there are two use cases missing from the older punchcard Fortran (Fortran 77) standards.
In most cases do-constructs are writen like
However, one could also replace the
enddo
statement with acontinue
statementand still be correct. This change on it's own would be rather trivial to make in the rules however there is one last form of the do-construct that complicates things significantly.
The previous two examples are both forms of un-labeled do-constructs. A do-construct can also be written as a labeled do-construct, such as:
When written in this format the line terminating the loop can be almost any executable statement (including
continue
andend do
). Furthermore multiple labeled do-constructs can terminate on the same line. For instancewhere both the inner and outer loop terminate on line
99
.I've spent a little time toying around with fixed for this but I haven't come up with anything particularly satisfying that didn't involved abandoning the more structured rules approach (i.e., getting rid of the multi-line do-construct rules and replacing them with the old do/enddo keywords.