Related articles |
---|
[8 earlier articles] |
Re: language design tradeoffs jlg@cochiti.lanl.gov (1992-09-15) |
Re: language design tradeoffs anw@maths.nott.ac.uk (1992-09-16) |
Re: language design tradeoffs drw@euclid.mit.edu (1992-09-16) |
Re: language design tradeoffs rob@guinness.eng.ohio-state.edu (1992-09-17) |
Re: language design tradeoffs bromage@mullauna.cs.mu.OZ.AU (1992-09-17) |
Re: language design tradeoffs jch@rdg.dec.com (1992-09-17) |
Re: language design tradeoffs firth@sei.cmu.edu (1992-09-17) |
Re: language design tradeoffs nickh@CS.CMU.EDU (1992-09-17) |
Re: language design tradeoffs norvell@csri.toronto.edu (1992-09-17) |
Re: language design tradeoffs jlg@cochiti.lanl.gov (1992-09-17) |
Re: language design tradeoffs bks@s27w007.pswfs.gov (1992-09-17) |
Re: language design tradeoffs raveling@Unify.com (1992-09-17) |
Re: language design tradeoffs jlg@cochiti.lanl.gov (1992-09-18) |
[20 later articles] |
Newsgroups: | comp.compilers,comp.human-factors |
From: | firth@sei.cmu.edu (Robert Firth) |
Organization: | Software Engineering Institute |
Date: | Thu, 17 Sep 1992 14:20:45 GMT |
References: | 92-09-048 92-09-093 |
Keywords: | design, parse |
rob@guinness.eng.ohio-state.edu (Rob Carriere) writes:
[EOL ends statement]
>Hm. Did whoever did that research take large mathematical expressions
>(which naturally translate to multi-line statements) into account? My
>single most common syntax error in FORTRAN and Matlab is forgetting the
>continuation marker on a multi-line statement.
BCPL got that right (and much else!). A semicolon always terminates a
statement. EOL terminates a statement if what it terminates is a legal
statement; otherwise you roll right on to the next line. Thus:
sum := a+b+c+d+
e+f+g
is one statement. No continuation markers, and no semicolons.
This is how the original compiler worked; I made a small change so that
the EOL was ignored also if the following token couldn't start a statement
but could continue the previous one. That means this also works:
sum := a+b+c+d
+e+f+g
If you know the language, that leaves only one pathological case, when the
first token of the next line is the "!" operator. But I'd never seen
anyone split a!i over two lines, so figured it wasn't important.
And yes, the compiler works as expected: the lexer recognises EOL as a
token, and the parser knows what to do with it, based on at most a
one-token lookahead.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.