For Programmers: Free Programming Magazines  


Home > Archive > Fortran > September 2004 > Statement terminators









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Statement terminators
Rich Townsend

2004-09-25, 4:00 am

Dear all,

A month or so ago, I posted to c.l.f asking about tips for writing a
Fortran lexer/parser. Many thanks to all those who gave me pointers;
I've made a start on the project, and I'm currently working on the code
for dealing with contination lines.

I've run into a little difficulty understanding how statement
continuation interacts with statement termination via semicolons.
Consider the following two lines of free-form code:

print *,'foo'; &
print *,'bar'

Is this code leagal? Both the Intel and Compaq compilers complain, with
the same error message:

Warning: test_continuation.f90, line 3: Continuation character illegal
as first non_blank in statement

Now, from my reading of the standard(1), there is nothing which
prohibits a statement terminator from being followed by blanks and then
a continuation character. In fact, the only restriction I can find on
the use of semicolons is in Section 3.3.1.3: 'A ";" shall not appear as
the first nonblank character on a line.' -- clearly not the case in the
code I give above.

I'd appreciate any input on this matter.

cheers,

Rich

(1) I've got a draft copy of the F2003 standard; I'm assuming that --
apart from the increase in the maximal number of continuation lines --
the specification for free-form source is the same as in F90/F95.

--
Dr Richard H D Townsend
Bartol Research Institute
University of Delaware

[ Delete VOID for valid email address ]
James Giles

2004-09-25, 4:00 am

Rich Townsend wrote:
....
> Consider the following two lines of free-form code:
>
> print *,'foo'; &
> print *,'bar'
>
> Is this code leagal? Both the Intel and Compaq compilers complain, with
> the same error message:
>
> Warning: test_continuation.f90, line 3: Continuation character illegal
> as first non_blank in statement


Well, §3.3.1.3 of the F95 standard says that the & is used to continue
the current statement. Well, it could be argued that there is no current
statement at the point where your & appears here. The only statement
on that line has certainly been terminated already by the preceeding
semicolon. I think this may be a bit too pedantic, but it could be the
logic they applied.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com