Re: language twiddling, was Infinite look ahead required by C++?

Chris F Clark <cfc@shell01.TheWorld.com>
Sun, 07 Mar 2010 14:34:32 -0500

          From comp.compilers

Related articles
[3 earlier articles]
Re: Infinite look ahead required by C++? cfc@shell01.TheWorld.com (Chris F Clark) (2010-02-27)
Re: Infinite look ahead required by C++? bartc@freeuk.com (bartc) (2010-02-28)
Re: language twiddling, was Infinite look ahead required by C++? cfc@shell01.TheWorld.com (Chris F Clark) (2010-03-01)
Re: language twiddling, was Infinite look ahead required by C++? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-03)
Re: language twiddling, was Infinite look ahead required by C++? bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-05)
Re: language twiddling, was Infinite look ahead required by C++? bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-05)
Re: language twiddling, was Infinite look ahead required by C++? cfc@shell01.TheWorld.com (Chris F Clark) (2010-03-07)
Re: language twiddling, was Infinite look ahead required by C++? bartc@freeuk.com (bartc) (2010-03-08)
Re: language twiddling, was Infinite look ahead required by C++? cfc@shell01.TheWorld.com (Chris F Clark) (2010-03-10)
Re: language twiddling, was Infinite look ahead required by C++? bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-12)
Re: language twiddling, was Infinite look ahead required by C++? nevillednz@gmail.com (Neville Dempsey) (2010-03-14)
Re: language twiddling, was Infinite look ahead required by C++? genew@ocis.net (Gene Wirchenko) (2010-04-14)
Re: language twiddling, was Infinite look ahead required by C++? bobduff@shell01.TheWorld.com (Robert A Duff) (2010-04-16)
[2 later articles]
| List of all articles for this month |

From: Chris F Clark <cfc@shell01.TheWorld.com>
Newsgroups: comp.compilers
Date: Sun, 07 Mar 2010 14:34:32 -0500
Organization: The World Public Access UNIX, Brookline, MA
References: 10-02-024 10-02-039 10-02-086 10-02-088 10-03-003 10-03-005 10-03-007
Keywords: design
Posted-Date: 08 Mar 2010 00:34:00 EST

I incorrectly wrote:


>> The basic idea of reserved word (i.e. a keyword you can't use for
>> anything else) specifying a declaration followed by a list of
>> identifiers being declared is a sound one and is used in the
>> languages leading upto C.


glen herrmannsfeldt <gah@ugcs.caltech.edu> writes:


> Two languages which had some of the features that went into C,
> and that were reasonably used at the time, were Fortran and PL/I.
> [C was mostly based on BCPL. See http://cm.bell-labs.com/cm/cs/who/dmr/chist.html
> -John]
...
> Both Fortran and PL/I have no reserved words.


You are right. I mispoke.


I was thinking primarily of FORTRAN (and to a lesser extent
Algol-60). The property I was thinking of was not reserved words, but
the lack of user defined types as declaration keywords. PL/I also has
that property. (I can't speak of BCPL, as I never learned that
language.) In all of those languages, there is a fixed set of words
that introduces a declaration. PL/I even anticipates Pascal with its
use of "declare" (or "decl" for short) roughly the same way that
Pascal uses "var".


FORTRAN is more like C though in its use of INTEGER, LOGICAL, FLOAT,
DOUBLE, and COMPLEX. Perhaps, if the idea of user defined types had
existed in FORTRAN, the problem would have been introduced there.
But, it didn't, and it wasn't. That simplicity in FORTRAN makes all
the difference. Not, that FORTRAN doesn't have its own parsing
difficulties, like spaces being irrelevant, which fortunately did not
propagate to the language's heirs.


BTW, I agree with Bob Duff in that there are other ways to be clear
and unambiguous. However, initial keywords (especially when they are
reserved words) are particularly simple to use and generally make
proving that the language is LL(1) trivial. While this may not be a
be-all-end-all property for a language to have, it is a good start
especially for those who are still learning.


For example, the resolution of the dangling else problem, by changing
the syntax to have a closing terminator on if-statements, results in
that section of the language being LL(1). This is due to the fact
that in most languages, nearly every type of statement (generally
excluding assignment) is introduced by a unique keyword, if-then, and
if-then-else breaking that rule (and are also recursive). Those are
the facts that cause the dangling else problem, and which make the
language not LL(1). (For those students out there, what other
solution suggested by this paragraph would solve the dangling else
problem? I can think of two.)


Again, these are just my pedagogical opinions,
-Chris


******************************************************************************
Chris Clark email: christopher.f.clark@compiler-resources.com
Compiler Resources, Inc. Web Site: http://world.std.com/~compres
23 Bailey Rd voice: (508) 435-5016
Berlin, MA 01503 USA twitter: @intel_chris


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.