Eric Sosman said:
The code you posted is not C, although it may be some kind
of "C with extras" dialect. For example,
The link in the original post is:
http://cm.bell-labs.com/cm/cs/who/dmr/primevalC.html
It's the source code of one of the very first C compilers, written
(mostly?) by Dennis Ritchie.
extern swp[], isn, swtab[], printf, deflab, statement, brklab;
extern label;
Most of these declarations have meaning ("are legal") in C as it
was circa 1989; all of them have been prohibited in C since 1999.
Even in 1989 the declaration of `printf' was incorrect and caused
undefined behavior. (The declaration of `isn' is also suspect, but
the undefined behavior in its case is likely to be "it works as
intended, by luck and not by design.")
It's far older than 1989. It's from 1972 or 1973. It's not just
pre-ANSI; it's pre-K&R1.
int sswp[], dl, cv, swlab;
sswp = swp;
This assignment cannot be performed in C.
It's not the assignment that's changed, it's the declaration. In the
version of C this was written in, "int sswp[];" actually defined sswp as
a pointer.
[...]
... and so on. I think your first task is to discover what
language this code is written in (it isn't C). Then you can look
for an appropriate forum; this isn't it.
Moral: It isn't necessarily C just because it has semicolons.
And it isn't necessarily not-C just because it's not *modern* C.
One could argue that it is C (because that's what C was like back then)
or that it isn't (because it doesn't conform to any C standard). I'd
say that comp.lang.c is the most appropriate place to discuss the code
-- as long as it's made clear how old it is and how much the language
has evolved since then.
Some interesting quotes from the cited web page:
The earlier compiler does not know about structures at all: the
string "struct" does not appear anywhere. The second tape has a
compiler that does implement structures in a way that begins to
approach their current meaning. Their declaration syntax seems
to use () instead of {}, but . and -> for specifying members
of a structure itself and members of a pointed-to structure
are both there.
Neither compiler yet handled the general declaration syntax of
today or even K&R I, with its compound declarators like the one
in int **ipp; . The compilers have not yet evolved the notion
of compounding of type constructors ("array of pointers to
functions", for example). These would appear, though, by 5th
or 6th edition Unix (say 1975), as described (in Postscript)
in the C manual a couple of years after these versions.
Instead, pointer declarations were written in the style int
ip[];. A fossil from this era survives even in modern C, where
the notation can be used in declarations of arguments. On the
other hand, the later of the two does accept the * notation,
even though it doesn't use it. (Evolving compilers written in
their own language are careful not to take advantage of their
own latest features.)
It's interesting to note that the earlier compiler has a
commented-out preparation for a "long" keyword; the later one
takes over its slot for "struct." Implementation of long was
a few years away.
Aside from their small size, perhaps the most striking
thing about these programs is their primitive construction,
particularly the many constants strewn throughout; they are
used for names of tokens, for example. This is because the
preprocessor didn't exist at the time.
The code is of great *historical* interest to programming language
historians -- and it helps explain some of the odd quirks that have
survived into modern ISO C. It's probably not the best resource
for understanding either modern C or modern compiler construction.