Related articles |
---|
[18 earlier articles] |
Re: Programming language and IDE design gneuner2@comcast.net (George Neuner) (2013-11-18) |
Re: Programming language and IDE design sgk@REMOVEtroutmask.apl.washington.edu (Steven G. Kargl) (2013-11-19) |
Re: Programming language and IDE design gneuner2@comcast.net (George Neuner) (2013-11-19) |
Re: Programming language and IDE design jonathan@cobalt.astro.indiana.edu (Jonathan Thornburg) (2013-11-19) |
Re: Programming language and IDE design wclodius@earthlink.net (2013-11-22) |
Re: Programming language and IDE design robin51@dodo.com.au (robin) (2013-11-25) |
Re: Programming language and IDE design martin@gkc.org.uk (Martin Ward) (2013-12-03) |
Re: Programming language and IDE design DrDiettrich1@aol.com (Hans-Peter Diettrich) (2013-12-05) |
Re: Programming language and IDE design hu47121@usenet.kitty.sub.org (2014-03-02) |
Re: Programming language and IDE design gneuner2@comcast.net (George Neuner) (2014-03-02) |
From: | Martin Ward <martin@gkc.org.uk> |
Newsgroups: | comp.compilers |
Date: | Tue, 3 Dec 2013 15:15:07 +0000 |
Organization: | Compilers Central |
References: | 13-11-016 13-11-018 13-11-031 |
Keywords: | syntax, design |
Posted-Date: | 04 Dec 2013 21:07:39 EST |
On Sunday 24 Nov 2013 at 23:33, "robin" <robin51@dodo.com.au> wrote:
> > AFAIK, Fortran's DO loop requires the most lookahead of any of the
> > classic language features: LL(4) [if I'm counting correctly].
> >
> > 10DOI=42
> > 10DOI=42,45
>
> The statements are
> DO 10 I = 42
> DO 10 I = 42, 45
The difference is even smaller than this:
DO 10 I = 42.45
DO 10 I = 42,45
The first is an assignment of a floating point value to variable DO10I,
the second is a loop with I as the loop variable.
Fortran allows spaces in the middle of identifiers, so requiring
spaces around keywords does not help (unless you *also*
disallow spaces within identifiers).
The fact that the two statements can be distinguished with an LL(k)
parser does not necessarily mean that the language is easy to read.
Disallowing spaces within identifiers, insisting on spaces around keywords,
insisting on correct indentation and correct and distinct closing keywords
to block structures, and requiring all identifiers to be declared with an
appropriate type, all make the language harder to write:
but also easier for humans to read (even if they make no difference
to the language parser). Any, or all, of these restrictions would have
prevented the confusion between an assignment and a loop.
--
Martin
Dr Martin Ward STRL Principal Lecturer and Reader in Software Engineering
martin@gkc.org.uk http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4
G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/
Mirrors: http://www.gkc.org.uk and http://www.gkc.org.uk/gkc
Return to the
comp.compilers page.
Search the
comp.compilers archives again.