\
\
To:
From:
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
Project MAC
Memorandum MAC-M-347 April 28, 1967
Project MAC participants
J. J. Donovan, k. F. Ledgard
Subject: Canonic Systems1and Their Application to Programming Languages
Abstract: I i
This paper presents two basic results: the use of established method,s of recursive defini1tio.n ·to
1. specify the syntax of computer languages (including contextsensitive require~ents),
2. specify the translation of programs in one computer language into programs in another language.
The method can be used to write one specification for both the syntax of a language (e.g. a source language) and its translation into a target language (e.g. an assembler ! language). A syntactically legal program and its translation into the target language can then be generated using the specification. If the target language is understood, the semantics of the first language is specified.
The paper develops the method of recursi.ve definition in conjunction with an example specifying the syntax of a limited subset of PL/I and its translation into IBM System/360 assembler language.
I The application of the method to a generalized translator for computer
languages is discussed.
1. Introduction
Our objective is to present a single method for expressing the syntax
and translation of computer languages.
The objective to develop either methods for specifying the syntax or
methP,ds for specifying the translation of computer lanugages is not new.
In response to the demand for numerous problem-oriented computer languages to
meet the needs of diverse fields, there has been considerable activity to ease
the effort required to implement a language.
Much of this activity has led to the development of methods for
specifying, at least in part, the syntax of computer languages.< 7- 12)
The methods for specifying syntax have facilitated the description of
computer languages to members of the comp~ting field and have led to t he
development of syntax-directed translators. <22- 25) However, most of the
methods for specifying syntax have been shown to be equiva l ent to context-
. (11 21 22) free phrase structure grammars and hence inadequate ' ' for completely
characterizing the syntax of computer languages. For example, some program-
ming languages require that all statement labels in a program be different,
that reference labels refer to existing statement labels, that the arithmetic
type of a variable be declared , or that the dimensions of an array be declared
before referring to an element within the array. These restrictions cannot
be specified by a contex-free grammar. We consider these restrictions to
be syntactic in that programs violating these restrictions are never
translated, but are rejected solely on their form. Debate as to whether
these restrictions are syntactic or semantic is immaterial when we wish to
specify both the syntax and translation of a language, because then all these
restrictions must be satisfied .
. (25 26) Other activity has been directed to developing table-driven compilers '
(18,19) h and programming languages for expressing string transformations. Te
table - driven compilers have generally been limited to a particular type of •,,
target language and have required excessive detail in writing the specifications
to fill the tables for a particular source language. The string transformation
languages have been limited to special types of string transformations and ,,, .t have not been found generally useful for translating computer languages .:-~-
£ d (15,16,17) Approaches to the ormalization of semantics have also been ma e.
Here we present a single, formal method for specifying completely the
syntax and translation of a computer language. The method is independent
of both the source and target languages. The method uses an uncluttered,
readable notation. The method recursively classifies sets of strings.
The syntax of a computer language is characterized by specifying a set
where each element is a syntactically legal program. the translation of a
( computer language is characterized by specifying a set of ordered pairs,
where the first element of each pair is a legal program in the source
language and the second element is a corresponding program in the target language
that preserves the meaning of the source language program. If the target
language is understood, the semantics of the source language has bee.n specified.
The paper develops the method of recursive definition with an example
specifying the syntax of a limited subset of PL/I and its translation into
IBM System/360 assembler language. A discussion of the power of the method
and of its application to a generalized translator is presented. An
ordered set of appendices is also presented. The appendices present:
1) a brief summary of the notation for the method of recursive definition,
2) two programs in the subset of PL/I and their translation into System/360
assembler language, 3) a Backus-Naur Form specification of the syntax of
the subset of PL/I, 4) a complete specification of the syntax of the subset
-
0
using the method of recursive definition, 5) a complete specification of the
syntax of the subset artd its translation into System/360 assembler language using
the method of recursive definition, and 6) a derivation of a syntactically
legal program in the subset and its translation into assembler language .
2. Basis of Formalization
The formalization for the method presented here evolved from Post's
canonical systems, (l)and hence will be called canpnic systems. Smullyan( 2)
used an applied variant of the canonical systems of Post in his definition
of elementary formal systems . In class notes on the application of
elementary formal systems to the definition of self- contained mathematical
systems, Trenchard More(J) modified the definition of elementary formal
systems . Elementary formal systems (now called canonic systems in recognition
of the earlier work by Post) were further modified to meet the definitional
needs of computer languages and applied to the definition of syntax by
Donovan.<4 ) Canonic systems were later applied by Ledgard(S)to specify
the translation of computer lahguages. This paper is a synthesis of the
last two works.
Canonic systems, which are equivalent to elementary formal systems, can
be used to specify any recursively enumerable set. Smullyan used elementary
formal systems as the basis for his entire study of formal mathematical
systems and resursively enumerable sets. We use canonic systems to define
two examples of recursively enumerable sets, the set of syntactically legal
programs comprising a computer language, and the set of ordered pairs
specifying the translation of programs in one language to programs in another
language. We may feel confident that canonic systems can specify any
programming language, or more generally, any algorithm that a machine can
I' perform. This confidence is a direct consequence of Church's thesis, (3l) '-
(
(
which assex:ts tni:1t the logical notion of "recursive function" or "recursively I
enumerable set" '(which is encompassed by canonic systems) is capable of fully •l
'r· describing ~e intuitive concept of an algorithm. >)·· ,t . H H
3. Canonict Systems
A canonic system is a finite sequence of rules for recursively defining
sets. The elements of the sets are strings of symbols selected from some
finite alphabet. Each rule is called a canon. A canon generally has the
form
set A b set B
which may be interpreted informally:
If 11a1
11 is a member of the set named "set A111 ,and 11 a2
11 is a member of
the set named "set A2
11 ; and "a II is a member of the set , n
named "set A", then we can assert that "b" is a member of the !l
set named "set B" .
The "a. 11 and "b" represent symbols from the finite alphsbet; the "set A." 1 ~~-i
and "set B" are the names of the sets defined.
In the remainder of this · section we will elaborate on this notation.
A synopsis of the notation is given in Appendix 1. and may be used as a
reference throughout the text. The notation will be developed by a series
of examples taken from the canonic system specifying the syntax of a subset
of PL/I, called Little PL/I. This subset includes limited f orms of PL/I
GO TO statements, IF statements, label assignment statements, label declaration
statements, and arithmetic assignment statements. The Backus- Naur Form
description of the subset is given_ in Appendix 3. Two example syntactically
legal programs in the subset are given in Appendix 2. One of these examples
is repeated here:
0
PROCEDURE ; DECLARE LX LABEL; L: I= I+l:A*IB-IC;
LX=L; GO TO CHECK;
M: I = I+lj LX=M;
CHECK: IF I<LIMIT THEN GO TO~; END Q;
We define the syntax of a language as the set of rules for specifying
the strings that can be recognized by a translator and translated into
some other language. The set of rules excludes strings that the translator
would. reject solely on their form. The syntax of Little PL/I has the
following restrictions, which for all practical purposes make Little P~/I
context-sensitive and therefor~ impossible ·to completely characterize . in
Backus-Naur Form:
l. Different declarations of the same identifier are in error·, i.e.
2.
3.
4.
s.
a . The lists of fix-pt var.iable·s, statement labels and declared label variables for a program must be mutually disjoint, and
\
b. the label before PROCEDURE must not occ~r within the proqedure block.
T~e label after END tnust be identical to the label before PROCEDURE . All statement labels ·must be different.
The identifier in a GO TO statement must refer to an existing statement label or a declared label variable.
The identifier on the left hand side 6f the- ''=" in' a lab'el assignment statement must. refer to a declared label variable; the identifier on the right hand side .of the "'"'" must refer to an. existing statement label or a declared label variab_le.
'-· We begin our discussion of the notation for canonic syste.ms by specifying
a set named " l etter" .
~ A- letter
~ B ietter
t Z letter
The canons for this set are as follows:
(l)
(2)
(26)_
. I r
1.
. I
I I , I I
.I I I
1
. .1
•.
(
(
These canons may be read :
(From no premises) we can assert that the symbol "A" is a member of the set named " letter" .
(From no pr emises) we can assert that the symbol "B" is a member of the set named "letter" .
And so on.
The canons specify a set named "letter" comprising the capital letters of
the English alphabet. The sign 11 ~ " is the assertion sign. The strings
"A letter" , "B letter", •• • , and "Z letter" are conclusions . The capital
English letters A through Z are members of the object language. The underlined,
lower case characters are predicates. A predicate, here "letter" , is the
name of a s ·et .
The set named "identifier" may be specified in terms of the set
named "letter":
11 letter r .l1 letter 1-
,/ 1
identifier
12 letter f /l /2 identifier
/ 1 letter + i letter 1 2
These canons may be read:
If "4" is a member of the set named "letter", then we can assert that
11/1
11 is a member of the set named " identifier".
If " i " is a member of the set named 1 the set named " letter" , then we
of the set named "identifier".
And so on.
*
"letter" and 111 " is a member of 2 can assert that 11
)' f' " is a member 1 2
The canons specify a set consisting of identifiers of one to eight capital
* Actually, these canons shoul d properly be called canon schema, which denote in~r~nc.P.~ of c.~non~.
(27)
(28)
(34)
r
English letters. The lower case (possibly subscripted or superscripted)
English letters 1 1 through L8 are variables that represent members of the
set named "letter" . The strin= 11 I " " I J " are terms. A term is a string er 1 , 1 2
of variables or symbols from the object alphabet (e.g. 1111
11 , 11 i1J
211 , or
"A.11 1211
) . The sign "t" is the conjunction sign. The strings 11 .f1
letter",
"P2 letter", "13 letter" are premises. The " 't " before and 11 ~ " separates
premises, all of which must be satisfied to assert the conclusion. The
strings ")'~ letter", 11i 1 identifier", 11J2
letterit, 11,.t1 ,/
2 identifier" are
remarks.
The vocabulary used to describe a canon is sumarized as follows:
} 1
letter
1...-J
variable
identifier
L...J variable
I......J '---' term predicate term predicate
premise conclusion
remark remark
canon
To demonstrate the property of recursion in canons, we define a
set named "list". The set named "list" is needed in the canonic system for
the syntax of Little PL/I to specify the requirement that the list of all
reference labels for a program must be contained in the list of all statement
labels. The canons for the set named "list" are as follows:
r I\ list
i identifier ~ i, list
a list f b .!i.U ~ ab list
(35)
(36)
(37)
We can use canons (1) through (37) to show that the string "A,BB,A, 11 is
c
(
a member of the set named "list". Using canon (1) we can assert that "A''
is a member of the set named "letter" . Using canon (27) we can assert "A"
is a member of the set named "identifier" . Using canon (36) we can assert
that "A," is a member of the set named "l ist". Similarly, using canons
(2), (28), and (36) we can assert that "BB," is a member, of the set named
"list". Since the premises "A, 1 ist" and ''BB, 1 ist" have been asserted, we
can use the instance of canon (37)
A,BB, list
to assert that "A,BB," is a member of the set named list. Using canon (37)
c;lgain (recursively) and letting "a" denote the list "A,BB," and "b" denote
the list "A," we can assert that "A,BB,A," is a member of the set named "list'!.
The repeated use of the same predicate names in the above canons
strongly suggest the use of two abbreviations:
1.
2.
If t , t2
, • • • , t 1 n
"S", the remarks
tl 1 i- t2 1 may be abbreviated
are terms denoting members of the same set named
t s n-
If c1
,c2
,
Q ~ cl
Q ~ c2
C are conclusions with identical premises Q, the canons n
Q ~ c n
may be abbreviated
Q ~ c1 f c2 + Thus the canons for "letter" may be abbreviated with abbreviation 2:
~ A letter ~ B letter f + Z letter
or further abbreivated with abbreviation 1:
~ A + B f . . . y Z letter
.,, The canons for "identifier" may be abbreviated
l 1 ~ .12 + . . . f t8 letter ~ .i1 ? 11 f'2 ? . . . f .11
;2 .13 J14
1-15
J~ Y7
.18
identifier
This canon may be read:
If " 1111,
11/ 2" , • • • , and "/
811 are members of the set named " l etter",
th t th t II /} II II // j II a d II j' / / ) / p ,' JI II are en we can asser a · Jl , ~ 2 , ·•• , n 1 2 3 4 5 6 7 8 members of the set named "identifier" .
We also introduce the following abbreivation:
3. In cases where many canons have some common premises, a b i ock structure abbreviation may be used. The common premises are stated once and understood· to be added to the premises of all canons within the scope of the common block.
This a bbreviation greatly eased the writing of the sepcification for the
syntax of the simulation language GPSS . (4 ) There was no need to i ncorporate
this abbreviation into the canonic system df Little PL/I. An abbreviation
of two or more canons is formally called an edict. However, we will usual l y
refer to edicts as canons.
Thus far we have specified only sets of 1- tuples, i.e., predicates
of degree 1. For a complete specification of Little PL/I, we will have
to specify sets of n- tuples for n greater than 1, i.e . , predicates of
degree n, n> 1. We use the notation
a are terms, n
to denote an ordered n- tuple. The sign " (" s~parates elements of an ord'ered
* To obtain the given abbreviation for " identifier" , we must first change the premises of each of the eight unabbreviated canons to 11...t
1 letter 9-'
l 2letter + . . . t 18
letter". This change does not affect the validity
of the canons.
(
n-tuple. For the r.equirement that the list of reference labels for a Little
PL/I program be contained in the list of statement labels, we specify a
set named " in". The predicate " in" names the set of all ordered pairs
such that the first element is a list of identifiers and the second element c.\nd -\'k.f,~t \"1sr ;.,$
is a list of identifiers. x::orttained in the ~ list • . The set named "tn" - S<;c,~J
is defirted:
a f· b f c list ~ <b.:abc> in
<a<i > irt + <b<i> in ~ <ab<.i> in
(38)
(39)
To suggest more strongly the relationship among the elements of an n- tuple,
we allow premises and conclusions of the form
to be written
a 1 textl a2 text2 • •• textn-1 an
Thus the canons for "in" become
a f b f c list ~ b in abc
a in 1 9- b in J. ~ ab in ,.,f_
These canons may informally be read:
(38)
(39)
If .,.a", "b", and "c'' are lists, then we can assert that the list "b" is contained in the list "abc".
If the list "a" is contained in the list "1" and the list "b" is contained in the list 11111 , then we can assert that the list "ab" is contained in the list ".P".
The following conclusions can be asserted from canons (1) through (39):
A, in A,B, A,A, in A, R,S, in S,T,R, ALPHA, in ALPHA,BETA,
(
·- .............. .,.,.
Finally, we extend the use of the symbol "t" to abbreviate the writing
of n-tuples by allowing remarks of the form
a 1 textl a2 text2 ••• textn-1 ai textl a2 text2 ••• textn-1 a~
to be abbreviated
Thus canon (39)
a in / 't bin .I ~ ab in / (39)
may be abbreviated
a f b in If 1 ~ ab in ,t (39)
4. Canonic System Specification of Syntax
This section is concerned with the motivation and development of a
canonic system for the syntax of Little FL/I, irtcluding context-sensitive
requirements. Our approach will be to specify eventually a set of 1-tuples
named "PL/I prqgram". Each member of this set will be a syntactically
legal Little PL/I program. The entire canonic system specification of this
set is given in Appendix 4. The numbers of the BNF productions of Appendix
3. and the canons of Appendix 4. correspond in that productions and canons
with corresponding numbers specify corresponding syntactic constructions .
The sets of letters and digits are specified by canons 1. and 2. of
Appendix 4. An identifier in Little PL/I is a string of one to eight
letters. Canon 3 . specifies the set of identifiers . Similarly, the set
of unsigned integers, whose members are strings of one to ten digits, is
specified by canon 4 . Little PL/I has only fixed - point arithmetic variables.
Canons 5.1 and 5 .2 specify the set of fixed-point variables. Canons 6. and
7 . 1 specify the set of labels and label variables.
To specify the restriction that a reference label in a GO TO statement
c
be contained in the list of statement labels or that all label variables
for a program be contained in the list of declar;ed label variables, we define
the sets named "list" and "in" (cartons 7.2 through 7.6). the canons for
11list" specify a set of lists, where each list is a sequence of identifiers
separated by commas. The canons for "in" specify a set of ordered pairs of
lists, where each identifier in the first list is contained in the second list.
To specify the restrictions that the sets of fixed-point variables,
statement labels, declared label variables, and the procedure label for a
program must be mutually disjoint, we define the set of ordered pairs named
"disjoint" (canons 7.10 through 7.13). The first element of each ordered
pair is a list of identifiers; the second element of each pair is a list
of identifiers, pone of which appears in the first list. For example, the
ordered pair "<A,B,C, < n~E,F,>" is a member of this set. To define the
set named "disjoint", we first define a set named "differ" (canons 7.7 through 7.9) .
Members of the set named "differ" are ordered pairs, in which the first
element is an identifier and the second element is a different identifier.
Canons 8.1 through 18.4 specify the constructions for Little PL/I
primaries, GO TO statements, relational operators, boolean expressions,
IF statements, label assignment statements, arithmetic assignment statements, and
label DECLARE statements. For example, with every GO TO statement we
keep track of its reference label (to check later if it is in the list of
statement labels) or keep track of its label variable (to check if it is in
the list of declared label variables). Thus we define the canon for a
GO TO statement:
.! labei r GO TO .l; goto stm with ref label ,i, label var A (9.1)
This canon specifies a set of 3-tuples named "goto stm with ref label-label var".
The first element of a 3-tuple is a GO TO statement, the second element
the reference label for the GO TO statement, the third element the label
(
(
variable for the GO TO statement. The canon has the following instance:
A label I- GO TO A; goto stm with ref label A, label var A
or
A label ~ <co TO A;<Au_.A> goto stm with ref label-label var
Likewise, with every arithmetic assignment statement we keep track of the
list of its fixed-point variables (to check later if the list of fixed-point
variables for a program is disjoint from the lists of statement labels,
declared label variables, and procedure label for the program). Hence the
canons for an arithmetic expression and an arithmetic assignment statement
specify $ets of ordered pairs, in which the second element of each pair
is a list of fixed-point variables. In the same manner, we define a set
of ordered 4-tuples to specify an IF statement, a set of ordered 3-tuples
for a label assignment statement, a set of ordered pairs for a DECLARE
statement.
Canons 19.1 through 19.4 specify a statement sequence consisting of a
* single (possibly labeled ) s.tatement. Canon 20.1
sf s i stm
decl
seq with stm labels 1 L .,f' ref s't' s
label vars /vd ~ ~d fix-pt vars
labels .Ir+ .1~ label vars ~ 1 .<!~ v? v' ~ ll dis joint R.'
"'<s S I
t- ss' stm seq with stm labels f 1' ref s s labels .f. D' label vars ,,(1 - r-<.r .. v
decl label vars {,,a,f.;,d fix -pt vars vv'
specifies a statement sequence of two or more statements. This canon may
informally be read
20 . 1
If " s 11 is a stm seq with stm labels 11/ 11 , ref labels 11
/ 11 label vars 11
/11
s r ' .,.'v ' declared label vars "./vd", and fix-pt vars "v",
and "s 1
" is a stm seq with stm labels 11./
1
", ref labels s
declared 1.abel vars 11/
1 " and fix-pt vars 11v
1" vd ' '
"f 1 ", label vars
r I
1t,f II
v '
and the list of stm labels 11,.f II is disjoint from the list of stm labels 11,f 111
s s '
* The element 11 stm labels" for a labeled DECLARE statement is given as "/\" ~.;-~~ ~+-~+-o"'o..-.t- 1 aho1 o -Fn..- l'\'li'r'TA"QJ.' c,t-~t-.om.ont-c: .<lrP ionnrP.<l in PT.IT.
then we can assert that "ss' 11 is a stm seq with stm labels "I .f 1 11,
I • I S S • ref labels 11
,/ .,/_ " label vars 11 ,e_ .I " declared label vars " ft L' " r r , v ·v , vd vd, I
and fix -p t vars "vv II
The premise 11 .f disjoint ,!1 " insures that the statement labels for each
s s
statement sequence are different.
Canon 20.2
s stm seq with stm labels J ref labels ,,f . cL s r
fix -pt vars v -i- Lvd disjoint vi s~
label vars .fv decl label vars .,fvd
v disjoint i s q-- (20.2)
.i in i t ..f in j d r - s v - v L s legal stm seq with stm labels ~ vars j v l vd
specifies a syntactically legal statement sequence. The premises 11/_ dis joint v / " vd , s
and "v disjoint J " insure that the lists of declared label variables, s
fixed -point variables, and statement labels for a Little PL/I program are
mutually disjoint. The premises 11P in ;; " and 11./ in i " insure that all r - <s v - vd
reference labels refer to existing statement labels and that the label
variables used in the label assignment and GO TO statements are declared.
Finally, canon 21.
~ label + s legal stm seg with stm labels .f . s ~ ,I_ : PROCEDURE s END f; PL/I program
dis joint f' v s
specifies a syntactically legal PL/I program. The premise 11./, disjoint -f. v"
s
insures that the procedure label '~ " is not used within the statement
sequence for the program. The set named "PL/I program II is our desired
set, the set of 1-tuples such that each member of the set is a syntactically
legal Little PL/I program.
We thus state our first basic result:
1. The language of canonic systems can be used to specify (exactly) the syntax of a computer language.
(2 1.)
c
(
5. Canonic System Specification of Translation
We know that theoretically, at least, the translation of programs from
one computer language to programs in another computer language is a process
that~ be expressed by a canonic system. We can view every translator
as specifying a function from one set of strings to another. Since the
translation of programs is a task performed on computers, we can assert
that the function specifying the translation is recursively enumerable and
hence can be specified by a canonic system. The ordered pairs defining
the function comprise the recursively enumerable set. The first element
of each ordered pair is a program in one language, the second element its
translation into the target language.
We use this last fact to motivate our development, We will develop
the specifLcation for the translation of a language by
a. modifying the specification of the syntax of the language to distinguish further the semantically different strings (e.g., the set of arithmetic operators+, -, *,and/ will be split into two sets, one for the addition operators+ and - and one for the multiplication operators* and/), and
b. appending to each n - tuple specifying a translatable string one more element specifying a corresponding string in some other language that preserves the meaning of the first string.
Instead of eventually specifying a set of 1-tuples comprising the set of
syntactically legal programs (as we did in the previous section), we
will eventually specify a set of ordered pairs. The first element in each
pair will be a syntactically legal program, the second element its
translation into the target language .
As in the previous section, we will illustrate our approach by example.
The syntactic specification of Little PL/I will be modified to specify
not only the syntax of Little PL/I but also its translation into IBM
System/360 assembler language. A complete specification of the ayntax
and translation of Little PL/I is given in Appertdix 5, Two example
syntactically legal programs and their translations specified by Appendix 5.
(
are given in Appendix 2. As in the example translations, the canons of
Appendix 5. specify comments entries with the assembler statements so that
(hopefully) the reader will not have to be familiar with IBM System/360
assembler language to understand the translation.
In the succeeding paragraphs of this section we present a detailed
discussion of the canons of Appendix 5 , The reader may wish to omit this
discussion. The techniques used in forming the canons of Appendix 5. may
be grasped by comparing the correspondingly numbeted canons of Appendices 4.
and 5. For example, canons 9.1 and 9.2 of Appendix 4 , give the canons
specifying the syntax of a GO TO statement, and canons 9 . 1 ' and 9 . 2' of
Appendix 5. give the canons specifying the syntax of a GO TO statement and
its translation into assembler language. Following this section we continue
with a discussion of the application of canonic systems to a generalized
translator.
Consider first canon 9.1 of Appendix 4:
/ label ~ GO TO .I; goto stm with ref label i, label var A (9.1)
The assembler language statement for a GO TO statement such as "GO TO A;",
where A is a reference label, is simply
B A *BRANCH TO A
where " B" is the operation code for an assembler branch statement, "A" is
the symbolic address of the first assembler statement for the referenced
* Little PL/I statement , and "*BRANCH TO A" is a comments entry. we may
specify this translation by modifying canon 9.1:
L label ~ GO TO .L ; goto stm with ref label .P, label vars/\ assembler stms (9 .1
B 1 *BRANCH TO 1
* We assume that identifiers occurring in a Little PL/I statement will not be changed upon translation into assembler statements so that the same identifiers may be used.
(
(
. .. .,.._ .... .,, ... .,, .
The modified predicate "goto stm with ref label- label var-assembler stms"
names a set of 4 - tuples, where the elements of a 4 - tuple are
1. a GO TO statement
2. the reference label for the GO TO statement
3 . the label variable for the GO TO statement
4. the assembler s tatements for the GO TO statement.
The instance of canon 9 . 1' for the GO TO statement "GO TO A; " is simply
A label ~ GO TO A; goto stm with ref label A, label var A assembler stms
B A *BRANCH TO A
Similarly, canon 9.2 of Appendix 4 . , the canon for a GO TO statement with
a label variable, is modified to specify its translation:
L label variable t GO TO i ; goto stm with ref label/\ label var .L, assembler stms
L l ,..{ *LOAD ADDRESS STORED IN ..L (9.2') BR 1 *BRANCH TO THIS ADDRESS
We next consider canon 11 of Appendix 4:
p * p ' primary with fix-pt var v? v' 4- r rel op
~ prp ' boolean exp with fix-pt vars vv '
(11)
The assembler language statements for a boolean expression such as "I<S"
in an IF statement
IF <boolean exp> THEN <non-declare statement>
might be as follows :
z
L l,I C l,=F'S ' BNL Z
*LOAD I *COMPARE WITH =F'S' *BRANCH IF NOT LOW TO Z
(translation for non-DECLARE statement following the boolean expression)
EQU * *SYMBOLIC ADDRESS OF Z
For the first three assembler statements we must know :
a. the operand entries (I and =F'S') for the primaries (I and 5) of the bool ean expression
b. the branch operation code (BNL) for the relational operator (<)
c. the symbolic address (Z) of the assembler statement to which control should be passed ir the boolean expression is not true.
These requirements necessitate that we
a. modify the canon for primaries to specify the operand entry for each primary
b. modify the canon for relational operators to specify the operation code for each relational operator
c. add a premise to canon 11. to specify a new label
d. modify th~ conclusion or canon 11. to carry the new label for later use(canon 12. ') in specifying the EQU assembler statement to follow the assembler statements for the non-DECLARE statement.
Thus canons 8.1, 8.2, 10., and 11. are modified to give:
i unsigned integer ~ i primary with fix-pt var I\ operand code =F' i' (8.1')
v fix-pt var ~ v primary with fix-pt var v, operand code v (8 . 2')
~< f : f > rel op with branch code BNLtBNEf:SNH message NOT LOWtNOT -EQUALf NOT HIGH
PtP' primary wi~h fi;:-pt var vrv' operand code xrxT't
r relop with branch code b message g 4 ,,(__ label
( 10')
(11')
r prp' boolean exp With fix- pt vars VV I branch label l assembler StffiS
L c b
l ,x l,x'
.1.
*LOAD x *COMPARE WITH x' *BRANCH IF g TO .L..
The modifications to canon 12. to specify the translation of an IF
statement readily follow:
b boolean exp with fix- pt vars v branch label} assembler stms s ~ a
s non-declare stm with ref label J label vars 1 fix-pt vars v' r v
assembler labels .1 assembler stms s' ~ - £, disjoint j
(12')
L a a T a I IF b THBN s if stm with ref label i label vars } fix -pt vars vv'
r v
1.
assembler labels fa! , assembler stms
s a
SI a
EQU if *SYMBOLIC ADDRESS OF i
Here the premise ".J, disjoint,/" insures that the new branch label differs a
from any that occur in the translation of the non-DECLARE statement "s".
(
The element "assembler labels" in the predicate for an IF statement is
specified so that the assembler labels may later be specified to be different
from the other assembler labels and PL/I identifiers for a program.
Canons 13 . 1 and 13.2 are easily rewritten to specify the translation
of a iabel assignment statement:
v label var 't llabel (13.1 ' )
~ v =t ; label asstgn stm with ref label .R., label vars v, assembler stm
MVC v, =A(l.) *SET v TO ADDRESS OF L
v t v label var
~ v =
(13 .2 I)
label assign stm with ref label label vars v1
,v1 assembler stm
MVC *SET v EQUAL TO v'
We next consider canons 14., 15., and 16., the canons for an arithmetic
expression:
r + f -r * t I arith op
p primary with fix- pt vars v ~ p arith exp with fix- pt
a? a' arith exp with fix- pt vars v f v' cf- o arith op
~ ao~ arith exp with fix -pt vars vv'
vars v
(14)'
(15)
(16)
We cannot immediately add to each of these canons the elements specifying
t he correct assembler language statements. In the evaluation of arithmetic
expressions, the operations of multiplication and division are carried out
before the opera tions of addition and subtraction. We may specify this
requirement for a left to right evaluation of arithmetic expressions by :
a. separating the arithmetic operators (+, - ,*,and/) into two classes, one for the addition operator (+and-) and one for the multiplication operators (* and /) - -canons 14.1 ' and 14.2'
b. defining a new construct "term" that consists of a sequence of two or more primaries separated by multiplication operators(* and/)
c. re-defining an arithmetic expression as a sequence of one or more primaries or terms separated by addition operators (+and-)
d. specifying that the left-.most primary or term in an arithmetic expression be evaluated first, in machine register 1- - canons 15 . 1 ' through 15.4' for result in register 1
(
e. specifying that succeeding primar·ies in an arithmetic expression be· directly added or subtracted to machine register 1--canon 15,5'
f. specifying that succeeding terms in an arithmetic expression be formed first in machine register 3 (canons 15.2' and 15.3' for result in register 3) before being added or subtracted to machine register 1--canon 15.6'.
For example, canons 15.1 ' and 15.5' specify "I+l" as a legal arithmetic
expression with assembler statements:
L A
l,I l,=F'l'
*LOAD I *ADD =F'l'
Canons 15.1', 15.2', 15.3' and 15.6' specify "A+B*C*D" as a legal arithmetic
expression with assembler statements :
L l,A i(LOAD A (canon 15.1') L 3,B *LOAD B (canon 15.2') }1 2,C *MULTIPLY BY C M 3- 1,D *MULTIPLY BYD (canon 15.3') AR 1,3 *ADD REGISTERS (canon 15.6')
The remaining canons of Appendix 4 are readily modified. Canon 16.,
the canon for an arithmetic assignment statement, is modified to specify
the assembler store instruction appended to the assembler statements for
an arithmetic expression. Canon 17., the canon for a DECLARE statement·,
requires no modification. Canons 18.1 through 19.4, the canons for a
non-DECLARE statement and a statement sequence of one statement, need
only be rewritten to carry the associated assembler labels and assembler
s_tatements. (Canon 20.2 must also be modified to append the assembler
EQU statement to the assembler statements for a labeled non-DECLARE statement.)
Canons 20.1 and 20.2, the canons for a statement sequence of two or
more statements, are also modified to carry the associated assembler labels
and assembler statements. The premise "..la disjoint/~" added to canon
20 . 1' insures that the assembler label$ differ from each other and the
premise "J.. disjoint/ J.. dV"' added to canon 20.2' insures that the assembler a s v
labels differ from the other identifiers in a Little PL/I program.
(
(
Canons 21.1' and 21.2'
~ /\ set of vars with assembler data stms /\ c-J_...., sd set of vars with assembler data stms v ~~ identifier -r- v1, disjoint v
~ vv1
, set of vars with assembler data stms
sd DS F *STORAGE FOR v1
are new . These two canons specify the assembl er data storage statements
for a set of variables. For example, if "I" were the only variable in a
PL/I program, the following instances of canons 21.1 ' and 21.2 ' would
specify the storage statements for ilI"!
~ A set of vars with assembler data stms " A set of vars with assembler data stms A i I identifier i I, disjoint
r I, set of vars with assembler data stms
I DS F *STORAGE FOR I
Finally, canon 21., the canon for a syntactically legal Little PL/I
program, is modified to give
A
i (21. 11
)
(21. 21) '
21.3 '.!.. label 4 s legal stm seg seg
.P, dis joint J v t ' v' set
r ..1. : PROCED~ ; s END 1;
with stm labels j_ vars v assembler stms s s ~~ a t of vars with assembler data stms s d f v in v'
PL/I program with translation
* * ASSEMBLER LANGUAGE PROGRAM FOR 1-
*
*
BALR USING s a SVC
15,0 *, 15
0
*SET REGISTER 15 AS BASE REGISTER *INFORM ASSEMBLER OF USE OF RlS AS BASE REGISTER
*RETURN TO SUPERVISOR
*TERMINATE ASSEMBLY
The added premise "v1 set of vars with assembler data stms sd" specifies
the assembler data storage statements for the variables of the legal
statement sequence.
(
--·· .... ,:,
The set named "PL/I program with translation" is our desired set.
This predicate names the set of all ordered pairs such that the first
element of each ordered pair is a syntactically legal Little PL/I program
and the second element is its translation into assembler language.
We thus state our second basic result:
2. The language of canonic systems can be used to specify the translation of programs in oile computer language into programs of another computer language.
If the predicates needed to specify the syntax of a source language are
properly modified, the language of canonic systems ~an be used to write one
specification for both the syntax of a source language and its translation
inco a target language.
b . Derivation o_f a Syntactically Legal Program and its Translation into
a Target Lang.uage
We have defined the rules for constructing the canonic system of
Little PL/I in English. However, this canonic system could have been defined
by a second canonic system; the elements of the second canonic system
would formalize the rules for constructing canons, premises, terms, etc.
In fact, starting with the canonic system of Little PL/I, there is an
unending series of canonic systems, each of which specifies the canonic
system previously written.
Canons of the second canonic system are called statutes. Statutes
are read using the same rules as were used to read canons. The sign 11 I~ 11
is the assertion sign of the second canonic system. We have informally
given the definitions of a derivation, a list of premises, a conclusion, and
a canon of the first canonic system. The predicates "derivation",
"list of premises", "conclusion", and "canon" name sets in the second
(
(
canonic system that formalize these definitions. Two statutes of the secorttl
canonic system are:
l~ A derivation
d derivation cf .£ list
~ dii{derivation
(1)
of premises+~ conclusion 4 .,.{~,fi canon ~ ,,{amid d
(2)
The predicate "canon" names the set of all canons of the canonic system of
the syntax of Little PL/I. The predicate "amid", like the predicate "in",
specifies that one list (here a list of premises) be contained in another
list (here a list of conclusions previously derived) .• These statutes formalize
the not ion of a "derivation" and are read:
1. From no premises, we can assert that the null string can be derived.
2. If a) a derivation premises 't." in the
"d" has been derived and b) the list of canon 1'.,l I- l" is amid the derivation "d", then
1
the string "L" can l
be appended to the derivation.
For example, by successively using the following instances of the set named
"canon" in statute (2):
~ A letter
A letter~ A identifier
A identifier ~ A label
A label ~- GO TO A; goto stm with ref label A, label var A
we obtain the following member of the set named "derivation"
1.
3 .
s. 9 . 1
A letter~ identifier<A label~ TO A; goto stm with ref label A, label var A<
This is a derivation of the string "GO TO A". (This string could alternately
have been derived by applying the two rules of inference, substitution
and Modus Ponens, to the canons of the canonic system of Little PL/I.)
An example of a member of the set named "derivation", using the canonic
system of Appendix 4. as members of the set named "canon", is generated in
Appendix b. This derivation is a formal proof that the string
(
P: PROCEDURE ; A: I= I+l;
IF I< 5 THEN GO TO A; END P;
is a PL/I program. Statute (2) above is used recursively to generate the
right-hand column of --4_ through ...e50
• The right-hand column of lines
1i, through A'50
is the member of the set named "derivation". The third
column gives the number of the canon of Appendix 4. used to add the conclusion
given in the right-hand column to the derivation . The second column gives
the numbers of conclusions previously derived that are used as premises to
the canon of Appendix 4. The first column gives a number to the newly
derived cortclusion. For example, line ,,(1
is asserted using the instance
of Statute 2:
A derivation~ A list of premises f I first letter .for fix-pt var conclusion t ~ I first letter for fix - pt var canon
l~ ! first letter for fix:pt var< derivation
Since all premises of this statute are true, we can assert the conclusion
"I first letter for fix-pt varz derivation". ~ines / 1 and 12 are asserted
by using an instance of statute 2 where "d" denotes "I first letter for fix-pt var<_',
1')11 denotes "A 11 , and 11L." denotes "I letter". Similarly, lines .,,e.1 through . 1
i50
are generated.
Appendix 7. presents a member of the set derivation of the canonic !
system of the canonic system of the trans_lation of Little PL/I using the
canons for the translation (Appendix 5.) as members of the set "canon".
The member of the set named "derivation" given in Appendix 7. is a formal
proof of the PL/I program "A" and its translation into System/360 assembler
language.
The derivations of Appendices 6.and 7. lead to two observations.
First, the derivation provides us with a structural description of a derived (3?,)
string. By a structural description of a string we mean the sequence of
c
\.
-~
rules (here a sequence of canons) used in forming the string; the rules used
give us certain information about the construction of the string. For
example, using a derivatit>n of a string, we may construct its "syntactic
tree". Consider the portion of the derivation from Appendix 6:
I first letter for fix-pt var ( I fix-pt var< I primary with var ~<.
5 digit~ 5 unsigned integer~ 5 primary with fix-pt var I\ <rel op 4....
A letter ~A identifd.er <A label< GO TO A; goto stm with ref label A, label var/\ i.
GO TO A; non-declare stm with ref label A, label _vars A fix-pt vars A<.
IF r<s THEN GO TO A; if stm with ref label A, label vars A fix-pt vars IJ <
If we consider only the first elements of each derived n-tuple, this
derivation provides a structural description for the string "IF IZ 5 THEN GO TO A;"
that may be represertted in form of a syntactic tree:
prlmarz re op
fix-pt var l I
first letter for fix-pt var
I
non-declare stm
I ~ GO TO label ;
..:;.:.;:;;.;;;...;;;u.;:=.;;;,.--~in;;.:;..;;;.t~e~g~e~r --r--digit ident-ifier
I I 5 letter
A
The tree ~an be constructed by scanning the derivation from left to right
and constructing the corresponding tree from the bottom up. In general,
if we designate only certain elements of a canonic system, the portions
of the derivation of a string for these elements provides us with a
structural desc-ription of the string with respect to these elements.
(
Se.cond, no additional mechanism was needed to derive the translation I
of the syntactically legal program. The string representing the translation
into assembler language was derived like any other string needed in the
derivation.
7. Application to a Generalized Translator
An important characteristic· of a canonic system' is that it is "generative".
That is, like a Backus-Naur Form specification, a canonic system defines a
string by generating the string using some rules of inference.
To use a canohic system specification in a generalized translator
(i.e., translator that is independent of both source and target languages),
.an algorithm to recognize strings specified by a canonic system must be
devised. No a l gorithm for recognizing strings specified by a canonic $ystem
is presented in this paper. An explicit recognition algorithm has been
developed ( 6) for canonic systems and is being implemented. It is hoped
that with this implementation canonic systems may be used in the recognition
and translation of computer languages for a generalized translator.
A possible implementation of such a generalized translator is ind~cated
in Figure 1. Here we depict two procedure segments and one data segment. I
The procedure segment named Encoding Progra~ accepts a canonic system and
forms it into a data segment to be referenced by the translator procedure
segment. The translator procedure uses tne encoding of the canonic system
as a data base, recognizes source language progr·ams specified by the canonic
system, and outputs the associated translation into the target language.
(
Canonic system of
syntax of source language
and translation into
target language
' Encoding
Program
I
Source Language Program
trans lator l Program for recognizing
source language programs
specified by the canonic
', . '~ data
I
-:;; ,, " and outputing the
base 1- - -
1Data base1
lfor 1canonic I system I
1 _ - - - _J
associated translation
Translation into Target Language
Figure 1. Model for a generalized translato'r
system
The present recognition algorithm (6) was initially devised to recognize
strings of a source language using the canonic system of the syntax of a
source language as a data base. Using the same recognition algorithm and a
canonic system for the syntax of a source language and its translation into
a target language as a data base, no additional mechanism is needed to
construct the tr-anslation of a recognized program. In general, it appears
that no additional mechanism is needed to construct the translation for any
algorithm that has the ability to recognize one element of an ordered
n- tuple and construct another element .
i
Further, as indicated by Appendices 4. and 5., the language of canonic
systems appears to provide an uncluttered notation for expressing the
syntax and translation of a language. The writer: of a canonic system
need not think in terms of character scanning algorithms, parsing algorithms
for syntactic trees, symbol tables, literal tables, and many other details
that plague translator writing.
/
·I I I I
I
1 1
I
I
I
J
l 1 I
I I
The generalized transla~or could be written to first recognize a string and I
then output its derivation . This derivat~on could be used to construc.t the
structural description (e.g . syntactic tree) specified by designated elements
of the derivation.
------ ----- - --- - ·- -·- - - ------- ------8. Discussion
Our approach in developing the canonic system for the syntax and
translation of Little PL/I was to modify the canonic system of the syntax
alone by adding to each n-tuple defining a translatable string another
element specifying its translation. We found that we further had to modify
the canonic system of the syntax in two ways. First, we had to rewrite
tne canons for certain syntactic constructs (e._g., the canon for arithmetic
operators) so that semantically different parts were separated (e.g., the
canon for arithmetic operators had to be separated into two canons, one
( for addition operators and one for multiplication operators). Second, we
had to define a few additional elements and canons (e.g., the canons for
assembler data storage statements). we also found it convenient to define
elements such as message fields.
In practice, a canonic system different from Appendix 4 was initially
devised to specify the syntax of Little PL/I. This canonic system was often
found inconvenient to rework to specify the translation. The reworking
led to the canonic systems of Appendices 4. and 5. We note tnat we did not
attempt to devise independent canonic systems for the syntax and for the
translation of Little PL/I. In a specification of a translation, a specification
of a syntax is implicit and cannot be separated.
Many features of Pl/I were omitted in choosing the subset Little PL/I.
We have ignored the specification of allowable spacing of Little PL/I
programs. Spacing, as well as card format has been specified for another
computer language(4) using canonic systems. Some of the other omitted features
(
(e.g., nested arithmetic expressions) would have required only minor modifications
to the specifications of Appendices 4. and 5, The use of identifiers containing
up to thirty-six characters would have required tnat the identifiers in a
program be changed upon translation to assembler language, where identifiers
of only eight or less characters are allowed. The use of both fixed and
floating point variables was initially considered, but was omitted because
many additional canons and several additional elements were neede9 to specify
the translation of arithmetic expressions. The inclusion of these features
would not have added any new ideas to our development. The large number of
other Pl/I features, such as tne assortment of data types, block structure,
procedure references and definitions, and input/output were disregarded. It
is certainly within the capacity of canonic systems to specify both the
syntax and translation of these features.
However, an equally important issue is whether canonic systems provides
a natural and concise specification of these featur~s. A canonic system for
tne complete syntax of only one language, the simulation language GPSS (4 )
has been written. Judging from the modest size (14 type-written pages)
of this specification and the ease with which the partial syntactic specification
of Appendix 4. was written, we feel that a canonic system for the complete
syntax of PL/I would not be unduly large.
On the other hand, it is clear that a complete specification of the
syntax of PL/I and its translation to assembler language would be large.
We feel that this largeness is due to three principal factors. First,
the PL/I language is complicated. Second, on some features PL/I and IBM
System/360 assembler language are poorly matched . For example, many modifications
to the canons of Appendix 5. would have been required to specify the assembler
statements for the evaluation of arithmetic expressions containing both.
fixed and floating point variables. For any source and target languages ., if
a canonic system of the syntax of the source language and its translation
to the target language were written befote finally defining the languages,
it is likely that we could better match the languages. The unwieldiness
of portions of the canonic system would clearly indicate where the languages
were ill -matched. Third, we feel that a large part of the unwieldiness
is due to the shortcomings of assembler language as a general-purpose target
language. We feel strongly that if a better set of language primitives
were devised, the specification of the translation process, using the new
language as a target language, would be greatly eased.
It is important to develop languages whose descriptions are concise.
The Backus -Naur Form specification of Appendix 3. and the associated five
English sentences of Section 4. describing the context - sensitive requirements ·
provide a very concise description of the syntax of Little PL/I. In their
present form canonic systems wlll nbt replace Backus -Naur Form and the
English language for describing programming languages to people. However,
canonic systems, although yielding larger specifications, provide complete
descriptions in a precise language that a machine can be instructed to
understand with present techniques (6) Moreover, the language of
canonic systems, like Backus-Naur. Form, is readable.
We wish to point out two additional features of the canonic systems
of Appendices 4. and 5. First, barring any inadvertent errors, the canonic
systems describe a set of PL/I programs and assembler language programs
that will run on a computer when translated by a PL/I compiler or System/360
assembler. Second, the specification of the comments entries in the
assembler language statements was provided not only to aid the reader.
The comments are meaningful context - sensitive strings in the English
language. The specification of these strings was handled as easily as
the specification of the strings in assembler language . The specification
(
of the strings in the English language illustrates the use of canonic
systems to specify the entire operation of a translator, including the
specification of meaningful comments. Moreover, it suggests the capacity
of canonic systems to hahdle communication and tranlation in languages
other than computer programming languages. We have not explored this
enticing area .
Cano!lic systems are applicable to the definition of an "abstract"
syntax (l3) of a language. An abstract syntax of a language is a description
of the syntax of a language that is independent of any actual representation
of the symbolic expressions in the language. By 1) omitting the canons
s pecifying only symbols in the object language (e.g., the canons for "letter"
and "d igit"), and 2) using the application of the abstract syntactic functions
in place of elements specifying strings in object language (e.g., writing
the canon for a Little PL/I GO TO statement as "jlabel r GO (.,.() goto stm
with ref l abel P, label var /\" , where "G011 is a function to be specified
in defining a "concrete" syntax of Little PL/I), a canonic system could be
developed to provi de an exact specification of an "abstract" syntax of a
language .
As mentioned earlier, the results of this paper apply to any recursively
emunerable set. Any function D~ relation that is recursively enumerable
can be specified by a canonic system. Canonic systems can be used to
express language and string transformations of a much more different
nature than given here. The facility with which comments entries were
specified suggests many uses, for example, in handling inter-terminal
computer communication. We do not know to what extent canonic systems
can pract ically be used to express more varied algorithms tnan tnose for
s tring transformations.
(
(
We have used canonic systems to present a single method for specifying
the syntax and translation of computer languages. To ease further the
specification of the translation of computer languages it might be desirable
to use a target language other than another computer language. This new
target language ~ould have a set of primitives in which the constructions
in a large class of languages can readily be expressed. This target language
has not been developed.
(
REFERENCES
The work presented in this paper has evolved from the following works:
1. Post, Emil L. Formal Reductions of the General Combinatorial Decision Problem, Am. J. Math, Vol. 65, pp. 197-217, 1943. This work presents a formal system named canonical systems and demonstrates that every system in canonical form can formally be reduced to a system in normal form.
2. Smullyan, Raymond M. Theory of Formal Systems, Princeton University Press, Princeton, New Jersey, 1961. This work describes a variant (elementary formal systems) of the canonical systems of Post as the basic formalization for a study of formal mathematical systems and recursively enlimerable sets.
3. More, Trenchard, Class notes for course EAS 313b Applied Discrete Mathematics, Yale University, New Haven, Conn., spring 1965. In this work the definition of elementary formal systems were modified to parallel More's definition of propositional complexes (ref. 30) an-0 applied to the study of various mathematical systems.
4. Donovan, John J. Investigations in Simulation and Simulation Languages., Ph.D. dissertation, Yale University, New Haven, Conn., Fall 1966. Elementary formal systems were further modified (now called canonic systems in recognition of earlier work of Post) to meet the definitional needs of programming languages and applied to the definition of the syntax of computer languages.
5. Ledgard, Henry F. The Transformation of Source Language Programs into Applicative Expression Form, Term paper for course 6.688, Linguistic Structures, M.I.T., January 1967. Here canonic systems were applied to specify the translation of computer languages.
The following reference describes an algorithm that uses a canonic system specification of a language as a data base to recognize strings specified by a canonic system and generate their translation.
6. Alsop, Joseph w. A Recognizer or Translator for Computer Languages Using Canonic Systems. B.S. Thesis, M.I.T. Cambridge, Mass., June 1967.
The following references describe other formalizations used to characterize computer languages:
7. Backus, J. w. The Syntax and Semantics of the Proposed International Algebraic Language of the Zurich ACM- GAMM Conference. Proc.Interna'l. Conf. Information Processing, UNESCO, Paris, pp. 125-132; June 1959 .
(
(_
8.
9.
I
110.
11.
. I I
12.
Km.1th,. D. E. Backus-normal-form vs . Backus-Naur-form, Comm. ACM, vol. 7, p. 735; December, 1964.
I Burkhardt, w. H. Metalanguage and Syntax Specification,. Comm.
ACM, vol. 8, pp. 304-305; May, 1965. .
Iverson, K. E. A Method of Syntax Specificatiort, Comm. ACM, vol . 7, pp. 588-589; October, 1964.
Floyd, R. w. The Syntax of Programming Languages - A Survey, IEEE Traas. of Electronic Computers, pp. 3'4-6.-353; August, 1964.
I· I
Steel, T. B. (Editor) Formal Language Description Languages for Computer Progr~mrning, North-Holland Publishing Co., Amsterdam, The Netherlands, 1966.
13. · McCarthy, John, Towards a Mathematical Science of .Computation, Proc. bf IFIP Congress, Munich, 1962, North-Holland ' Publisr ing Co., Amsterdam, pp. 21-23; 1963.
The following reterences describe formalizations used to characterize the semantics of computer languages:
I
14. Landin, Peter, The ~-Calculus Approach, Advances in Progralnming and. Non-Numerical Computation, Pergamon Press, 1966. 1
15. Van Wijngaarden, A. Recursive Definition of Syn.tax and Semantics·, IFIP Working Conf., Baden; September 1964.
16. Feldman, J. A. A Formal Semantics for Computer Languages and its Application in a Co~piler-Compiler, Comm. ACM, vol. 9, PP• 3-9; January, 1966 .
17. Wirth, N. and Weber, H. EULER! a Generalization of ALGOL and its Formal Definition, PART I, Comm. ACM, vol. 9, pp·~. 13-23; January, 1966·; PART II, Comm. ACM, vol. 9, pp. 89-99; Febryary, 1966.
The following papers describe programming languages for exp~easing string transformations;
18. Farber, D. J., Grinwold, R. E., Polonsky, I. P. SNOBOL, a String Manipulation Language, Journal of the· ACM, vo t . 11, no. 2 pp. 21-30; January 1964 .
19. Mooers, Calvin N. TRAC, A Procedure - Describing Language for the .ieactive Typewriter, ·Comm. of the ACM, vol. 9, no. 3 pp. 215-219; March, 1966.
The follawing paper describes a computer ~rogram for expressing transformations on natural language input strings:
20. Weizenbaum, Joseph, ELIZA - A Computer Program for the Study of Natural Language Commui:iication Between Man and Machine, Comm. of the ACM, vol. 9, no. 1, pp. 36-45; January, 1966.
I
(
I
\
(
The f ollowing references (and ref . 11) point out inadequacies of past specifications in specifying the syntax of programming languages:
21. Gilbert, P., On the Syntax of Algorithmic Languages, J. ACM, vol. 13, pp . 90-107; January, 1966 .
22. DiForino, A. c. Some Remarks on the Syntax of Symbolic Programming Languages, Comm. ACM, vol. 6, pp. 456-460; August; 1963.
The following references (and ref. 16) describe generalized translators that have been implemented as table- driven compilers :
23. Irons, E.T. A Syntax Directed Compiler for ALGOL 60, Comm. ACM, vol. 4, pp. 51 - 55; January, 1961.
24. Brooker, R. A. and Morris, D. A General Translation Program for phrase-structure languages, J. ACM, vol . 9, pp. 1-ld; January, 1962 •
25 . Cheatham, Jr., T. E. and _Sattley, K. Syntax-Directed Compiling, Proc . Spring Joint Computer Conf., Spartan Books, Baltimore , Md., vol. 25, pp. 31-57; 1964.
26. Liu, c. L. The Design and Implementation of a Table-Driven Compiler System, AFIPS, vol. 30, 1967 Spring Joint Computer Conference, Spartan Books, Washington, 1967. A detailed discussion- of Liu 1 s translator is . given ·in Project MAC Tecnnical Report MAC -TR-
The following references describe to an extent the syntax of PL/I :
27 . Chladek, H., Kudielka, V, , Neuhold, E, Syntax of PL/I, IBM Technical Report TR 25.058, Vienna Laboratory, September 1965 .
28. -- -- -,Formal Definition of PL/I, IBM Technical Report TR 25 . 071, by PL/I-Definition Croup of the Vienna Laboratory, December 1966 .
Definitions of the logical terminology used in this paper may be found in the following works:
29 . Rosenbloom, Paul c. the Elements of Mathematical Logic, Dover Publications, Inc., 1780 Broadway, New York 19, N,Y.; 1950 .
30. More, T, Relations Between Simplicational Calculi , Ph.D . dissertation, M. I .T., Cambridge, Mass.; May, 1992.
31. Church, Alonzo Introduction to Mathematical Logic, Princeton University Press, Princeton , New Jersey, vol. l; 1956 .
32. ----- , An Unsolvable Problem of Elementary Number Theory, Am. J. Math., vol. 58, pp . 345- 363; 1936.
33. Chomsky, Noam On Certain Formal Properties of Grammars, in Readings of Mathematical Psychology, Luce, R, D., et . al., John Wiley and Sons, Inc., New York, N. Y, , vol. 2, pp . 125 - 155; 1965 .
The following manuals were used in developing the example subset of Little PL/I and defining its translation to IBM System/360 assembler language:
34. --- --, IBM System/360 Operating System, PL/I Language Specifications, IBM Systems Reference Library, Form C28-6571-3.
35. - - -- -, IBM system/360 Operating System, PL/I (F) Programmer's Guide, IBM Systems Reference Library, Form C25-6594-0 .
36 . -----, IBM System/360 Operating System, Assembler Lang~age, IBM System Reference Library, Form C28- 6514-4.
37. -- - - - , IBM System/360 Principles of Operation, IBM Systems Reference library, Form A22-6821-4.
38. -----, A Programmer's Introduction to the IBM System/360 Architecture, Instructions, and Assembler Language, Student text, Form C20- 1646-l.
•
,,-.. "
Appendix l Summary of Notation for Canonic Systems
To provide the r eader with a concise reference, the canonic systems notation used in this iraper wi 11 be presented by a series of short examples,
Basic Constructions:
Canon(s )
I.
2.
3.
4.
5.
~ A letter
~ 8 letter
C letter
f letter
~ f identifier
identifier 4-identifier
Interpretation
(From no prem-ises, we can
conclude that) "A" ls a
member of the set named
"letter".
"B" .is a member of the set
named "letter".
"C" is a member of the set
named "letter11•
If · .. f .. is a member of the
·s ·et named "letter", then
we can conclude that "J ...
is a member of the set
named " i dentifier".
If " i" is a member of the
stt named "identif ier" and
New Construction(s)
" ~" i's the assertion sign;
"A letter" is a conclusion;
"letter" is the name of a set
and "A" is an element in the se~.
The name of the set, here
"Letter", is called a predicate.
It ( letter .. i s a pre.mise;
The small letter d." is a
variable denoting any member of
the set ruuned "letter".
~ ij identitier if " J" is a member of the
.+ .. before the "~" separates
premises, all of which must be
satisfied to asser t the
6. ~ <A,.B> ~
7. ~ < A~C> differ
set named " i dentifier", then conclusion.
"ij" is a member of the set
named "identifier".
The ordered pair "<A ,i>" The notation "<A._B>" denotes
is a member of the set named an ordered pa i r.
"differ". The set ruuned In general, the notation
"dHfer" consists of <a1< a2~ '· · can> ordered pairs whose elements denotes an ordered n·tuple.
are d iffe.rent.
The ordered pa i-r '' <A ._c >"
is a ·member of the set
named "di ff.er" .
Abbreviations and alternate notations:
Canon(s)
8. t A letter'+
B letter
9. ~ A+ B letter
10. ~ A dHfer 8
l l. ~ AYA differ BtC
Interpretation
"A" is a member of the set
named "letter" and ""B" is a
member Of the set named
"letter" (same as canons
1. and 2.).
"A" and "B" are members of
the set named "letter"
(same as canon 8.).
The ordered pair "<A<.s>"
is a member of the set
named· "differ" (same as
canon 6.).
The ordered pairs " < A._B>"
and "<A ,c >" are members
of the set na,ned "ill!.!!" (same as canons 6. and 7.).
)
New Construction(s) , I I "I" after the "i" separates
conclusions , all of ,which can
be asserted if the premises
(here none) are satisfied .
11 + 11 is used to separate two
or more elements that are
members of the same set.
Alternate notation for
"<A1..B> differ". In general,
the notation
"a1 text .l a2 text2 ..• ~ an"
is an alternate form for
"<a1 ,a2 , ... an> text! cext2 textn-1",
where "<a1c a2
._ , , , ._a,;>" is a·n n·.tuple and
"textl text2 ... textn·l"
is name of the set in wh ich
the n·tuple is a member .
"+ '' is used to separate the
elements of two or more ordered
pairs that are members of the
same set. Th is not at ion 1,s
extended to handle n·tuples.
(
Appendix 2 Two Syntactically Legal Programs in Little PL/I and their Translation into IBM SYSTEM/360 Assembler Language
Legal Program P
P.: PROCEDURE; A: I = I+l;
IF I < 5 THEN 00 TO A; END P;
Legal Program Q
Q: P~OCEDURE; DECLARE LX LABEL;
END Q;
L: I= l+IA*IB-IC; LX = L; GO TO CHECK;
M: I = I+l; LX = M;
CHECK: IF I <LIMIT THEN GO TO LX;
Translation for P
* ,~ ASSEMBLER LANGUAGE PROGRAM FOR P
* p A
z
* I
BALR USING EQU L A ST L c BNL B EQU SVC
DS END
15,0 *,15
* l , I 1, =F'l' 1,1 1,1 1, .. p• 5' z A * 0
F p
*SET REGISTER 15 AS BASE REGISTER *INFORM ~SSEMBLER OF USE OF RlS AS BASE REGISTER *SYMBOLIC ADDRESS FOR PL/I LA!lELA *LOAD I *ADD "'F'l' *STORE RESULT IN I *LOAD I *COMPARE WITH =F'S ' *BRANCH IF NOT LOW TO Z *BRANCH TO A *SYMBOLIC ,6.DDRESS OF Z *RETURN TO SUPERV !SOR
*STORAGE FOR I *TERMINATE ASSEMBLY
Trans lat fon for Q
* * ASSEMBLER LANGUAGE PROGRAM FOR Q
* Q L
M
CHECK
z
'* LX I IA IB IC LIMIT
BALR USING EQU L L ~
AR s ST MVC B EQU L A ST MVC EQU L c BNL L BR EQU SVC
DS DS DS DS DS D.S END
15,0 'f, 115 ;,
l,I 3,IA 3-1, IB l,3 l. IC i. r LX,=A(L) CHECK
l,l l ,=F' I ' l, i LX, .. A(M) ;'t
L, I l ,LIMIT z l ,LX l
* 0
F F F F F F Q
*SET REGISTER 15 AS BASE REGISTER *IN"FORM ASSEMBLER OF USE OF RlS AS BASE REGISTE: 1,SYMBOLIC ADDRESS FOR PL/I LA.BEL L *LOAD I *LOAD IA *MULTIPLY BY IB 1<ADD REGISTERS *SUBTRACT IC *STORE RESIJLT lN l <<SET Ll< EQUAL TO ADDRESS OF L >'<BRA.~CH TO CHECK >'<SYMBOLIC ADDRESS FOR PL/I LABEL M i<LOAD I *ADD ~F' l' *STO~E RESULT IN I *SET LX EQUA,L TO ADDRESS OF M >~SYMBOLIC ADDRESS FOR PL/I LABEL CHECK 1<LOAD I i<COMPARE WITH LIMIT *BRANCH IF NOT LOW TO Z *LOAD ADDRESS STORED IN LX *BRANCH TO THIS ADDRESS *SYMBOLrC ADDRESS OF Z *RETURN TO SUPERVISO.R
*STORAGE FOR LX *STORAGE FOR I *STORAGE FOR IA *STORAGE FOR is *STORAGE FOR IC *STORAGE FOR LIMIT *TERHINATE ASSEMBLY
, ... .
l. <htur> ::• AIB lz 2. <dtglt> ::• ol1 19 3. <Identifier> ::• [<letter>]:
10 4 . <unligned inteaer> . .. [<digit> ]1
5. <ux-pt var iabl•> : :• [1IJI KJ ti Mi NJ: [ <letter> 1: 6. <1•b• l> :: • <idei>t!fier>
7. <label variable> ::• <tdentlfier>
8 . <prt-ry> ::• <un1 lgoed integer> I <Hx·pt variable>
9. <oo TO 1utuent> ::•COTO <label> ;I COTO <label varlable '>i
10. <rol op> ..• <l-1>
ll. <boolHII expreu Ion> ::• <prl-ry> <rel op> <prl.mary>
12. <IF statement>
13. <label auign stat-nt>
14. <•rlth op> ~
is. <erlth exp>
16. <arith auign state.ent>
17. <DBCLAU ot•t-11t>
18. <non·DECU..R.lt stateme_nr>
19.
20. <nate ... nt Hquence>
21. <PL/I progu11>
: :• IF <(boolean axpreulon>
T1IEN <non·OBCLAI& 1tat-t>
<label variable> • <label> ; I <label var iable>
: :• <primary> I <artth exp> <•rlth op>
<arith exp>
: :• <ftx·pt variable> • <art th o.xp>;
: :• DICI.UJt <label variable> LAaBL;
<co TO etatement> I <lP 1tatement> I <label aulgn otate-nt> I
::•
: :•
<arith anign 1tateMnt>
[ <1aba1> :j ~ <non· D!Cl.ARJ: , tata•nt'>I
[<1ab•l> : ] ~ <DECU.R.lt otatu,ent>
[<statement> ]7 <tab~ 1> : PROCl!D\11\E; < otatement aequencc>
&ND <Label>;
ln addition to t .he coo.atruct1 uaed t.n pure 8acku, .. Naur Form, WO u1e the brackets r to d•aignate any number from kl through k2 of oc:c1.1rrence1 of the enclosed expre11fon.
l. ~
2. d1a1t
3. idaaUfhr
4. uaa{gn.ed integer
5.1. flut latter for
5.2. Hx•pt var
6. .!!l!tl
7,1 , label var
1.2. .ll.!!
7 ,3 .
7.4.
1.s. ~ 7.6.
1,1 , dlthr
1.1.
1,9,
7,ll ,
7,12 ,
1,,1:,.
ftx·ec var
APp~ndiK 4 Canonic Sy1tem Specifkation or Syntax of Llttl• PL/1
~L?2t···f9fu!l
l1+ l2 ~/3 ~~tis~ /6? i 7 + fa lt~ter ~.;; ~ .P14 f • ·, + 11 ,; >'3{1s{//:S ldentlfier
d 1+ d2 +d3 td4 td5 .d6 ~d7 ~d8 }d9 ~d 10 digit ~d 1{ d 1d2 ~ • • • 4d1d2d3d4d5d6d7d8d9d 10 unsigned lnteger
~ I j, J t .. , + H r !rat letter for f!x·pt var
ii flr,t letter for fix-p t var9"' 1.2~+ ~~.!.ill£rli ~~12+ ... ?'1'2'3.J~/sJ~[,~ rtx-pt var
ldent1fler
l ldont lf ler
~ Ail.!!
i ldent ifler t i, .!!.!! a f b .ll.!! ~ ab .ll.!!
• f b + c .!!.!! ~ b _m abc
a .m l <t b .m L ~ ab .!.!l 1..
~AfA+ ... 1A.!!.ill!.!:J~Ct h+ a+ ... fa ~..!.!.!!!A+c +
h+ Z t ••, tz .!!.!!!!.!: At B t ... {,Y "+ Y latter + x .!!.!!!!.!: y 4 a xd + aye identifier ~ axd ~ aye
x dlffer y ~ y ~ -"
~ Adlaloint;\
l identifier r l, dla!olntJI 9-' l\dlaloint l,
i film j ~ i, dlo Joint J,
" dlaJolnt I t y ~t l ~ ,cy dlajoint l 9-' l dia1oint xy
(
(
8, l. J! rlmari "'1th fix·et var
8,2.
9. l. s2to stm with ref label•
label var •
9.2.
10. rrloe
11. boole•n t*Xp with flx·pt vars
12, iC atm with · ref labcl·label var a•
Ci><·pt Vjll'"S
13. l. label a s si,gn stm wlth . re f label•
l abel vars
13.2.
14. arlth op
15 , l, arlth e xp wlth (lx·pt vars
15,2,
16. arith asolgn stm with fix~ l!t var a
17 . declare stm with. decl label var
18, l.
18.2.
18.3.
111,4 ,
19 , l,
19.2.
19. 3.
l~ .4.
20 .1 .
io.2 .
21.
non·declare stm with ref label•
label vars· f ix·pt var•
stm seg with atm labels·
rd la be lo· labe I var a•
decl label vara-{ix .. pt v•r•
l l•gil l Mlm toee~ with stm l4bt•ls·
~
Pl./1 progr.un
unsi15ned inte3er r erimarl:: wi th fix·et var fl
v fix·et var J- v er imar:z: with fix·pt var v.
l .1!.l!!.!. ~ co TO l; goto scm with ref l abel l . label var A
f label var ~ C:O TO e. goto stm with ref 1 .. bel/\ label var l,
r < , • I > !!:l...21?
p{ p' primary with iix·pt var v { v' + r lli....21! ~ pq,' t>ooleall ~sp with fil<·pt vars vv'
b boolean exp with flx·pt vars v t s non·declare stm w i th r, ... i lab(l'lS .fr lab~ 1 \'al"~ .l.v fix·pt \•at·$ v
~ IF b THEN s i C stm with ref label l.r label vus ( i il<·pt vars vv'
v label var 4' [~ ~ v • f_; label assign scm with r,•f label l. labe l vars,,,
v + v' labe I var ~ v • v'; label assign stm Yith rei labe l A label v.i rs v.v•
p prlmat·y wit~. fix-pt var v ~ p arlth e><p with fll<·pt vars v
r a o•' ar i th ~:cp wi th fJ.«• pt af a' art.thJt exp with fix ... pt vara vf v' o/ o arith op var~ vv•
v 1 flx·p~ var 9-' a arith exp with fix·p't vars v ~ v 1 • a ; art ch aulgn stm with Clx·pt vars vv1
,
v label var ~ DECLARE v LAllEL; dee lare stm with dee I label var v,
g aot:o nm wi~h ref l abel f la be l var !. . r v
~ 8 non·declare atm with re f label8 .('f: lab..-t vars 'r fix-et vars,-.
lf stm with ref label Jr label vars iv fix ·et vars v
r i non•declare stm with ref labels J., label vars l ii x ·pt \'.l l' $ v v
i. label ualgn a tm wlth re f label ( label vars l r i. non-dec lare &tm with ref labels Ir labe l vars ( f ix·l'! t va r !C A
a •rich •••ign stm with f ix-pt vars v
r a non·de'clare stm with ref labeh~A lahl! l vars A fix-pt. vars v
• non·d~clare •tm -with ref labels J •. l abel va rs fv (jx-p,t va r$ v
~ iJ • tm seq wlth s t m l abe laiJ\ r,..,f l abels f label va~s.' i.v J,-.l· l labt•l vars,\ flx ·pt vars A
a non•duclare stm with re( lahl•l ~ label vars..( i' hc -pt \' nl' s v 4-' i l.:•ht> I
I·· j_: a atm seq with ~tm lab~la f, ref lahe~s .tr lah,·1 vu1· tt Lv _J_,·-~-l~l_a_h_,._l_v_a-"r'-'--s/\ flx·pt va r s v
d dN: lar~ s tm with tle1.·l lMhel var v
r d stm »cq "ti t h Bt"I l abt."lsAref lahcls;\ latwl vars,\ ,,, ..... 1 lah1."l VUt'S · V f ix-pt v arM A
J declare- stm with dl.'\.'l lalwt var v + L~
~ i: d s tn1 seq with :a .n1 l.abela .\ r,}f laht"h; \ l:ih,•1 \.'"'~I\J,~ .. · I lah1.•l v iilrs v fix.·JH vnr ~ /\
s tm s"g "'i th stm l nh,•l• /5~1~ rd lab,•ls fr{' I;, ..:.l.:,11,;;h.:.''..:.l....:.''"'".:.r"•
fix-pc ~ars v ! v' 1 , di8J,,int • 1
l s s l-s S
1 SC~ St.'Q w ith s t m laht>l.s 'e, t4..1f
s s fix·pt vars vv,1
s ~f m Hl.!9 with stm l a b~ls / r~ r lah,·l s /. laht.•l var~ • v
1. ., dis j\1 i ut vi. rL v disj,>lut l d ,' i n •. vu :-T •T-r - s r.S h•ti,a:I Sla'I S('Q Wi l h Stm lab,•ls i...
5 ~ ~d V
i l.!.!!£.1 f -,: h· •a I ~tm ~,~ r 2.: PK 'EDl' KE; • ENO
with sta, labe l :. / v at' s v 't-' ,, l Pl./ l pro,;ram
5 --
, .. I· d,,,· I rf r
Canons l' • chrou1, 7 .1~ • 1ame ae canon, 1,.. throwgh 7. t3. in Appe~ l X 4.
8.1' prl .. ry vith flx·pt var·
operand code
8.2'
9.1'
9.2'
10.1 •
II'
12'
LJ. l'
13.2'
l4, l'
14.2 '
U,l'
15.2'
LS.3'
1oto sea with ref label
labe l var-a1u1tnb.Ler 1tm1
rel op wtth br•nc.h code·
me11age
boolean eKp wtth (t><-pt v•ra
branch label•aase11.bler 1ttaa
if at• with re( labe\ ·
label var•·Hx- pt var,
a11eUlar labehi:-a11oaabler atm.a
label &11tgn ate vtth r ef label
label var1-a,1e.mbler at•
add op with op code·ineaaage
•rlth exp with !lx-pt var1-re1ult ln rex-•6st!.cnbler ltl!I&
term with fht·pt varare,u l t f.n reg-asaemble.r ,c.m.a
l.5 . 4 1 ari.th exp wlth flx - pt var,
t'ctlu l t ln r eg·a•aembler atma
IS,S'
LS.6'
L6.' arl th uolp •<• with fix·pt van•
a11ellbler 1t•1
u.naiped int•a•r r t, priaar-y vlth fix-pt varAoperand code . F't'
v fix-pc var ~ v prliKry -with flx•pt var r, opeTand code v
t CO TO [, goto at• with ref label l. la.bel var/\ aaaembler ataa
8 l *8AANC1i TO j_
£ label var ~ GO TO i, goto ata with ref label/\ lab•l var (. aaaembllr • tma
L I, i_ *LC»J> ~STORED lN ,i_ llR •BllAIICH TO THIS ADDRESS
~ < f • ~ > n l op with branch co~• 8111.. BN! + lllffl meosaa• NOT LOW~ 1100' EQUAL f NOT HlCH
pf p' primary with fl•·pt var v f v' operand coda xf x• lf-r relop with branch cod• b -u•r,•, ti.label
~ prp• boolean exp wlth ltx•pt vare vv 1 branch labftl l.. es-selllblar ,ams
L t ,IC *U)IJ) x
c b
I
l *COMPARE w 1'T1t x I
"8IWICII tF 8 TO l
b boolean up with fl~·pt vars v branch lal>ol laueinbler •t•• • + ,....j _ a non· declare sc:a vith ref label 1;. tabt: l vars ~ fix·pt vara v' a11e.t,ler labeh i..8 a11...,ler atu ·~ T t, d11!olnt ~ ~IP b THEN s L! 1tm with r~f l abal fr labal vars ( UK-pt vara vv' aa aembler labele~l ataembler at••
l
•• .. a
*S"tllllOLIC ADDRESS OF i_
v label = i; label a aaign 1t• with ref labetf_. labe l v&re v. a11elllbler at•
• A(i) -Sff • EQUAL TO ADDRESS Ol' L
v ~ v' label var ~ v • v' ; label a111gn 1tm with ref Label,\ labe l vare v ,v,' ae1e,abler 1tm
MVC .. SIT v EQUAL TO v '
~ + { • add op vlth op codo At S -•uge ADD f SUITIACT
f- * f I mult op with op cede Mtll mo pna• HULTIP!.Y l!Y f DIVIDE 8Y
p priinary vith fix-pt vat v operand code x
L 1,x ~ p arith exp with
*1.0&D x
fix - pt var, v reeu LC in reg
pf p • pr itl\Dry wtth f i>c. ·,t var v ~ v • operand code x f. x •+ m owlt op with op code c ma:aaage. g
~ p,np1 term utt.h CJx-pt vara vv' re.ault ln reg l •••embler at1H
L )I
l ,x O,x. •• x
c:f, pmp' term with fix .. pt var, vv 1 re.,ult in reg ) a11ainblt1r 8tlll
L 3 .x #1.0o\D x M 2 ,x "& ,c
t term vlth fix-pt var, v r•ault reg 1 aas..nebler etaa a + F prl-.ry with fi,t•pt var v\ operati.d code x f • c!tt op vith op cod• c mea1age a r tmp term with fix·pt var, vvl reautt. in reg i ••••rnbler atma
•• 1 .. 1,x •ax
t term wlth (lx•pt var1 v re,ult tn rag l •••••blar stm:a a r t arith exp wlth fix-pt var, v :ra•ult in t'•g l aeo:mbler .etm, ••
• arkh exp with fb·pt van • result in r~ l auamblu ,t .. a 1-p pi-l .. ry vltb var v1 operand code x o add op vtth op :ode c M11•ge g
~ aop arlth •xp Vith fix-pc v•r• vv1 repult In reg l ••••mbl•r •t• •• c. 1,,c. *& v
1
a11e9Ler at•f
& Al'(th exp Vith (i,c•pt V&T8 Y reault iD r ·ea l •••ellt)leT at•f • t-t term \llth, fix-pt ver• v' reault ln r"• 3 ••tpabler attu :. +~ add op vlth op code c !UJ!I! a r a i.> t erith •xp \f1th fix-pt var• vr' ... ,ult i a r•a l llteembler atma
'• ... a
cR 1,J *11 UGlST!RS
v 1 fix-pt var er a arith exp wlth fix-pt var• v re1ul t tn rea 1 •••ecnbler •t.Ju •a r vl • a; arith •••Jan ata vlch ft.lt-pt var, vvl •••Ntbl•r at.tu s. ST "11TOU USULT lN v 1
I
17 '
18. l '
18 . 2'
18. J '
l8 . 4'
,~. l.
19,1 '
,~.J·
20.1'
20. 2'
2 l. l'
2\.2 '
H.J '
<l c~lare stm with decl label var
non-d~t lare stm wit h ref labels
labt.'l vars-fix-pt var s
assembler labels-assembler scms
:,; tin ~,:q with s t n, laht"ls
r~f l uh~ts-label vars·
d c"· I l;1 h1.· l va rs · (ix-pt vars
a~sL!mh l ~r l abclsHuss-.,mhl<'r scms
t~uul stm seq wi t li ~ln, L~bc l M·
v~,r~ -a~st.'mbl~r stms
s~t of ~nrs wic l, a~~embler data ~tms
v l abel var ~ DECLARE v LABEL; declare scm wl th decl label var v,
g .G:oto stm with ref label fl label va r f_ a~ ~fl'mhler stms s 'r r a ~ g non·dec lare stm wit-h re( labels t r l abel vars 'r fix-pt vai:s assemb l er labe l s assemb ler stms s
8
if stm with ref label {_ La bt• l v.ol"s 1.-r fix·pt vars r assembler Jabe l !I fa assembler sc-ms s8 r i non•declare stm With ref lab~l& Jr label VSTS f V fix -pt vars V assemb ler labe l s1a a a g~mb l l"r Stms~&
>~ labe l assign st1n wl th re t label rT label vars lv asgcmblcr stms s3
lf.:!o~·dec tare s tmwith ref lubl" la~ label vars fv fi x - pc vcHSl\8.li$L~mbl t.-r labelSf\4SS@mble r s t ms sa
a arith a.ss·ign stm wtth Lix-pc vat's v assembler stms s3
B nun-declare stmwuh ref labels1'labet varsAfix·pt. vars v a:!Ha•mblt .. r l ah1.·lsAaSRt'mbh•r i:;tm~ ~a
s non -d~('lare stm wJch rt'[ lahels IT label vars}~ flx - pt v~r~ v A!iSt'mb l ll t' La~els ,'8 asscmb l ,•r s tn,s $.a
ts s tm seq With stm tnbel3Aref lRbelsty lab<>l va-rsJ~ d1.·c l labttl varsJ(tx-pt vars v
asst-mblc·r le.be l:. l Bss~n\hl'°··r stm,;- s ,. a
5 non -decla,e stm wi th ref l abels .~ labe l va,s l v fix -re vnrs ,. ass,•mbler la bclsY,. assembler stms •a + fl labe L r }: 9 Stll'I .seq with stm labels~re r labe l s.~ labe l vars fr Jccl l ala·l varsA (ix 00 pt vat'$ V
as ~"·mblcr label• .. / 'a acsembler s t m!I
f EQU * *SYMBOLIC ADDRESS FOR PL/ I LABEL 1 5 a
d dec lare stm wi th decl label var~
~ cl ij:tm st!g with stm labels/\ re( l ab-els/\ label vars/\ decl label vars v Ji x -pt var-s I\
ass1.!.mbl ttr labels ,\ 3.S&~tribleT stms/\
d dN· l ar<' stm wtth ch.·~ l lobc.1 l \'tlr v { · f .!.!!?.!l. ~ £: cl S't m seq wi.lh stm tab1.• l jj A r4!! Label s /I l.e.bC' l vars I\ de~: l lab I! I v~rs v f i x-pt vut·~ A
assembler l3he l s 11 .1 s~l~n1blc t stms I\
st s' s tm scg w!t. h scr.1 laUt.•I ... ,J l J; rt?( labels f r ~ >~ label vars J v f I~ d-.!,: I lab,·l va rs /~ (> (~.,
(ix-pl vurs v ~ v ' d N~t.·1nhl,·1 label s J ). l' assemble-, stms s j.. s t I disjoint f• t\ J, d l si(,inl,' · - a T a a T a s s ·" a
I _ ss ' stni i:wq w1 t li i. L111 lobc.· ls} J ' ref labf..• l s, 1' Label vart1 f • <lecl \Abt-l varsJ °' ·· ; r - S & t" r V \' v<r' Vu
(i;s - pt var,.; v v' , t ,: 1't.•111ldL'I ,nbr ts/0
;:~ nssembl~c stms sas~
s sLm riNI "'-' it.ii stnl la bels ls t'cf l ahcls ~t' lab{>l vars f r dcr.: 1 lRbe l vars J \'d fix ~pt v a ts v
a sl:tC U1b h• r l:..\.b"ts I a~st•mh l,·1· :.ln'ls .s <~. J' 1-Ji.s jl:d nt '.'1 cj--a ------- a I v :,i
v tli 1qolnt I' .. l. A in , ··t f i n 1 1 ..: [l di-s j1.) int .f ... f .d S r t' - r; V - V ( ..,,r a c, V t s J1.•>:;a l stin s,•g wlth sttu ln lwL t:t J~<!, .!!.!!,!!.f!d v .afHH·ml>h•r s t m8 .::ta
A s,•L 1:d vars with :\SJH'mhter Jota Rtru.s ,,,.
V :-1.•t ,11 1.•t1r~ with n~:;.t.•mbl1.r 1..k1 t a stm:; :--11 t v
1 id 1..·1'lliflt:r tv,, dfsJ..,i n t v
f· , 1
, :,11,.• t .. ,r v.ir,: wit h .i~s~·mhl,·:' J uta i-tms
" J
\ l ns
/ ' label <.t • val id stm seq wi~l , stnl labds f, ~ v "ss embler scms
J, 1i 1• jt•lnt I v ·i '°~ .t,·l ('r var:-. Wi lli .i.ss,·r1blt'r data s1.ms sJ
t-- A PRClC.EO~N.t-: : ... f':N ll.1, PL/I ,,r,•s ram wit h tr.111:d.ithm
*
M l.~ l'SlNc;
... f.~ll
I 5 ,() , l 5
()
>SE l HF.< , IS I f.l< 15 AS Ui\SE REt:ISTER ,, r~l'lll\.'I ,\SS l·:~llll.1-:l( 01' l' SE or Ill~ i\S IIASE Rl((: tS'rF.k
" RI·. l'l' R~ l'n Sl 'l'~;R\' I SOR
l'r.llJ'T[~:A I~ i\SoF.MHl,Y
\·.
I List of * prealsea
.L
·'\ -' -2 I 3 11,12 · ~· * l 4 . 3 t s /4 t 6 -I
:6·\· .1 .I
8 • 7 J
.9 I 8
"10 -I
11 's•J9,110 I 13 ,Ill 12
I I) I' 12
)14 -~IS 44' 114' 1,16 ',s '11 1
13' 116
~18 ; I I
.19 18' 18' 120 /19
121
~22 j • I .4' 20' 21
'2) 116 I
24 L23 I
2S 1'22• ' 24
I 261'25
I Canon I fr .. 1
~PP·' I i.li I
s.1
l.
s.2
8.2
LS. I
2.
4.
8.1
IS,
14.
lS.2
16.
18.4
I.
).
6.
19.2
2.
4.
8.1
lO.
ll.
9.1
18.1
12.
Appendllt 6 Derivation of txa..ple Le11l Program
?he fol1C111ln1 table 1peclflu a derivation of the ,yntactlcally leaal progu11 P given ln Ap;,end , x 2.
lule l: 4 ,. der lvatJon
luh 2: d derlvat!on ~) list of preehu 4, conclualon t L~ 11
cano11;f; amid d • dt1c duivatloo
1 - - ~
Concluolon added t o derlvatlOQ
I first letter for fix -pt var
l .!.!!.!.!! I fix•pt var
I primary with fix-pt var 1,
.Li
t arlth exp with fix-pt var, l ,
I d l<
l untlgned integer
t prlury v!th f ix·pt var fl
I arlth up vlth fix·pt vua A
+~ t+I arlth exp with flx·pt var, 1,
1 • l+l; arith ass i gn st• with fix-pc vars 1,1,
l s I+l; non- declare at11 with ref l abel'\ label vars II fix-pt vara t, I,
,\ .!!!.!!!: A ldent I fier
A~
A: I • I+I; ttm seq vlth at11 label a A ref labels/\ label vars r. decl label vara11 (lx·pt vars l,l.,
s~ S unalgned integer
S pr lury v i th £ix•pt var II
< !!!.2.e t<S boolea~ exp vlth (lx·pt vars I,
CO TO A; goto atm vlth rel label A, label var I\
CO TO A; non- declare a tm vlth ref label A, label var11 fix•pt vau
lf I < S THEN CO TO A; 1f 1t• vlth rd label A,
r -Lht of prwse,
i.
J 27 i26
l -28
11s /
29 1 . 11·'21·'28
I )0
' 31 130
J )2 '30' /)0
I )3 '30•-"31 I 1i.s )4
I )S . 134 135' jlS , 36 . . 37
j • 38 'J.S' flS .llS
; )9 l'29 4) }28 • 16 .J38
40 f-t 4 I 140•{0·
; 42 '41
43 -j 44 f . 4S 43
46 '44 !
47 ;46'146
;48 47.146
Canon from App.4
; f- ;1
119.l
7. ll
20.1
7. 7
7 .12
7.1
7.7
7.)
7.2
1,S
7 .10
7 .S
20.2
l .
) .
6.
7 .1
1.7
7 .12
7 .12
7. l)
7 .13
7. l)
co·nc1u,lon added to derivation
~I
----·--IF t<S TRf'1 CO TO A; 1t11 1e9 vlth atm labels/\rtf labeh A,
label YIU,'\ dttl label VUIJ\flX·pt var, l,
A, disjoint I\
A: 1 • l+l; lf 1<s TH£N 00 TO A; l ttl ,eq wltb at• labeh A, re( labeh A, label var1Adecl label vaul\ flx•pt vau l,1,1,
I fil!!.!: A
t, dhjolntA
I. I, dllJolnt A,
l,t.1, dl1Jolnt A,
"· l!!! /\ ~
A, .!!l A,
A, dis jo int/\
II .!!! II
A: t • l+l; If 1<s TllEN CO TO A; legal 1t11 seq vlth 1t11 label, A, !!!.!, 1,1,1,
p .!.!.!ill p !dent lfler
p ~ ,\ ill!!.!: p
l !!.!!!! p
A, dbjolnt P,
1, diajolnt P,
1,1, dh!olnt P,
1,1,t, dlaJolnt ~·
P, dbjolnt A,1,1,t, ' label vars A f.Lx·pt vars I,
J 49 45•' 48 I' , , 50 42' 41' 49 21. P: PROC-!DURt; A: 1 • t+I; lf I<S THEN 00 TO 11; £ND P; PL/I program 118.2 ' I tr I< S Tl!ES CO TO A; non-dee tare at• vlth rd labels A,
labe I va rs 'I fix-pt vars l, I Derivation for example progra• • '1('2( ... <'so(
* " " denotu a repet ition ol tbe lht 1,lve,1 preehe until the nWlll>er o( pr .. bu ln the canon la •tcbed.
Ape!ndb 1 De~lvatlon of Ex-l• Lo&al Prof '<I l to Traaolacion i nto 1111 Syotflo/360 Au..,ler 1.a,.. ..... We vit 1 a11U111C that the 1trlna
·1,'i~11c.4../1 <114< ' 1s( 116< 'ta<-' 19<'2t1/1o<t J l<.' 12c.~33c.114<.'3se,6~1,<.' 3a<-'i.o<.'~ 1< '42</43{'44C"4,< '~6<;47<.'49l;49<
from the derlv1tion of ApptDdU 6 h •ho a Mlll:>eT of the Ht named "derivation" for t .he derivation of thh Appendix.
Liit of pre• l tee
I
canon~ frOII App .S
J ~L1
i
Conclu.,ion addt.d to derivation
j_
l · 1· 1., ,' ! ) '-i I l:i
l j I'' l· -
( I H Aj,p 6) I I I I
l; Li: .lj. L..
l 6 Ii;, Ls.
'; I Lg
1s I 116·i,
i; 14, lio -l• -
11
lfffi·'i1·
I I
!
I
• l u.Liz I j_ i,.JL i 4 ·Lio ,li,
i
I l;s, li6
"· '1· L l6'. IS
l . I,. 171 12
I ia!li4•.f;6,fi, ~·I
I
I /I
I 8.2 • 1 1 prl.11ary Wtlh fix:·pt var 1, Ot!fan.d Code
tS.2' l adth exp with fix·pt van I , re,ult l o reg l a aae.mbhr n ..
L l.1 *LOtJ> I
8. l ' j l pri..lury vitb fix-pt var/\ operand code • P' l '
l4. l' + add op v tth op code P ••u11 ADO
u .s• I 1+1 &tith •xp vlt.h flx-pt var• I, 1'e1ult la r•1 t •••em>l•r l[U
L A
I ,I , • .p•1•
*LOtJ> I *ADO-F ' l '
16. 1 I 1 • t+l; ar i th •••ign 1t11 v lth ftx-pt vare t,t, aue:•bl•r 1tu
L A ST
l, l 1,-V'l' I , I
*UllD I '*:ADJ>-F' l' *STORE ll£SUl. T DI I
l8.4 1 I t • t+l; non•dtt lare 1te vlth r ef l.&Wlt A l.abcl van A·Hzt·pt var a.- t-,5, auhliblc r labt:hA ••••mbler at••
L .l ST
I, I l,4''1' I, I
•tiw) I *ADO-F' I *STORE llESUl.T Ill I
19.2 1 I A: I • l+l; ata •!9 vith at.a lat.eh A, rif labehA label varaA d•c l bbe l var, Afix·pt var1 I ,I,
8.1' 10.' I..
).) . 6 ••
II.•
9.1'
18. l'
4.8'
12 ••
18.2'
a uellbler labte1 A a11ea1bler 1tm.1
A EQll L A ST
• I ,I l,•f 'l. l, 1
· Sn!BOLI.C ADDRESS FOR PL/I U.BEL A *LOAD I *A.J)()&f I l *stOllE USUl.T Ill 1
S prl..Mry v lth flx·pt varA opet'a nd code• P'S'
t < rel op wtth branch code IHL and ••• age HOT LOW
z !!ll.!!.' Z ld•ntltilr
z~ t<S boolean ekp vith flx·pt var, I, b·ranch l abel z a11Hlbler 1tia
L c atn.
l , 1 I ,•P'S' z
*LOAD I *CONPAll WITH • F ' 5' *BIWICH IP NOT LOW TO Z
CO TO A; goto at• v i.t h ref Labe l A, ~Aauembler •tu
a A *BIWICR TO A
CO to A; non-declare st• vtth t'ef label A, label vara A fb·pt varal\ auetlbler labeh ,\a11Mlbler 1tu
A *BRANCH TO A
Z dhjolnt II
IF I<S TR!Jf 00 TO A; i C ata v ith ref label A, label var, A Ci.a ·pt val'1 I, •••••t•r labe.lt %, •••Hibler •t••
L I ,I *LOAD I c l, • F 1 S 1 *Cl'.IIPAll III'l'H •F'S' IN!. z *llWICH IF NOT LOW TO Z a A *BIWiCll TO lo.
z !QU * *SYMBOLIC ADOUSS OF Z
J;,jl;. 1Jl;9 119. t • I
U 1<S T1IEII 00 ro A; noo·dadare •ta v!tb ref bbels A, labd v•N A fb.·pt vara I, a,1 ... ler l.abeh Z, auHlbler ,c.u (a1 LD21
9 r, I<S 'l'1lllC 00 TO A; lta HQ vltb sta labeh ,\ ce! labeh A,
laN:l var•1,.de.cl Label vara1,,.ft.x· pt var, I, a111.llbler labeh z, aue.)ler ltN (at in 1i_
9)
I .
Derlvatloa {or ._1. prosru and It o tra ... latloo • l 1<Jz<"l< 16( • • • <'o< 'ic;2( • • ·/j9
Uot of p1'P1H I
.i
l 211 !i2 ,( 22 ,8.,20.,28'~1
l· ~-1
23, "24i
125 lj, f 26 24 1 i, A)6'~6
I 29 li,·121
j i, ~6'~9 I io 1i2~3~9·~,4e·'2,
1· -)1
1 32 12·'2· ... i . ,. 3) '1.
j 34 I i1 ~2 ,fj3
ii ., 3l'iz. I j fj5• 'j5,/35 ; 37 136'136 .I ' ;, ,,
)8 36' 37
I 39 '\2 ·1io· '4, ·4. .lja
Ca.non ftoe App.5
Id-~
7 .61
20. 1 •
'.,. '.,. 1 . 12'
'.12. '.13'
7.1)'
7.1)'
20.2•
21.l'
) .. '.11 •
21.2'
7 .3'
'.s' '.6' '.6'
21.2'
Coai:h,11• ...S<IM to • erivotloo
/ l
A dhJolnt Z,
A: I • I+I; If t<~ THIN 00 TO A; 1ta !!9 vitb ata blteb A,1 r ef l abelt A, label var , A dt.cl label var 1 A fix:Jt val'a I.1.1, auMabler l~la Z, a,,...,le r •:S-
.l
z
iqu L ,. ST L c IIIL
' l!IQU
A~Z
l~Z
• l,I l,•F'l ' l,I I ,I l. •P'S' z ,. •
A, d h Jolnt Z,
I, dhJoint Z,
I,I, dhloint %,
1,1,I, diaJoiat Z,
t, diejotat A,I ,L, f,
~C lo.ODUSS POI FL/I LUii. .l *tOAI) I •AJ>O-·p I l I
"STOil£ llESUt.T Ill I *t.OAD I tt(!(l(pAU VITB . , '5 ' *SlAIICH I1 tor LOW 10 Z *IIAIICI! TO A "SlllaOI.IC lo.DDUSS Of Z
A: I • 1+1; IP I <S TRiii CO TO A; le&al lta Ha vlth at• !!.!!..!! 4 , !!!.! I ,l,I, aunbler at.u (• • ln ,4
3>
/\ aet of var, v itb au..a, hr da t a et.al A
I ldeot lf ler
1, dhJolnt A
I, H t of v&ra vtth au•blar data atu
I • DS
I .!.!!! I, !!! I,
1,1, .!!! I,
I . I.I I .!!! I,
, *S?OIACI POR I,
P: PaocEl>UU ; A: I • l+l ; IP I<S T'DII QO TO A; END P; PL/1 prograa vitb tru1latioo
• * ASS!KIL!l LAHCUM:I PIOCIAII roa , *
A
t
* 1
BAU USIHC
IQU L 11'1
ST L c INL a IQU SVC
09 DD
IS,0 *,IS
• l,l l,• F'l '" l,I l,1 1.•r •s• z A
* 0
r p
*SIT UCIST!l 15 AB IIAS! UCISTll *IllPOIII .USIKBUll or USS- <11 ll 5
AS MSI UCISTU "S!IGOLIC ADDUSS l'Oa FL/I L.UIL A *tOAI> I *ADO •r' t' *STOU USULT Ill I *tOAI> I "<Xll!All WITH •r•s• *IWQI tr IIOr LOW TO Z *IUJICII TO A *fllOOLIC lo.ODUIS Of t *UTUl1I TO SllnlVUOI
*ffOUC& POtl l *TUKIM?'I ASSIMII. Y