Newsgroups: | comp.compilers |
From: | Charles Fiterman <cef@geodesic.com> |
Keywords: | syntax, design |
Organization: | Geodesic Systems |
References: | 95-05-031 95-05-080 |
Date: | Wed, 17 May 1995 13:03:51 GMT |
Mark Everett - Sun Parallel Open Systems <everettm@walters.East.Sun.COM> wrote:
>"Dr A. N. Walker" <anw@maths.nottingham.ac.uk> writes:
>> ludemann@netcom.com (Peter Ludemann) writes about semicolon-free syntaxes:
>> >Indeed: I can think of 3 examples.
>>
>> Here is a fourth: throw away the semicolons in Pascal, and the
>> only ambiguity is that you can't always see where the empty statements are.
>> This can easily be cured by adding a visible representation [such as ";"]
>> of such statements.
>>
>> Whether this is a Good Thing from the point of view of the poor
>> programmer trying to make sense of the error messages coming from the
>> compiler is quite another matter.
>
>I was always under the impression that garbage characters like ';' were
>there to enable error recovery to provide meaningful error messages. Statement
>delimiters are a place where the compiler can "sync up" with what it is
>expecting. They are not needed in correct programs, but rather incorrect
>ones.
>
If thats their purpose they serve negative value. End of line can
do the same thing and the parser can always put the error message
on the correct line.
At one university they scanned a lot of code for continued lines.
This excluded cases where there were () including newlines. It
mearly counted C code where a missing semicolon on one line
caused it to be merged with the next. In about 25% of the cases
the missing semicolon either caused or concealed an error.
Most statements occupy one line, it makes sense to have the
exceptional condition take extra code. In the language we
are building indentation is part of syntax so we need to
say which line is being continued. We use ^^ lined up under
the line being continued.
print
Hello world
I love you
^^ aVariableName
More text
Comes through the lexer the same as
print [Hello world\nI love you\n] aVariableName [More text\n]
We treat indented material as strings. Some users such as 'if' will
cast those strings to code. 'if' will discard its indented argument
unparsed if it evaluates to fail at compile time.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.