|
|
DataMuseum.dkPresents historical artifacts from the history of: RC4000/8000/9000 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about RC4000/8000/9000 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 26112 (0x6600)
Types: TextFile
Names: »ptoarapo«
└─⟦00964e8f7⟧ Bits:30007478 RC8000 Dump tape fra HCØ.
└─⟦b2ec5d50f⟧
└─⟦this⟧ »ptoarapo«
\f
PASCAL TO ALGOL 1
__________________________________\r1. Way of Presenting the Problems.
A Chinaman called Yu Song Yu has September 1981 been
living two years in Copenhagen, where he has made a lots og
programs on DIKU (Institute of Computer Science of Copenhagen)
in the programming language Pascal.
Now the problem is that Yu Song Yu, when he is returning
to China, he has no possibility to go on working at his
programs, because he onlyy can get programs in the program-
meringlanguage Algol executed, and Yu Song Yu dont know
anything about Algol.
We are now trying to make a translater, whivh can
translate Pascal to Algol. The translater is written in Algol,
because it is the language Yu Son Yu have on the machine DJS-6
in Shanghai.
Some of the things we are going to concider in connection
with drawing up the translater are following:
a) which of the three following things are going to
have the highest priority
1) the likeness between the Algol and the Pascal
version of a program is as great as possible
2) the translation from Pascal to Algol of a program
is as fast as possible
3) the executing time of the Algolversion of the
program is as low as possible
b) how is the precise syntax for Algol in China and
which Pascalversion should be translated
c) which input-, output- and storage possibilitys are
there on the machine in China
d) which possibility do we have for testing the
translater (look section )
e) beside the syntax's differens between Pascal and
Algol, there are in Pascal some facilitetes (heap,
pointer, set, case, repeat - while, type) , which do
not exist in Algol. How are they going to be translated
f) which possibilitys do we have to get information
about the circumstances in China
g) must the translation and the syntaxcheck be done at
\f
PASCAL TO ALGOL 2
the same time or is the translation going to be in
steps
__________________\r2 Problemanalysis.
2.1 The Possibility to Getting Information about the Circum-
stances in China.
As mentioned in section 1 Way of Presenting the Problems,
we have to know the precise Algolversion in China, which
external devices there are on the machine in China, and how
much storage there is, wordsize and so on.
Yu Song Yu, the Chinaman for whom we are making the
translater, have no particular knowledge about Algol on the
topical machine in Shanghai, on the other hand he has a friend
in Aarhus, who had told us a little bit about the machine but
nothing about the Chinese Algol. Therefore we have made some
questions on English, which Yu Song Yu and his friend have
translated to Chinese and sent to their place of work in
Shanghai. One of the question was, is it possible to get a
manual in Algol.
So we have possibility by letters to get information
about the Chinese machine and the language, but because it
takes about two mouths, before we get an answer on a letter,
it is limited, how many letters we can get answered during the
periode the projekt is running.
After about three months we have got an Algol manual on
Chinese, but never the less we can study the programexamples
and realize, how the programminglanguage is, and Yu Song Yu is
ready to try to translate parts of the manual.
\f
PASCAL TO ALGOL 3
_____________________\r2.2 The Algolversion.
The Algol, Which is used on the machine in China, we are
going to make a translater to, is extended Algol 60 with some
small differenses. The machine is called DJS-6, in the rest of
the report we use the name DJS-6 Algol or Chinaalgol, when we
referer to the programming language, which we are going to make
a translater to.
In Algol 60 there are no input/output procedures, so
these are of couse added in DJS-6 Algol. These procedures can
only read an integer or a real and write them again. There is
no possibility for input/output of characters - more about that
in section 3.3.1.
The reserved words in DJS-6 Algol are surrounded by
apostrophes in sted of as in Algol 60 to be underlined.
Example:
DJS-6 Algol Algol 60
'BEGIN' BEGIN
-----
Ruthermore some of the symbols are changed viz following:
DJS-6 Algol Algol 60
'LS' <
'LQ' <
'GQ' >
'GR' >
'NQ' =
At last it should be mentioned, that the wort COMMENT
does not exist in DJS-6 Algol.
\f
PASCAL TO ALGOL 4
___________________________________________\r2.3 Which Pascalversion Must Be Translated.
Yu Song Yu works with the version of Pascal, which is
implemented on PDP-11/45 also named "sequentiel Pascal".
This version have some restrictions in proportion to
"standard Pascal" because there are no labels, jumpstatements,
and only to levels global and routine, in sted of there are in
sequentiel Pascal universal types and prefix
3____________________________________\r .4 External devices and memory size.
The manual, we have got from China, says that there is
a papertapereader, a papertapepuncher, a printer and a drum.
The manual is from 1974 so may be, there is some new external
devices, but it had been impossible for us to be enlightened
about, there is any modification in proportion to the manual.
Our possibilities to utilize the external devices are the
following:
The Pascalprogram is read on papertapereader, the syntax-
checked Pascalprogram is printed on the printer together with
errors if any. On the papertapepuncher the DJS-6 Algol prog-
ram(i.e. the translated Pascalprogram) is printed, so if there
is no errors the papertape can be read, and the program
executed.
The drum is our only possibility for storing other places
than in the machine, the drum is ? K word and one word is 48
bit.
2.5 The Priority between the Quickness in the Translater,
Executing Time of the Algolprogram and the Likeness between the
DJS-6 Algol Program and the Pascalprogram.
As mentioned in the heading, there is three drifferent
things, you can mortgage highly, when you are going to make a
translater namely:
\f
PASCAL TO ALGOL 5
1) The likeness between the aboriginal programtext and
the translated program should be as great as possible
among other things to keep as many identifiernames at
all as possible.
2) The quickness in translating from Pascal to DJS-6
Algol should be as great as possible.
3) The executing time on the the translated Pascal-
program, that is the DJS-6 Algolprogram should be as
little as possible.
Of couse it would be lovely, if all three things are fill
up, but some times the three things would counteract each
other, and which of the things should then have the highest
priority.
This mortgage would depend at:
a) On the present Pascalprograms should be translated
one time after which all modifications are maked in the
DJS-6 Algolversions, and you never make new Pascal-
programs.
b) On the present Pascalprograms should be translated
every time, they are going to be executed, if any
modifications they are maked in the Pascalversion,
after which the Pascalprogram is translated again. You
make new programs in Pascal.
If you chose solution a), that is translating the present
Pascalprograms once at all, if any modifications they are maked
in the new DJS-6 Algolversion you have got after the first
translation, and you will never make new programs in Pascal,
it does not mean so much, if the translationtime from Pascal
to DJS-6 Algol is high, because it is only necessary to
translate every Pascalprogram once.
If any modifications in the programs it should be done
in the DJS-6 Algol version. It is on the other hand important
that the likeness between the Pascalprogram and the DJS-6
Algolprogram is as great as possible, so the programmer could
recognise his own program again and have the possibility to
make modifications whitout using a lot of time studing the
"new" program.
The speed in the executing of the DJS-6 Algolprogram will
\f
PASCAL TO ALGOL 6
also have a high priority, but wheather the speed of the
executing at the DJS-6 Algolprogram or the likeness between the
Pascal- and the DJS-6 Algolprogram is as great as possible
should mortgage hieghest, is an individuel judgment.
On the other hand if you should translate the Pascal-
program every time, all modifications are made in the Pascal-
program all modifications are made in the Pascalversion, and
you make new Pascalprograms, it does not mean so much, if the
likeness between the Pascalprogram and the DJS-6 Algolprogram
is particular great. because the programmer never should look
in the DJS-6 Algolversion but only have a necassary inter-
mediate station to get the Pascalprogram exequeted. On the
other would the time, it takes to translate from Pascal to
DJS-6 Algol, have a great meaning, because it is a thing, which
should be made a lot of times. The exequting time of the DJS-6
Algolprogram will like before, be an important factor, and you
do not need to mortgage likeness between the two programs
particular high, it is easyer to get this demand fullfilled.
Now when we know, that the decisive for, what we shoul
give the hieghest priority in the translation, is depending on,
if the present Pascalprograms should be translated once at all
or every time you want to exequete the programs, the next
thing, we have to do, is to find, what Yu Song Yu, who is going
to use the translater, want.
Yu Song Yu still wants to make Pascalprograms, when he
is coming home to China. He does not want to make modifications
if any in the DJS-6 Algolversion, because he does not know any
thing about DJS-6 Algol, there for the likeness between the
Pascal- and the DJS-6 Algolversion does not mean so much. On
the other hand it is important, that the time it takes to
translate the Pascalprogram to DJS-6 Algol is small. These
things we have taken care of in our solution.
_____________________\r3.6 Translationsteps.
Because the translater also should be used to translation
\f
PASCAL TO ALGOL 7
of new Pascalprograms, is it necessary, that there is a
syntaxcheque of the Pascalprogram in the translater.
You can make the translater, so in the first phase you
do a syntaxcheque. The translation can be maked in two phases,
where you in the first construct the necessary tables with
identifiernames, typedeclarations and similar things, while you
in the next phase make the translation itself.
The last two phases you can fold up in one, that is you
have two phases, one where the Pascalprogram would be syntax-
chequed and one where the translation occur.
An other possibility is to make syntaxcheque and tran-
slation in the same phase, that is the translater only got one
phase.
The advantage of having many phases is if you find any
syntaxerrors, is it unnecessary to translate the program to
DJS-6 Algol, and then because the errors should be corrected
in the Pascalprogram, you save the time the translationsphases
take.
If you use multiphases translater, you have to store the
hole program in the machine, because we do not have exact
information about how much memory we have the disposol of, we
find it necessary to make translation and syntaxcheque in one
phase.
By this solution it is only necessary to store the
tables, which will be created, while the translation is made.
The Pascalprogram would be read as far as possible
statement by statement, after which the necessary information
for the tables, whish ar used for translation, is stored. There
woild be made a syntaxcheque and the statement would be
translated to DJS-6 Algol, at last the Pascalversion and if any
the syntaxerrors are printed on the lineprinter. The DJS-6
Algolversion is punched out on papertape.
Above when we wrote, that we as far as possible would
read statement by statement of the Pascalprogram, is it because
of that the loopconstrution could demand, that the hole
loopconstrution is stored in the machine.
So you should not use memory for the hole program at the
same time, which was exactly what we wanted, but the drawback
\f
PASCAL TO ALGOL 8
with this solution is that even when a syntaxerror had been
found, you must use time to translate the Pascalprogram to
DJS-6 Algol. It is possible to cheque, if there has been
syntaxerrors and then stop the translation, if there have been
syntaxerrors, but in the cases where there is no syntaxerrors,
which probably are most of them, you will loose a lote of time
asking if there have been any syntaxerrors in the program.
So our solution would be a one phase translater, where
both the syntaxcheque and the translation are made in the same
phase, and the hole Pascalprogram would be translated even,
when some syntaxerrors have been found.
________________________________________________\r3. Comparisons between the Programminglanguages.
In this section we will describe the differences, there
are between SequentielPascal and "Standard Pascal", between
Sequentiel Pascal and Algol 60, and between Algol 60 and DJS-6
Algol plus the limitations and extensions make for the sake of
the solution of the task.
_____________________________________________\r3.1 Standard Pascal Contra Sequentiel Pascal.
__________________________________________________________\r3.1.1 Differences between Standard- and Sequentiel Pascal.
By Sequentiel Pascal means the Pascal which is mean the
Pascal written for the machine PDP-11. Here there are some
limitations in proportion to Standard Pascal. The most impor-
tant differences are, that you in Sequentiel Pascal do not have
jumpstatements and labels. Futher you cannot in Sequentiel
Pascal declare a variable of the type Files as you can in
Standard Pascal.
\f
PASCAL TO ALGOL 9
______________________________________\r3.1.2 Extensions of Sequentiel Pascal.
par 11 page 31 you can read about constant parametres in a
routine call. According to the report these parametres can not
change value inside the call procedure, this is changed so now
you can change the value inside the procedure. This change have
no effect on the identifiers outside the procedure.
The reason for this extension is, that the procedure now
look more like Algol 60 and Standard Pascal, and we not not
need to control it in the syntaxcheque.
In the Sequentiel Pascal report par 12 page 34 you can
read, that procedures cannot be nested. This we have extended
so all declarations , which are on the programlevel can be used
in the procedurelevel. The reason for this extension is the
same as above more likeness to Algol 60.
Dynamic arraylimits is not allowed in Sequentiel Pascal,
but because it is implemented in Algol 60, it is easy to allow
it in the Pascalprograms, which should be translated.
3.2. Sequentiel Pascal contra Algol 60.
Because, we from the beginning thought that the version
of the Algol, which is used in China is "clean" Algol 60
whitout all the diffent fines and additions, you can find in
nearly all Algol versions, we have first make a comparison
between Algol 60 and Sequentiel Pascal with the above mentioned
extensions. After we have got the manual with that version of
Algol, They are using in China, we have made a comparison
between Algol 60 and DJS-6 Algol.
In Sequentiel Pascal there is some things, which do not
exist in Algol 60 . The most important things are record, type,
heap, pointer, set, case, repeat-until, while-do, char, input
and output.
To be able to translate some of the above mentioned
things to Algol 60, we have to use some auxiliary identifiers.
When this auxiliary identifiers are going to have names, you
may be guite sure not to use names, which all ready is used
\f
PASCAL TO ALGOL 10
in the Pascalprogram.
This you can solve in many different ways, among other things
by prohibited one decided letter as first symbol in variab-
lesnames in Pascal after which all auxiliaryidentifiers are
going to start with this letter. This solution have that
disadvnatage, that all ready existing Pascalprograms may be are
going to be changed, if there is variablenames, which are
starting with the letter, which is forbidden. An other way to
solve the problem (and which is the way we have choosen) is to
prefix all identifiers in Pascal with one or several symbol,
then auxiliary variables can be names, which start with symbols
different from the symbols, which are used as prefix. Our
prefixes consist of two letters, which is telling which type
the variables is.
The list whit prefix looks as follow:
Translation of Record.
As mentioned above there do not exist record in Algol 60,
therefore we translate the identifier inside the record as
integer, real or array depending on the declaration the
identifier has in the record. All the identifiers, which are
coming in the Algolprogram and belongs to a record in the
Pascalprogra, are prefixed with 'RE' and the recordname.
A example will illustrate the meaning.
Pascalversion:
CONST IDLENGTH=12;
necessary TYPE IDENTIFIER=ARRAY(.1..IDLENGTH.) OF CHAR;
information CONST MAXBANDS=5;
to under- TYPE COVARTYPE=ARRAY(.1..MAXBANDS,1..MAXBANDS.) OF REAL;
stand the TYPE NUMBERTYPE=(INTVALUE,REALVALUE,COMPVALUE);
translation
\f
PASCAL TO ALGOL 11
HEADPAGE=RECORD
PICTURECODE:NUMBERTYPE;
PIXELSIZE:INTEGER;
DATASOURCE:IDENTIFIER;
COVARSET:BOOLEAN;
COVARIANCE-MATRIX:COVARTYPE;
The translation to Algol 60, where only the translation of a record
named EXAMPLE of the type HEADPAGE is showed:
EXAMPLE:HEADPAGE
INTEGER REEXAMPLEPICTURECODE,
REEXAMPLEPIXELSIZE;
INTEGER ARRAY
REEXAMPLEDATASOURCE(1:12);
BOOLEAN
REEXAMPLECOVARSET;
REAL ARRAY
REEXAMPLECOVARIANCE-MATRIX(1:5,1:5);
3.2.2. Implementing of HEAP and POINTER.
The HEAP we have implemented by making an integer array
called HEAP.
Pointers are implemented as intergers.
3.2.3. Implementing of CASE.
This problems we solve with a row of if statements.
\f
PASCAL TO ALGOL 12
3.2.4. Implementing of WHILE-DO.
In Algol 60 you only have while-do combined with a
for-statement, therefore a WHILE-DO in Pascal will be tran-
slated asor-statement, therefore a WHILE-DO in Pascal will be
translated as follow:
FOR I:=I WHILE <condition> DO
BEGIN
.
.
.
.
END;
where <condition> is the same condition as in the WHILE-
statement in the Pascalprogram and I is a dummy variable.
3.2.5 Implementing of REPEAT-UNTIL.
That, wich in Pascal is called REPEAT-UNTIL, will in
Algol 60 be implemented in the following way:
FOR I:=I,I+1 WHILE -, <condition> DO
BEGIN
.
.
.
.
END;
where <condition> and I have the same meaning as in section
3.2.4. about WHILE-DO.
\f
PASCAL TO ALGOL 13
3.2.6. Input and Output.
In Algol 60 there do no exist in- and outputprocedure,
but because it is not Algol 60 but DJS-6 Algol the Pascal-
programs should be translated to, we will wait and see which
in- and outputfacilites there are in DJS-6 Algol.
3.2.7. Implementing of CHAR and TYPE.
In Algol 60 there is no CHAr and TYPE, therefore we
implement it as integer.
3.2.8. Implementing of SET.
vides end nu ikke
3.2.9. Differences between Algol 60 and Pascal.
In this sections we will describe things you can find in
Algol 60 but not in Pascal. Because it is Pascalprograms, there
should be translated to Algol, it do not give any problems that
there in Algol are some facilites, whisc do not exist in
Pascal, but the things ought to be mentioned as a matter of
form. In Algol there is labels and jump-statement, these do not
exist in Sequentiel Pascal.
3.2.10. Typographical Differences.
Some of the special symbols are typographical different
but with thw same meaning.
\f
PASCAL TO ALGOL 14
Because the special symbols also are typographical dif-
ferent in Algol 60 contra DJS-6 Algol we have made a table in
section 3.3.3, where you can see how the symbols look in the
three languages Seguentiel Pascal, Algol 60 and DJS-6 Algol.
3.3. Algol 60 Contra DJS-6 Algol.
As all ready mentioned above in section 3.2 the greatest
differences between Algol 60 and DJS-6 Algol are in the
input/outputprocedures and the typographical differences.
Further we now know, that there is some things in Algol
60, which do not exist in DJS-6 Algol.
3.3.1. Input/Outputprocedure.
In Algol 60 there is no input/outputprocedure at all. In
DJS-6 Algol there is as far as we know from the Chinese
Algolmanual the following procedures:
READR(A,B): reading real numbers to variables A and B
READI(A,B): reading integers to the variables A and B
INPUT(A): reading to a array A
OUTPUTI(A): printing the value of the integer variable A,what the exact
PRINTA(A): difference between these two procedures are, it has not
been possible to find out
OUTPUTR(A): apart from it is now real and not integer which is printed
PRINTR(A): there is no difference between these procedures and
OUTPUTI and PRINTI
OUTAR(A): printing the array A
PRINTS(S): printing the string S
Because you in Sequentiel Pascal can read, treat and
write symbols and strings, we are compelled to make some
procedure, because there is no in DJS-6 Algol. In the manual
\f
PASCAL TO ALGOL 15
we have got, there is too little about internal representation
so we can make the procedure. There is a machinelanguage CODE
which you can use to make such a things, but there is no closer
description of CODE, so it is impossible for us to make the
input/ outputprocedure. Our solution on the problem is, that we
have named some procedures, which we have used in the tran-
slated Pascalprograms, that is the DJS-6 Algolprograms. We will
in the userguide write a list with the procedures and what they
are going to do, so the Chines must make the procedures them
selves.
3.3.2. Comments.
As far as we can see in the Chinesemanual, there is no
possibility to write comments in DJS-6 Algol.
This of small importanc, because the comments, there is
written in the Pascalprogram, can not be placed in the right
places in the Algolprogram, because the rules, how you can
place comments in Pascal, are less restrictive than Algol.
Since the user/the programmer do not have to change in
the DJS-6 Algolversion of a program, it does not mean so much
whether there is comments or not.
3.3.3 Special Symbols in the Different Languages.
In Pascal you cannot see in the program, if a word is
reserved, whereas all resved words in DJS-6 ALgol are surroun-
ded of ' ex. 'BEGIN'.
Typographical differences.
Pascal Algol 60 DJS-6 Algol
+ + +
\f
PASCAL TO ALGOL 16
- - -
* x x
<> = 'NQ'
= = =
:= := :=
< < 'LS'
<= <= 'LQ'
>= >= 'GQ'
> > 'GR'
( (
) )
\f
PASCAL TO ALGOL 17
\f
\f
▶EOF◀