Parenthesis

Sean Kelly sean at f4.ca
Thu Dec 28 21:00:54 PST 2006


Wolven wrote:
> == Quote from Walter Bright (newshound at digitalmars.com)'s article
>>> |  After a couple of weeks with no results, he came across a DO
>>> |  statement, in the form:
>>> |       DO 10 I=1.10
>>> |  This statement was interpreted by the compiler (correctly) as:
>>> |       DO10I = 1.10
>>> |  The programmer had clearly intended:
>>> |       DO 10 I = 1, 10
>>> |
> 
> I realize the parser ignores "whitespace", but why would it combine what are
> clearly seperate tokens..  i.e. DO, 10, and I?  Seems like a logic error in the
> compiler.

How does the compiler know they are separate tokens?  Remember, FORTRAN 
ignores whitespace.  In this context, the compiler doesn't know it's 
parsing a DO loop until it encounters the comma.  In other words, you 
can consider FORTRAN to be an arbitrary look-ahead language, because the 
compiler only knows how to interpret a specific statement when it 
reaches the end of the statement.  Things are even worse than they 
appear, because as far as I know, keywords in FORTRAN are not reserved.


Sean



More information about the Digitalmars-d mailing list