Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!labrea!decwrl!sun!steved From: steved@sun.UUCP Newsgroups: comp.lang.fortran Subject: Re: "Interesting" error interpretation by f77. Message-ID: <28327@sun.uucp> Date: Thu, 17-Sep-87 15:00:06 EDT Article-I.D.: sun.28327 Posted: Thu Sep 17 15:00:06 1987 Date-Received: Sat, 19-Sep-87 09:59:31 EDT References: <5117@jade.BERKELEY.EDU> Reply-To: steved@sun.UUCP (Steve Dever) Organization: Sun Microsystems, Mountain View Lines: 43 Keywords: FORTRAN parsing, error interpretation. In article <5117@jade.BERKELEY.EDU> lagache@violet.berkeley.edu (Edouard Lagache) writes: > [ A FORTRAN program containing the invalid lines:] > READ(*,*) NUM1, NUM2 > SUM = NUM1 + NUM2 > [ Which produces the error messages] >Error on line 4 of practice.f: syntax error >Warning on line 9 of practice.f: local variable num2 never used >Warning on line 9 of practice.f: local variable read never used > ^^^^ >----------------------------------------------> ???? <--------- > > After some discussion with the staff, we concluded that > the assignment was being interpreted before the I/O statement, > but that doesn't give me much satisfaction. > ... > > Edouard Lagache > School of Education > U.C. Berkeley > lagache@violet.berkeley.edu The compiler's error message can best be uderstood by considering the statement as seen by the compiler because of the illegal continuation character. It sees: READ(*,*) NUM1, NUM2M = NUM1 + NUM2 Since FORTRAN keywords are not reserved, the compiler must determine from the context whether a particular sequence of characters is a keyword or variable. One way it does this is to scan the statement for an '=' not enclosed within parentheses. Since 'READ' is not a valid keyword starting a statement with an '=', it takes the read to be a variable. -- --------------------------- Steve Dever steved@Sun.COM or Sun Microsystems sun!steved