Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!linus!vaxine!wjh12!genrad!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!hao!seismo!rlgvax!guy From: guy@rlgvax.UUCP Newsgroups: net.lang Subject: Re: Lexical analyzers and parsers Message-ID: <1900@rlgvax.UUCP> Date: Mon, 7-May-84 15:11:36 EDT Article-I.D.: rlgvax.1900 Posted: Mon May 7 15:11:36 1984 Date-Received: Fri, 11-May-84 00:14:36 EDT References: <1632@tekig1.UUCP> <174@ccieng2.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 54 While we're on the subject of Fortran and lexical analysis, here's the worst consequence of the "blanks are ignored" rule I've seen yet, which appeared recently in net.unix-wizards: > Newsgroups: net.unix-wizards,net.bugs.usg,net.lang.f77 > Subject: weird f77 bug; anyone seen this one? > We are running USG 5.0 on a VAX 11/780. Here is part of a subroutine > from an f77 program that compiles properly: > subroutine scale (buff2,f2,ctscl2,type2) > character buff2*132,cont2*2,type2*4 > integer a2,d,e2,f2,ctscl2 > cont2 = ' ' > a2 = index (buff2,'scale') > if (a2 .ne. 0) then > do 100 d = a2+5,len(buff2) > if (f2 .eq. 1) goto 200 > if ((buff2(d,d) .eq. ' ') .or.(buff2(d,d) .eq. ' ')) > & go to 100 > e2=d > f2=1 > go to 100 > 200 if ((buff2(d,d) .ne. ' ') .or. (buff2(d,d) .ne. ' ')) > & go to 100 > c i = strtok (ctscl2,buff2,cont2,'i') > 100 continue > endif > If, however, you change the name of the variable 'd' to 'd2' throughout, > the compiler flags a syntax error on the 'do 100 ...' statement. > Any guesses? > Newsgroups: net.unix-wizards,net.bugs.usg,net.lang.f77 > Subject: weird f77 bug solved.... > The reason for this is the f77 extension which allows a double > precision exponent, which is a multiplier base 10. In other words, > '1d2' equates to '100' (1 * 10^2). f77, on the statement above, > was squeezing out the space between the '100' and the 'd2' and > parsing it as a double precision constant '100d2'; thus the > syntax error. How'd ya like that one, folks? A program that, by all rights, *should* be perfectly legal is made illegal by an unfortunate (but otherwise legal!) choice of variable name. ("e2" would have been just as bad, for the same reason.) Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy