Newsgroups: | comp.compilers |
From: | ludemann@netcom.com (Peter Ludemann) |
Keywords: | syntax, design |
Organization: | NETCOM On-line Communication Services (408 261-4700 guest) |
References: | 95-04-013 95-04-107 |
Date: | Fri, 28 Apr 1995 19:23:38 GMT |
Lutz Prechelt <prechelt@i41s25.ira.uka.de> wrote:
>rpereda@wotangate.sc.ti.com (Ramon Pereda, ) writes:
>...
>|> Icon has makes an interesting distinction between whitespace and newlines.
>|> Newline automatically inserts a semicolon at the end of a line,
>|> if an "expression" ends on that line and the next line begins with another.
>
>Indeed the semicolons can be a nuisance.
>And it is surprisingly simple (surprising only for us semicolon-grown
>programmers) to create a syntax that needs no semicolons.
Indeed: I can think of 3 examples.
1. BCPL requires a semicolon only if you put multiple
statements on a line. The end-of-line rule is especially
elegant: a semicolon is implicitly inserted if it would
make sense (ie, the semicolon is not inserted if the last
thing on the line is an operator or if there is an open
left parenthesis). Given that the designers of C (allegedly
a BCPL-descendant) didn't like verbosity, I'm surprised that
they didn't continue this fine tradition [BCPL's style of
commenting wasn't continued either; but it's now in C++].
2. REXX allows continuing a line by having the last character
on the line as a comma. This works because comma has no
intrinsic meaning in REXX (it can be used as an argument
separator in procedure calls, if you want). I urge all
scripting language designers to read Cowlishaw's book
on REXX (my flame to Larry Wall: REXX provides about as much
"power" as Perl, while having readability sufficiently good
that IBM managers have been know to program in it; and it works
well as an underlying language for editors (e.g., as a
replacement for Emacs-lisp)).
3. The new Arden syntax, where on a challenge I modified the
grammar to remove all semicolons (now they aren't even needed
if multiple statements appear on a line). It turned out to be
surprisingly simple to do ... in most cases, I just changed
the ";" token to <statement_end>, defined by:
<statement_end> ::= /* empty */
<statement_end> ::= ";"
If anybody wants to see the grammar, it's in YACC-form in:
ftp.netcom.com:/pub/lu/ludemann/ardenc/ardenc.tar.gz
--
Peter Ludemann ludemann@netcom.com
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.