SlideShare ist ein Scribd-Unternehmen logo
1 von 38
Downloaden Sie, um offline zu lesen
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Traduzione de “The syntax and semantics of the proposed
International Algebraic Language of the Zurich ACM-GAMM
Conference”
di John W. Backus, International Business Machines Corp.,
New York (USA)
15 - 20 giugno 1959
Traduzione effettuata da Google Traduttore
Adattamento di Salvatore Giglio
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Introduzione
Ho deciso di tradurre in italiano e pubblicare liberamente questo documento attraverso cui John W.
Backus presentò ufficialmente la sua notazione BNF alla prima ICIP, International Conference
Information Processing, che si tenne a Parigi dal 15 al 20 giugno del 1959 ora considerata anche come
il primo congresso dell’IFIP. Non essendo un madrelingua inglese mi sono avvalso di Google
Traduttore ed ho poi dato una forma più comprensibile a certe frasi tradotte stranamente. Questo
lavoro l’ho svolto per agevolare coloro che spinti da necessità di studio o, come me, da curiosità
autodidattica e passione per l’informatica, si sono imbattuti nella Backus Naur Form e desiderano
capire come sia nata. L’innovativa notazione ideata da Backus serviva per armonizzare e presentare
gli sviluppi progressivi del nuovo linguaggio di programmazione ALGOL che venivano promulgati
a mezzo stampa attraverso l’Algol Bulletin, redatto nelle fasi iniziali da Peter Naur quando lavorava
alla Regnecentralen (la prima azienda di computer danese), e sul magazine dell’Association
Computing Machinery, o ACM, Comunications of ACM. Una lettura a dir poco interessante che ci
restituisce l’atmosfera di quei tempi lontani in cui, nonostante i disastrosi esiti della II guerra
mondiale e il clima della guerra fredda, gli scienziati di due continenti uniscono le forze per realizzare
uno straordinario esperimento di informatica.
Attenzione!
1. Per non alterare i simboli impiegati originariamente da John Backus nel suo documento, ho
ritenuto opportuno effettuare una serie di catture video lì dove comparivano segni grafici
non presenti nel set di font Times New Roman con cui è stato redatto questo testo. Va da
sé che il lettore/studioso/appassionato più zelante potrà riprodurre, se necessario, sicuramente
con font vettoriali come il Cambria Math ciò che io mi sono limitato a copiare.
2. Il lettore noterà che la numerazione associata alla descrizione dei vari passi della notazione
risulta alquanto discontinua; a tal proposito mi preme precisare che mi sono limitato a copiare
verbatim il testo originale così come riportato nel documento di cui al seguente link: The
syntax and semantics of the proposed international algebraic language of the Zurich ACM-
GAMM Conference (softwarepreservation.org), limitandomi a disporre lo scritto su di una
sola colonna anziché su due. Per la traduzione ho utilizzato una struttura tabellare che mi ha
consentito di spostare, nella colonna di sinistra, i capoversi delle descrizioni in modo tale da
agevolare la consultazione del documento tradotto.
S. G.
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
1. Testo in lingua
originale
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
The syntax and semantics of the proposed international algebraic language of the Zurich ACM-
GAMM Conference
By John W. Backus, International Business Machines Corp., New York (USA)
This paper gives a summary of the syntax and interpretation rules of the proposed international algebraic
language put forward by the Zurich ACM-GAMM Conference, followed by a formal, complete presentation
of the same information. Notations are presented for numbers, numerical variables, Boolean variables,
relations, n-dimensional arrays, functions, operators and algebraic expressions. Means are provided in the
language for the assignment of values to variables, conditional execution of statements, iterative procedures,
formation of compound statements from sequences of statements, definition of new statements for arbitrary
procedures, and the re-use and alteration of program segments. The proposed language is intended to provide
convenient and concise means for expressing virtually all procedures of numerical computation while
employing relatively few syntactical rules and types of statement. 1.
1. General
In May 1958 a conference in Zurich completed a joint project of the ACM (Association for Computing
Machinery) and the GAMM (Association for Applied Mathematics and Mechanics) by approving a proposed
International Algebraic Language (IAL) or ALGOL. Other papers to be presented here discuss the history of
the project and various aspects of the language. It is the purpose of the present paper to describe precisely both
the syntax and semantics of IAL. The description given here will be that of the so-called "reference language"
which, for definiteness, employs a specific set of symbols and notational conventions. It should be kept in
mind, however, that the reference language form of IAL exists primarily for the purpose of describing the rules
of construction of the. language and its meanings. In actual use, a variety of symbolizations and notational
conventions are envisaged, each representation being a fairly direct transliteration of the reference language
and having the same rules of syntax and semantics. "Hardware representations" will generally use a smaller
set of symbols than that employed in the reference language and will be suitable for mechanical translation
into machine programs by a given type of machine. On the other hand, the "publication forms" of the language
will employ many of the notational conventions of mathematics (e.g., exponents, subscripts, Greek letters) and
will be used in human communication of IAL programs. The description of the reference language is given in
two parts. Chapter 2 gives a brief informal description of the major elements of the language in terms of
examples. Chapter 3 gives a formal description of the structure of the language.
2. Informal description
2.1 General
An IAL program is a sequence of statements which may be interspersed with certain declarations. Each
statement describes a rule of computation and, explicitly or implicitly, specifies a successor-statement (the
successor being the next statement in the program unless otherwise stated). The computing rule given by a
program is, of course, the sequence of computations specified by the statements when taken in the order
provided by successor-relations. Declarations state certain facts which are to obtain throughout the
computation. Their location in the program is generally unimportant. The" following paragraphs present some
of the important properties of expressions and statements, with examples.
2.2 Algebraic expressions
a) Algebraic expressions are composed of variables, constants, functions, and operators for the usual
arithmetic operations.
b) Names of variables, functions and other entities are composed of alphabetic and numeric characters,
the first being alphabetic. A sequence of characters may be of any length.
c) It is understood that the arithmetic operations in an expression signify a floating-point approximation
of real number arithmetic. Some variables may be declared to be integer-valued. The effect of such a
declaration is that any value which is to be assigned to such a variable is first rounded to the nearest
integer.
d) d) Array declarations (d. 2.5) may state that certain names are the names of arrays of data of various
dimensions. These names may appear in expressions as subscripted variables which are followed by a
- 1 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
sequence of subscripts enclosed in a pair of square brackets, the number of subscripts corresponding
to the dimensionality of the array and each subscript separated from the next by a comma. Since
parentheses are used to enclose function arguments (and subexpressions), it is easy to distinguish
between functions and subscripted variables. A subscript may be any expression; the value of the
subscript is the integer formed by rounding the value of the expression (if it is not already an integer).
Examples of algebraic expressions:
In particular, if i and j both have the value 1 (or 1,2) when the above expression is encountered, it is then
equivalent to:
R2, 1 × S1, 2·
2.3 Boolean expressions
Some variables or arrays of quantities may be declared to be Boolean-valued (i.e., having only the value 0,
"false", or 1, "true"). These variables, the constants 0 and 1, Boolean-valued functions, and subexpressions of
the form:
(ErE')
may be combined with the Boolean operators "and", "or", "not", and "equivalent" to form a Boolean
expression. (In the above E and E' are algebraic expressions and r is a relation, e.g., (x/y> 1).)
Examples of Boolean expressions:
This Boolean expression is true if, and only if, either X is greater than Y or Y is greater than Z2 or both. The
operator is that for "or".
Here A and B must be Boolean-valued variables. The expression is true when either A is false and B is true or
when A is true and X equals Y + 1.
2.4 Statements
2.41
a) Statements may be either basic or compound (formed from a sequence of statements enclosed in the
statement parentheses, begin and end). Statements are separated one from the next, by the separator";".
Example of a compound statement:
begin a[i]: = b [i] + c [i]; x: = a [i] end
In general, if S1, S2, …, Sn are statements then
begin S1; S2; ; ; Sn end
is a statement.
- 2 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
b) A statement may be labeled, as follows:
L:S
where L is a name or an integer; L thus becomes the label of statement S.
2.42 Assignment statements
Assignment statements direct that an expression is to be evaluated and assigned as the value of a variable.
Examples of assignment statements:
a) x: = a + b
means: assign the value of a + b as the value of x.
b) alpha: = 4.63
c) r [i, j]: = s [i] + t [j]
d) B: = (x > 0) ˄ A
here A and B are Boolean variables and B receives the truth-value of the Boolean expression on the right.
2.43 go to statements
a) A go to statement may specify some statement, other than the statement which follows it, as its
successor in the computing process described by the program. This may be done explicitly by writing
the label of the desired successor as follows:
go to A
where A is the label of some statement in the program. Or, the successor of the go to statement may
be made to depend upon the value of some expression by the use of a switch variable whose subscript
is the desired expression. The value of a switch variable is a label. Thus, if "branch" is the name of a
switch variable, then:
go to branch [i + j]
has as its successor that statement whose label is the value of branch [i + j].
b) Switch variables are defined by switch declarations (2.53). Thus, the switch variable "branch" might
be defined by the following declaration:
switch branch (A1, A2, B1, B2)
where A1, A2, B1, B2 are labels of statements. The value of branch [i + j] is then the (i + j) th label in
the sequence (or the nth label, where n is the integer formed by rounding i + j). For example, if i + j
equals 3, then the value of branch [i + j] is B1, and in that instance, "go to branch [i + j]" has the same
significance as "go to B1".
c) Switch variables may be used in the definition of other switch variables. Thus, the following two
switch declarations might appear in a program:
switch branch (A1, A2, B1, B2)
switch fork (branch [i], A1, B1).
In this case if i equals 4 and j equals 1, the value of fork [j] is B2.
- 3 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
d) A switch variable may have no value in some cases. For example, branch [i] as defined above has no
value if the integer nearest i is less than 1 or greater than 4. In such an instance the successor of "go to
branch [i]" is the next statement in the program.
2.44 if clauses and if statements
The if clause, "if B", where B is some Boolean expression, combines with the statement, S, following it to
form a compound statement. This· compound statement has the same effect as S if B is true and has the effect
of "no operation" if B is false.
Example of the use of if statement:
if (a > 0); x: = 1; if (a = 0); begin x: = y; p: = 0 end;
if (a < 0); go to B; S
In the above program segment statement S is encountered unless a is negative, in which case "go to B" is
executed; if a is positive and non-zero, x is 1 and p is unaffected when S is reached, otherwise x equals y and
p equals 0.
2.45 for clauses and for statements:
a) A for clause, like an if clause, combines with the statement, S, following it to forma compound statement.
A for statement specifies that a given variable take on a succession of values and that the governed statement,
S, be executed once for each value of the variable. Thus,
for x: = 1, r + s, k, 6.3, -10; a: = (a + x)/x
causes the governed statement to be repeated five times, once for each of the listed values of x. Since the
statement governed by a for clause may be an involved compound statement which may include other for
statements, complex recursive procedures may be easily specified by their use.
b) Sequences of values may also be given as arithmetic progressions:
this clause directs that i should assume the values: a 2, a 2 + b/2, a 2 + b,"', a 2 + nb/2,'" until y + 1 is reached
but not passed. Several such progressions may be included in a single for clause; e.g.
for r: = 1(3)10, 12(4)20, 21(-7)1
gives the sequence of r-values: 1,4, 7, 10, 12, 16, 20, 21, 14,7.
2.46 converge statements
a) A converge statement preceding a compound statement S causes those sub statements comprising S which
do not explicitly specify a successor, to have the statement following S as their common successor. However,
in the case of an if statement, only the successor of the governed statement is altered. The successor of an if
statement with a false Boolean expression is the next statement. Thus:
converge; begin if B1; S1; if B2; S2; if B3; S3 end; S4
causes that single statement Si to be executed which corresponds to the first true Boolean expression Bi; this
Si is then succeeded by S4. Thus, if B1, B2 and B3 are all true, the effect is to execute S1 and then S4.
b) A converge statement may also be used to conveniently select a single statement for execution as follows:
- 4 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
converge; begin go to branch [I]; L1; S1; L2: S2; L3: S3 end; S4
If "branch [i]" takes on the values L1, L2, La for i = 1,2,3, then the statement following converge has the effect
of the single statement Si followed by S4.
2.47 do statement
a) A do statement is simply a shorthand way of rewriting a segment of a program which appears
elsewhere. Thus,
do A; x: = y + z; A: r: = x + r
is another way of writing the following:
B: r: = x + r; x: = y + z; A: r: =x + r
where the copied statement has been given a new label, B, simply to avoid having two statements with
the same label. The choice of new labels in the copy is immaterial as long as the reassignment is done
consistently throughout the copy.
b) A do statement may specify a sequence of statements to be copied by giving two labels.
do R, S
thus represents the sequence of statements from the one labeled R through the one labeled S.
c) A do statement may require that certain alterations are to be made in the copy which it represents.
do R, S (x + y → x, a[i] → beta)
stands for the segment from R through S but with the name "x" replaced by "x + y" everywhere it
appears and
with "beta" replaced by "a [i]".
2.48 stop statements
stop statements have no successor, hence they signify the operational end of the process described by a
program.
2.49 return statements
A return statement, written "return", is used only in programs which define the meaning of procedure
statements. It signifies that the defined procedure has been completed and that the successor of the procedure
statement which invoked the defining program is the next statement in the invoking program.
2.410 Procedure statements
A procedure statement indicates that some particular process is to be performed, employing those entities
indicated by input parameters and producing results which are designated by the output parameters. (Some
procedure statements may also indicate specific successor statements by a list of labels or switch variables
which are associated with various exit conditions). Thus,
integrate (F(r), a, b, e) =: (int): (L)
might indicate that is to be found with an error less than e (if possible, with the given procedure),
that the result is to be assigned as the value of "int" and that if the desired result is not obtained the successor
of this statement should be the one labelled L. Some procedure statements may simply be added to IAL as
primitives (and realized by machine language subroutines). Others may refer, by the name which stands in
front (e.g., "integrate"), to an IAL program (d procedure declarations 2.56) which represents the process
indicated. Some procedure statements may not have any input parameters, others may have no output
- 5 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
parameters. Thus, a procedure statement which causes one number to be obtained from an external medium
might be,
in = :(a)
indicating that the number should be assigned as the value of a. Another might be print (r, s, t). Another
procedure statement may specify the replacement of a matrix, A, by its inverse:
invert (A [,] =: (A [,])
In general, it is intended that virtually any process can be expressed by a procedure statement.
2.5 Declarations
Declarations in an IAL program state certain facts which are to obtain throughout the program. They may
appear at any point in the program, but their position in it is not significant.
2.51 Type declarations
A type declaration, boolean or integer, asserts that the value of a variable or function or element of an array
will always be of the given type. Thus,
boolean (a, b, c)
asserts that any value assigned to entities having the names a, b, or c will be changed to a zero or a one
according to some rule, t, (e.g., t (x) = 1 when x = 1, otherwise t (x) = 0). Thus:
a: = x
in a program containing the above declaration would be equivalent to:
a: = t(x)
or again the appearance of a function b (x) in an expression in the program would be equivalent to t (b (x)).
Similarly, integer (r, s) constrains entities having names r or s to have integer values by rounding non-integer
values to the nearest integer.
2.52 array declarations
array declarations specify the upper and lower bounds for the subscripts which may be meaningfully associated
with an array. Thus:
array (a, b, c [1: 100], r, s [-10,1: + 10,50])
indicates that a, b, c are one-dimensional arrays whose subscripts have meaning only in the range 1 to 100
(inclusive), and that r, s are two-dimensional arrays whose first subscript should lie between -10 and + 10 and
the second between 1 and 50 (inclusive).
2.53 switch declarations
switch declarations have already been described under the heading, "go to statements" (2.43).
2.54 Function declarations
Certain functions may be defined for use within a program by a function declaration as follows:
g (x, y): = w + x + f (y, x)
If, in the program containing the above declaration, the following appears: g (t/v, h (v)), then its value is given
by the expression:
- 6 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
w + t/v + f (h (v), t/v)
Note, in this case, that g (x, y) is always a function of w even though it does not appear as an argument.
2.55 comment declarations
comment declarations do not affect the behavior of the program, they simply provide the ability to incorporate
verbal comments in a program. For example:
comment This is the end of Section 1.
The comment may be arbitrarily long provided it does not contain a statement separator, semicolon.
2.56 Procedure declarations
Procedure declarations are unique among declarations: precisely one procedure declaration must precede the
program it refers to. Such a declaration indicates that the IAL program following defines one or more procedure
statements and/or functions. For example:
procedure branch (a): (L1, L2, L3);
begin branch: if (a < 0); go to L1; if (a = 0);
go to L2; if (a > 0); go to L3 end
This comprises a procedure declaration followed by a program of one compound statement. The procedure
statement defined thereby is one named "branch" which selects one of three successors according as the value
of the input is negative, zero, or positive. Thus, the procedure statement,
branch (x - f (y)): (a [I], BB, MM)
used in any program means, by virtue of its defining program: go to the statement indicated by the switch
variable a [i] when x - f (y) is negative, if it is zero, go to BB, and if it is positive, go to MM. One more
example:
procedure root (a, b), ckroot (a, b) =: (c): (d);
begin ckroot: if (a - b < 0); go to d;
root: c: = sqrt (a - b); root: = c;
return end
The procedure declaration, together with the program, defines a function, root, and a procedure statement,
named "ckroot". The calculation of the function begins with the statement labelled root, and its value is that of
the variable, root, when return is encountered. The program for ckroot begins at the first statement, labelled
ckroot. The process corresponding to
ckroot (x, y/z) =: (a): (GL)
therefore, either gives the value sqrt (x - y/z) or, if x-y/z is negative, specifies the statement labelled GL as its
successor. On the other hand,
v: = r + root (m, n)
results in v having the value r + sqrt (m - n) regardless of the sign of m - n.
3. Formal description
3.1 General
The Zurich ACM-GAMM Conference had two principal motives in proposing the IAL:
- 7 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
a) To provide a means of communicating numerical methods and other procedures between people.
and,
b) To provide a means for realizing a stated process on a variety of machines with the only differences
between the realizations of a program on two machines being those imposed by differences in word
lengths, overflow conditions and the like.
It appears that IAL, as given by informal descriptions here and elsewhere [1], suffices rather well for goal (a).
However, if programs are to be written for a variety of machines to translate from IAL to the machine's
language in such a way that goal (b) is satisfied, two requirements must be met:
c) There must exist a precise description of those sequences of symbols which constitute legal IAL
programs. Otherwise, it will often be the case that a program which is legal and translatable for one
translating program will not be so with respect to another.
d) For every legal program there must be a precise description of its "meaning", the process or
transformation which it describes, if any. Otherwise, the machine language programs obtained by two
translating programs from a single IAL program may behave differently in one or more crucial
respects.
Heretofore there has existed no formal description of a machine-independent language (other than that
provided implicitly by a complete translating program) which has met either of the two requirements above.
Consequently, as anyone who has actually been involved in writing a translating program can testify, a large
number of decisions affecting membership in the-class of legal programs and the meaning of legal programs
must be made during the construction of the translating program. If, therefore, IAL is left in its present state
of incomplete and informal description, it is likely that many man-years may be invested in producing a number
of translating programs which will not reliably produce equivalent machine programs. In this case the great
potential benefits and savings offered by goal (b) will be lost. The author had hoped to complete a formal
description of the set of legal IAL programs and of their meanings in time to present it here. Only the
description of legal programs has been completed however. Therefore, the formal treatment of the semantics
of legal programs will be included in a subsequent paper. The work which has already been done in this
direction indicates a need for minor modifications in IAL to facilitate its completion. These changes will
require the approval of the appropriate groups. Since some of these changes are present in both chapters 2 and
3 of this paper, no official status for the descriptions contained in it should be assumed, although the changes
are few and, for the most part, slight.
3.2 Syntax of IAL
In the description of IAL syntax which follows we shall need some metalinguistic conventions for
characterizing various strings of symbols. To begin, we shall need metalinguistic formulae. Their interpretation
is best explained by an example:
Sequences of characters enclosed in "< >" represent metalinguistic variables whose values are strings of
symbols. The marks ": ==" and "or" are metalinguistic connectives. Any mark in a formula, which is not a
variable or a connective, denotes itself (or the class of marks which are similar to it). Juxtaposition of marks
and/or variables in a formula signifies juxtaposition of the strings denoted. Thus, the formula above gives a
recursive rule for the formation of values of the variable <ab>. It indicates that <ab> may have the value "("
or "[" or that given some legitimate value of <ab>, another may be formed by following it with the character
"(" or by following it with some value of the variable <d>. If the values of <d> are the decimal digits, some
values of <ab) are:
[(((1(37(
(12345(
(((
[86
- 8 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
3.31 Integers and numbers
3.32 Identifiers and variables
3.33 Subscripted, variables and arrays
3.34 Parameters, functions and pure functions
- 9 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
3.35 Arithmetic expressions, Boolean expressions, and expressions
3.41 Assignment statements
3.42 go to statements and designational expressions
3.43 if statements
3.44 for statements
3.45 converge statements
3.46 do statements
- 10 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
3.47 stop statements
3.48 Procedure statements and pure procedures
[a pure procedure may have any of the forms of a procedure statement but at least one position of one existing
list must be empty: at least one input parameter position or one output position or one successor position].
3.49 return statements
3.51 type declarations
3.52 array declarations
- 11 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
3.53 switch declarations
3.54 Function declarations
3.55 comment declarations
3.56 common declarations
3.57 Statements and declarations
3.6 Syntactic properties of IAL statement lists
a) L is the entry label of a statement S if S has the form:
L: <u stmt>
b) If d 2 is a designational expression in statement list S and there is a switch declaration:
switch X1: = (…, d2,…)
then d2 is said to succeed any designational expression of the expression of the form X1 [< exp>].
Further, if d3 succeeds d2 and d2 succeeds d1, then d3 succeeds d1.
3.7 Definition of an IAL program
An IAL program is a statement list (<sl>) with the following properties:
a) No two statements or sub statements have the same prefixed label.
b) No designational expression succeeds itself.
c) Every designational expression has some label as successor, or is itself a label.
d) To every n-place array name or subscripted variable name there corresponds one and only one entry
of that name in an n-place array segment (n = 1/2 number of entries in the upper-lower-bound list,
<ulbl>).
- 12 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
4. Acknowledgment
The proposed International Algebraic Language is the direct and indirect product of many people's work. Most
directly it is the result of the Zurich Conference at which the participants were: F. L. Bauer, H. Bottenbruch,
H. Rutishauser, and K. Samelson (representing the GAMM), and J. W. Backus, C. Katz, A. J. Perlis, and J. H.
Wegstein (representing the ACM). Extensive preparatory work was done by larger ACM and GAMM
committees [1]. All of this, in turn, was based on prior work done by many individuals and groups in the field
of automatic programming. The earliest work (to the author's knowledge) in this area was that of Rutishauser,
in Switzerland, and of Laning and Zierler, in the United States.
5. Reference
[l] PERLIS, A. J., and K. Samelson: Preliminary Report-International Algebraic Language. Communications
of the ACM, Vol. 1, No. 12, Dec. 1958.
- 13 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
2. Testo tradotto
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Traduzione de: The syntax and semantics of the proposed International Algebraic Language by
John W. Backus
Questo articolo fornisce un riassunto della sintassi e dell'interpretazione delle regole del linguaggio algebrico
internazionale proposto dalla Conferenza ACM-GAMM di Zurigo, seguita da una presentazione formale e
completa delle stesse informazioni. Diverse notazioni sono qui proposte per rappresentare numeri, variabili
numeriche, variabili booleane, relazioni, array n-dimensionali, funzioni, operatori ed espressioni algebriche. I
procedimenti sono forniti nel linguaggio per eseguire:
• l’assegnazione di valori a variabili,
• l’esecuzione condizionale di enunciati,
• le procedure iterative,
• la formazione di enunciati composti da sequenze di affermazioni,
• la definizione di nuove affermazioni per procedure arbitrarie,
• la modifica e il riutilizzo di segmenti di programma.
Il linguaggio proposto ha lo scopo di fornire uno strumento comodo e conciso per esprimere virtualmente tutte
le procedure di calcolo numerico impiegando un numero relativamente basso di regole sintattiche e tipi di
dichiarazione.
Sintesi
Nel maggio 1958 una conferenza a Zurigo completò il progetto congiunto dell'ACM (Association for
Computing Machinery) e la GAMM (Association for Applied Mathematics and Meccanica) approvando una
proposta di International Algebraic Language (IAL) o ALGOL. Saranno presentati qui altri materiali per
discutere sia la storia del progetto che i vari aspetti del linguaggio.
Lo scopo del presente documento, invece, è quello di descrivere con precisione sia la sintassi che la semantica
di IAL. La descrizione data qui sarà quella del cosiddetto "linguaggio di riferimento" che, per chiarezza,
impiega un insieme specifico di simboli e convenzioni di notazione.
Va tenuto presente, tuttavia, che il linguaggio formale di riferimento di IAL è nato principalmente con lo scopo
di descrivere le regole di costruzione del. linguaggio e dei suoi significati.
Nell'uso effettivo sono previste una varietà di simbolizzazioni e convenzioni di notazione, poiché ogni
rappresentazione è una traslitterazione abbastanza precisa del linguaggio di riferimento avendo in comune le
stesse regole di sintassi e semantica.
Le "rappresentazioni hardware" utilizzeranno generalmente un minor numero di simboli rispetto a quello
impiegato nel linguaggio di riferimento risultando così più consone per la traduzione meccanica in linguaggio
macchina per un determinato tipo di macchina.
Le "forme di pubblicazione" del linguaggio, d'altro canto, impiegheranno molte notazioni convenzionali della
matematica (ad es., esponenti, pedici, lettere greche) e saranno utilizzate nella comunicazione in scrittura
umana dei programmi IAL.
La descrizione del linguaggio di riferimento è divisa in due parti. Il capitolo 2 fornisce una breve descrizione
informale dei principali elementi della lingua in termini di esempio mentre il capitolo 3 fornisce una
descrizione formale della struttura del linguaggio.
- 16 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
2.1 Sintesi
2. Descrizione informale
Un programma IAL è una sequenza di istruzioni che possono essere intervallate da alcune
dichiarazioni. Ogni dichiarazione descrive una regola di calcolo e, esplicitamente o
implicitamente, specifica un'istruzione successore (il successore è l’istruzione successiva
nel programma se non diversamente indicato).
La regola di calcolo data da un programma è, ovviamente, la sequenza di calcoli specificata
dalle istruzioni quando prese nell'ordine previsto dai parenti successori.
Le dichiarazioni affermano alcuni fatti che devono valere in tutto il calcolo. La loro
posizione nel programma è generalmente irrilevante.
I paragrafi seguenti presentano alcuni degli aspetti importanti proprietà di espressioni e
proposizioni, con esempi
2.2 Espressioni
algebriche
a) Le espressioni algebriche sono composte da variabili, costanti, funzioni e operatori per
la consueta aritmetica operazioni.
b) Nomi di variabili, funzioni e altre entità sono composto da caratteri alfabetici e
numerici, il primo essendo alfabetico. Una sequenza di caratteri può essere di qualsiasi
lunghezza.
c) Resta inteso che nelle operazioni aritmetiche, l’espressione in virgola mobile indica
una rappresentazione approssimata dei numeri reali. Alcune variabili possono essere
dichiarate per essere di valore intero. L'effetto di tale dichiarazione è che qualsiasi
valore, che deve essere assegnato a tale variabile, è prima arrotondato all'intero più
vicino.
d) Le dichiarazioni di array (d. 2.5) possono indicare che alcuni nomi sono di array di
dati di varie dimensioni. Questi nomi possono apparire nelle espressioni come indici
di variabili seguite da una sequenza di pedici racchiusi tra parentesi quadre, dal numero
di pedice corrispondente alla dimensionalità della matrice mentre ogni pedice sarà
separato dal successivo da una virgola. Poiché le parentesi sono utilizzate per
racchiudere gli argomenti delle funzioni (e sotto espressioni), è facile distinguere tra
funzioni e variabili indicizzate. Un pedice può essere un’espressione qualsiasi; il
valore del pedice è il numero intero formato dall'arrotondamento del valore
dell'espressione (se non è già da un numero intero).
Esempi di
espressioni
algebriche
1) significa
2) significa
3) significa
4) significa
In particolare, se i e j hanno entrambi valore 1 (o 1,2) quando l'espressione di cui sopra
è incrociata, allora è equivalente a: R2, 1 × S1, 2
Esempi di
espressioni
booleane
È possibile dichiarare alcune variabili, o valori di matrici, con valore booleano
(ovvero, con il solo valore 0, "FALSO", o 1, "VERO"). Queste variabili, le costanti 0
e 1, le funzioni con valori booleani e le sotto espressioni della forma:
(E rE')
possono essere combinate con gli operatori booleani "and", "or", "not" e
"equivalent" per formare un'espressione booleana.
(In quanto sopra, E ed E' sono espressioni algebriche ed r è una relazione come, ad
esempio, (x/y> 1).)
- 17 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Esempi di
espressioni
booleane
1)
Questa espressione booleana è vera se, e solo se, X è maggiore di Y o Y è maggiore di
Z2 o entrambi. L'operatore è quello "or".
2)
Qui A e B sono due variabili con valori booleani. L'espressione è vera quando A è
falsa e B è vera o quando A è vera e X è uguale a Y + 1.
2.4 Dichiarazioni
Esempi di
dichiarazioni
composte
2.41
a) Gli enunciati possono essere di base o composti (formati da una sequenza di
enunciati racchiusi tra parentesi di enunciato, inizio e fine). Le istruzioni sono
separate una dall'altra dal separatore ";".
begin a [i]: = b [i] + c [i]; x: = a [i] end
In generale, se S1, S2, ... Sn sono dichiarazioni allora:
begin S1; S2; ; ; Sn end
è una dichiarazione.
b) Una dichiarazione può essere etichettata, come segue:
L:S
dove L è un nome o un numero intero; L diventa così l'etichetta
della dichiarazione S.
Esempi di
istruzioni di
assegnazione
2.42 Dichiarazioni di assegnazione
Le istruzioni di assegnazione indicano che un'espressione deve essere valutata e
assegnata come valore di una variabile.
a) x: = a + b
significa: assegnare il valore di a + b come valore di x.
b) alfa: = 4.63
c) r [i, j]: = s [i] + t [j]
d) B: = (x > 0) ˄ A
dove A e B sono variabili booleane e B riceve il valore di VERO
dell'espressione booleana a destra.
2.43 Dichiarazione go to
a) Un'istruzione go to può specificare un'istruzione, diversa dall'istruzione che
la segue, come sua succeditrice nel processo di calcolo descritto dal
programma. Questo può essere fatto esplicitamente scrivendo l'etichetta del
successore desiderato come segue:
go to A
dove A è l'etichetta di qualche istruzione nel programma. Il successore
dell'istruzione go to può essere creato, oppure già dipende dal valore di
qualche altra espressione mediante l'uso di una VARIABILE SWITCH, il cui
pedice è l'espressione desiderata. Il valore di una VARIABILE switch è
un'etichetta. Quindi se "branch" è il nome di una VARIABILE SWITCH, si
avrà:
- 18 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Esempio dell'uso
delle istruzioni if
Esempio dell'uso
delle clausole for
go to branch [i + j]
che ha come successore quella dichiarazione la cui etichetta è il valore
del ramo [i + j].
b) Le VARIABILI SWITCH sono definite dalle DICHIARAZIONI SWITCH (Cfr.:
2.53). Pertanto la VARIABILE SWITCH "branch" potrebbe essere definita
dalla seguente dichiarazione:
switch branch (AI, A2, B1, B2)
dove A1, A2, B1, B2 sono etichette di dichiarazioni. Il valore del ramo [i +
J] è quindi la (i + j) esima etichetta nella sequenza (o l'n-esima etichetta,
dove n è l'intero formato dall'arrotondamento: i + j).
Ad esempio, se i + j è uguale a 3, il valore del ramo [i + j] è B1 e, in tal caso,
"go to branch [i + j]" ha lo stesso significato di "go to B1".
c) Le VARIABILI SWITCH possono essere utilizzate nella definizione di altre
VARIABILI SWITCH. Così le seguenti due dichiarazioni SWITCH potrebbero
apparire in un programma:
switch branch (AI, A2, Bl, B2)
switch fork (branch [i], AI, Bl).
In questo caso se i è uguale a 4 e j è uguale a 1, il valore di fork [j] è B2.
d) Una VARIABILE SWITCH, in alcuni casi, potrebbe non avere alcun valore. Ad
esempio, il ramo [i] come definito sopra non ha valore se l'intero più vicino
a i è minore di 1 o maggiore di 4. In tal caso il successore di "go to branch
[i]" è l'istruzione successiva nel programma.
2.44 clausole if e istruzioni if
La clausola if, "if B", dove B è un'espressione booleana, si combina con
l'istruzione S che la segue per formare un'istruzione composta. Questa
affermazione composta ha lo stesso effetto di S se B è vera e ha l'effetto di
"nessuna operazione" se B è falsa.
if (a > 0); x: = 1; if (a = 0); begin x: = y; p: = 0 end;
if (a < 0); go to B; S
2.45 clausole for e dichiarazioni for
a) Una clausola for, come una clausola if, si combina con l'istruzione S, che la
segue per formare un'istruzione composta. Un'istruzione for specifica che
una data variabile assume una successione di valori e che l'istruzione
governata, S, deve essere eseguita una volta per ogni valore della variabile.
Così, ad esempio:
for x: = 1, r + s, k, 6.3, -10; a: = (a + x) /x
fa sì che la dichiarazione governata venga ripetuta cinque volte, una volta
per ciascuno dei valori elencati di x. Dalla dichiarazione composta
governata da una clausola for può essere coinvolta un’istruzione che può
includere altre istruzioni for, così procedure ricorsive complesse possono
essere facilmente specificate dal loro impiego.
b) Le sequenze di valori possono anche essere date come progressioni
aritmetiche:
questa clausola indica che i dovrebbe assumere i valori:
a2
, a2
+ b/2, a2
+ b, …, a2
+ nb/2, … finché y + 1 non viene raggiunto, ma non
- 19 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Esempio di
dichiarazioni
convergenti
superato. Molte di queste progressioni possono essere incluse in una sola
clausola for; per esempio:
for r: = 1(3)10, 12(4)20, 21(-7)1
fornisce la sequenza di valori r: 1, 4, 7, 10, 12, 16, 20, 21, 14, 7.
2.46 Dichiarazioni convergenti
a) Un'istruzione di convergenza che precede un'istruzione composta S fa sì che
quelle sottodichiarazioni comprendenti S, che non specificano
esplicitamente un successore, abbiano l'affermazione che segue S come
successore comune. Tuttavia, nel caso di una dichiarazione if è solo il
successore della dichiarazione governata ad essere alterato. Il successore di
un'istruzione if con un’espressione booleana falsa è l'istruzione successiva.
Cosi, ad esempio:
converge; begin if B1; S1; if B2; S2; if B3; S3 end; S4
fa eseguire quell'unica istruzione Si che corrisponde alla prima espressione
booleana vera Bi; questo Si è poi seguito da S4. Quindi se B1, B2 e B3 sono
tutti veri, l'effetto è eseguire S1 e poi S4.
b) Un'istruzione converge può anche essere usata convenientemente
selezionando una singola istruzione per l'esecuzione così come segue:
converge; begin go to branch [i]; L1; S1; L2: S2; L3: S3 end; S4
Se "branch [i]" assume i valori L1, L2, L3 per i = 1,2,3, allora la dichiarazione
che segue converge ha l'effetto dell'unica dichiarazione Si seguita da S4.
2.47 Istruzione do
a) Un'istruzione do è semplicemente un modo abbreviato per riscrivere il
segmento di un programma che appare altrove. Avremo così:
do A; x: = y + z; A: r: = x + r
che è un modo alternativo di scrivere quanto segue:
B: r: = x + r; x: = y + z; A: r: =x + r
dove all'enunciato copiato è stata assegnata una nuova etichetta, B,
semplicemente per evitare di avere due enunciati con la stessa etichetta. La
scelta di nuove etichette nella copia è irrilevante fintanto che la
riassegnazione viene eseguita in modo coerente in tutta la copia.
b) Un'istruzione do può specificare una sequenza di istruzioni da essere copiate
dando due, o più, etichette.
do R, S
che rappresenta, quindi, la sequenza di istruzioni da quella etichettata R a
quella etichettata S.
c) Una istruzione do può richiedere che vengano apportate determinate
modifiche alla copia che essa rappresenta:
do R, S (x + y → x, a [i] → beta)
che si deve interpretare: per il segmento da R a S, ma con il nome "x",
sostituito da "x + y" ovunque appaia e con "beta" sostituito da "a [i]".
2.48 Istruzione stop
Le istruzioni stop non hanno successori, quindi rappresentano il termine
operativo del processo descritto da un programma.
- 20 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
2.49 Istruzione return
Un'istruzione return, scritta "return", è usata solo nei programmi che
definiscono il significato delle istruzioni di procedura. Ciò significa che la
procedura definita è stata completata e che il successore dell'istruzione di
procedura, che ha invocato il programma di definizione, è l'istruzione
successiva nel programma invocante.
2.410 Dichiarazioni procedurali
L'istruzione procedurale indica che un particolare processo deve essere
eseguito impiegando quelle entità indicate dai parametri di input e
producendo risultati che sono designati dai parametri di output. (Alcune
istruzioni procedurali possono anche indicare specifiche istruzioni
successive mediante un elenco di etichette o variabili di commutazione
associate a varie condizioni di uscita). Avremo così, ad esempio:
integrate (F(r), a, b, e) =: (int): (L)
che potrebbe indicare F (r, x) dx, che deve essere trovato con un errore
minore di e (se possibile con la procedura data), che il risultato deve essere
assegnato come valore di "int" e che, se non si ottiene il risultato desiderato,
il successore di quest’istruzione dovrebbe essere quello etichettato con L.
Alcune istruzioni procedurali possono essere aggiunte semplicemente a IAL
come primitive (e realizzate da subroutine in linguaggio macchina). Altre
possono fare riferimento, con il nome che le precede (ad esempio,
"integrate"), a un programma IAL (cfr.: dichiarazioni procedurali d 2.56)
che rappresenta il processo indicato. Alcune istruzioni procedurali
potrebbero non avere parametri di input, altre potrebbero non avere
parametri di output. Quindi, un'istruzione procedurale, che produce, ad
esempio, l'ottenimento di un numero da un supporto esterno, potrebbe
essere:
in = :(a)
indicando che il numero deve essere assegnato come valore di a. Un altro
potrebbe essere:
print (r, s, t).
Un'altra dichiarazione procedurale può specificare la sostituzione di una
matrice, A, dalla sua inversa:
invert (A [,] =: (A [,])
In generale, si intende che praticamente qualsiasi processo può essere
espresso da una dichiarazione procedurale.
2.5 Dichiarazioni
Le dichiarazioni in un programma IAL affermano determinati fatti che
devono essere ottenuti durante tutto il programma. Possono apparire in
qualsiasi punto del programma, ma la loro posizione non è significativa.
2.51 Dichiarazioni di tipo
Una dichiarazione di tipo, booleana o intera, afferma che il valore di una
variabile o funzione o elemento di un array sarà sempre del tipo specificato.
Avremo così:
boolean (a, b, c)
asserisce che qualsiasi valore assegnato a entità con i nomi a, b o c sarà
cambiato in uno 0 o 1 secondo qualche regola, t, (ad esempio, t (x) = 1
- 21 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
quando x = 1, altrimenti t (x) = 0). Avremo così:
a: = x
o ancora la comparsa di una funzione b (x) in un'espressione nel programma
sarebbe equivalente a t (b (x)). Allo stesso modo avremo:
integer (r, s)
vincola le entità con nomi r o s ad avere valori interi arrotondando i valori
non interi all'intero più vicino.
2.52 dichiarazioni di array
le dichiarazioni di array specificano i limiti, superiore e inferiore, per i
pedici a cui possono essere associati, in modo significativo, gli array.
Avremo così:
array (a, b, c [1: 100], r, s [-10,1: + 10,50])
indica che a, b, c sono array unidimensionali i cui pedici hanno significato
solo nell'intervallo da 1 a 100 (inclusi), e che r, s sono array bidimensionali
i cui il primo pedice dovrebbe essere compreso tra -10 e + 10 e il secondo
tra 1 e 50 (inclusi).
2.53 dichiarazioni di commutazione
Le DICHIARAZIONI SWITCH sono già state descritte sotto il titolo "Istruzioni
go to" (Cfr.: 2.43).
2.54 Dichiarazioni di funzioni
Alcune funzioni possono essere definite per l'uso all'interno di un
programma mediante una dichiarazione di funzione così come segue:
g (x, y): = w + x + f (y, x)
Se nel programma, contenente la suddetta dichiarazione, compare: g (t/v, h
(v)), allora il suo valore è dato dall'espressione:
w + t/v + f (h (v), t/v)
Si noti, in questo caso, che g (x, y) è sempre una funzione di w anche se non
appare come argomento.
2.55 Commenti
I commenti non influiscono sul comportamento del programma, forniscono
semplicemente la possibilità di incorporare commenti verbali in un
programma. Per esempio:
comment This is the end of Section 1.
Il commento può essere arbitrariamente lungo a condizione che non
contenga un separatore di istruzioni, punto e virgola.
2.56 Dichiarazioni procedurali
Le dichiarazioni procedurali sono uniche tra le dichiarazioni: una sola
dichiarazione procedurale deve precedere il programma a cui si riferisce.
Tale dichiarazione indica che il programma IAL che segue definisce una o
più istruzioni e/o funzioni procedurali. Per esempio:
procedure branch (a): (L1, L2, L3);
begin branch: if (a < 0); go to L1; if (a = 0); go to L2; if (a > 0); go to
L3 end
- 22 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
comprende una dichiarazione procedurale seguita da un programma di una
dichiarazione composta. L'istruzione della procedura così definita è quella
denominata "branch" che seleziona uno dei tre successori a seconda che il
valore dell'input sia negativo, zero o positivo. Così, dunque, sarà la
dichiarazione procedurale:
branch (x - f (y)): (a [i], BB, MM)
usato in qualsiasi programma significa, in virtù del suo programma che lo
definisce: vai all'istruzione indicata dalla VARIABILE SWITCH a [i] quando x
- f (y) è negativo, se è zero, vai a BB, e se è positivo, vai a MM. Un altro
esempio:
procedure root (a, b), ckroot (a, b) =: (c): (d); begin ckroot: if (a - b
< 0); go to d; root: c: = sqrt (a - b); root: = c; return end
La dichiarazione procedurale, insieme al programma, definisce una
funzione, una radice e un'istruzione procedurale, denominata "ckroot". Il
calcolo della funzione inizia con l'istruzione etichettata root, e il suo valore
è quello della variabile root, quando si incontra return. Il programma per
ckroot inizia dalla prima istruzione, denominata ckroot. Il processo
corrispondente a:
ckroot (x, y/z) =: (a): (GL)
quindi o fornisce a del valore sqrt (x - y/z) oppure, se x-y/z è negativo,
specifica l'istruzione etichettata GL come suo successore. D'altro canto
v: = r + root (m, n)
3 Descrizione formale
3.1 Generale
La Conferenza ACM-GAMM di Zurigo ha avuto due motivazioni principali
nel proporre IAL:
a) Fornire un mezzo per comunicare metodi numerici, e altre procedure, tra
le persone.
e,
b) Fornire un mezzo per realizzare un determinato processo su di una
molteplicità di macchine, con le uniche differenze tra le esecuzioni di un
programma su due macchine diverse essendo queste imposte dalle
differenze di lunghezza delle parole, condizioni di overflow e simili.
Sembra che IAL, come indicato da descrizioni informali qui e altrove [1], sia
sufficiente per raggiungere l'obiettivo (a).
Tuttavia, se i programmi devono essere scritti per una varietà di macchine
per tradurre da IAL al linguaggio della macchina ospite, in modo tale da
soddisfare l'obiettivo (b), devono essere adempiuti due requisiti:
c) Deve esistere una descrizione precisa di quelle sequenze di simboli che
costituiscono i programmi IAL validi. Diversamente accadrà spesso che
un programma che è corretto e traducibile per un programma traduttore
non lo sarà rispetto ad un altro.
d) Per ogni programma valido deve esserci una precisa descrizione del suo
"significato", che illustri il suo eventuale processo o trasformazione. In
caso contrario, i programmi in linguaggio macchina ottenuti da due
programmi di traduzione da un singolo programma IAL potrebbero
comportarsi diversamente in uno o più aspetti cruciali.
- 23 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Finora non è esistita alcuna descrizione formale di un linguaggio
indipendente dalla macchina (diversa da quella fornita implicitamente da un
programma di traduzione completo) che soddisfacesse uno dei due requisiti
di cui sopra.
Di conseguenza, come può testimoniare chiunque sia stato effettivamente
coinvolto nella stesura di un programma di traduzione, un gran numero di
decisioni che riguardano l'appartenenza alla classe dei programmi legittimi e
il significato dei programmi legittimi devono essere prese durante la
costruzione del programma di traduzione.
Se, quindi, IAL viene lasciato così com’è nel suo stato attuale di
incompletezza e di sola descrizione informale, è probabile che trascorreranno
molti anni nella produzione di una serie di programmi di traduzione che
comunque non produrranno in modo affidabile programmi macchina
equivalenti. In questo caso andranno perduti i grandi potenziali in termini di
benefici e risparmi offerti dall'obiettivo (b).
L'autore sperava di completare una descrizione formale dell'insieme dei
programmi legittimi IAL, e dei loro significati, in tempo utile per poterla
presentare qui. Tuttavia, è stata completata solo la descrizione dei programmi
legittimi.
Pertanto la trattazione formale della semantica dei programmi ufficiali sarà
inclusa in un successivo lavoro. Il lavoro che è già stato fatto in questa
direzione indica la necessità di apportare ulteriori modifiche minori in IAL
per facilitarne il completamento. Queste modifiche richiederanno
l'approvazione degli appositi gruppi. Poiché alcuni di questi cambiamenti
sono presenti in entrambi i capitoli 2 e 3 di questo documento, non si
dovrebbe assumere uno status ufficiale per le descrizioni in esso contenute,
sebbene i cambiamenti siano pochi e, per la maggior parte, lievi.
3.2 Sintassi di IAL
Nella descrizione della sintassi IAL che segue avremo bisogno di alcune
convenzioni metalinguistiche per caratterizzare varie stringhe di simboli. Per
cominciare, avremo bisogno di formule metalinguistiche. La loro
interpretazione è meglio spiegata da un esempio:
Le sequenze di caratteri racchiuse tra "< >" rappresentano variabili
metalinguistiche i cui valori sono stringhe di simboli.
I segni ": ≡" e "or" sono connettivi metalinguistici.
Qualsiasi segno in una formula, che non è una variabile o un connettivo,
denota sé stesso (o la classe di segni che sono simili ad esso).
Giustapposizione di segni e/o variabili in una formula significa
giustapposizione delle stringhe denotate. Così la formula di cui sopra fornisce
una regola ricorsiva per la formazione di valori della variabile <ab>. Indica
che <ab> può avere il valore "(" o "[" o quello dato da alcuni valori legittimi
di <ab>, se ne può formare un altro, facendolo seguire dal carattere" “(" o
facendolo seguire da qualche valore della variabile <d>. Se i valori di <d>
sono le cifre decimali, alcuni valori di <ab> sono:
[(((1(37(
(12345(
(((
[86
- 24 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
3.31 Interi e numeri
3.32 Identificatori e variabili
3.33 Sottotitoli, variabili e array
3.34 Parametri, funzioni e funzioni pure
3.35 Espressioni aritmetiche, espressioni booleane ed espressioni
- 25 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
3.41 Dichiarazioni di assegnazione
3.42 dichiarazioni go to ed espressioni designative
3.43 istruzioni if
3.44 Istruzioni for
3.45 Istruzioni converge
3.46 Istruzioni do
3.47 Istruzione stop
- 26 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
3.48 Enunciati procedurali e procedure pure
[una procedura pura può avere una qualsiasi delle forme di una dichiarazione
procedurale, ma almeno una posizione di un elenco esistente deve essere vuota:
almeno una posizione di parametro di input o una posizione di output o una
posizione di successore].
3.49 istruzioni return
3.50 Dichiarazioni di tipi (N.d.R.: 3.51 sul documento originale)
3.51 Dichiarazioni di array (N.d.R.: 3.52 sul documento originale)
3.52 Dichiarazioni switch (N.d.R.: 3.53 sul documento originale)
3.53 Dichiarazioni di funzioni (N.d.R.: 3.54 sul documento originale)
3.54 Dichiarazione di commenti (N.d.R.: 3.55 sul documento originale)
- 27 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
3.55 Dichiarazione comuni (N.d.R.: 3.56 sul documento originale)
3.56 Statements e declarations (N.d.R.: 3.57 sul documento originale)
3.6 Proprietà sintattiche degli elenchi di istruzioni IAL
a) L è l'etichetta iniziale di una proposizione S se S ha la forma:
b) Se d2 è un'espressione di designazione nell'elenco di istruzioni S ed è
presente una DICHIARAZIONE SWITCH:
switch x1: = (..., d2,...)
che si leggerà d2 succede a qualsiasi designazione dell'espressione della
forma x1 [< exp>]. Inoltre, se d3 succede a d2 e d2 succede a d1, allora d3
succede a dl.
3.7 Definizione di un programma IAL
Un programma IAL è un elenco di istruzioni <sl>) con le seguenti
proprietà:
a) Non esistono due affermazioni o sottoasserzioni uguali all’etichetta
prefissata.
b) Nessuna espressione designativa succede a sé stessa.
c) Ogni espressione designazionale ha una qualche etichetta come
successore, o è essa stessa un'etichetta.
d) Ad ogni nome di matrice di n posizioni o variabile con indice nome vi
corrisponde una ed una sola voce di quel nome in un segmento di array
di n posizioni (n = 1/2 numero di voci nell'elenco upper-lower-bound,
<ulbl>).
- 28 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
4. Riconoscimenti
Il linguaggio algebrico internazionale proposto è il prodotto diretto e
indiretto del lavoro di molte persone. Più direttamente è il risultato della
Conferenza di Zurigo in cui i partecipanti erano: F. L. Bauer, H.
Bottenbruch, H. Rutishauser e K. Samelson (in rappresentanza del GAMM),
e JW Backus, C. Katz, AJ Perlis e JH Wegstein (che rappresentano l'ACM).
È stato svolto un ampio lavoro preparatorio dai comitati ACM e GAMM
[1]. Tutto questo, a sua volta, era basato sul lavoro precedente svolto da
molti individui e gruppi impegnati nel settore della programmazione
automatica. Il primo lavoro (a conoscenza dell'autore) in quest’area era
quello di Rutishauser, in Svizzera, e di Laning e Zierler, negli Stati Uniti.
5 Note
[l] A. J. Perlis, K. Samelson: Preliminary Report-International Algebraic
Language. Communications of the ACM, Vol. 1, No. 12, Dec. 1958.
Traduzione eseguita con Google Traduttore, adattamento di Salvatore Giglio
- 29 -
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus

Weitere ähnliche Inhalte

Mehr von CADZINE

CADZINE n° 3, giugno luglio e agosto 2016, ANNO III
CADZINE n° 3, giugno luglio e agosto 2016, ANNO IIICADZINE n° 3, giugno luglio e agosto 2016, ANNO III
CADZINE n° 3, giugno luglio e agosto 2016, ANNO III
CADZINE
 
CADZINE n° 2, maggio 2016, ANNO III
CADZINE n° 2, maggio 2016, ANNO IIICADZINE n° 2, maggio 2016, ANNO III
CADZINE n° 2, maggio 2016, ANNO III
CADZINE
 
CADZINE n° 1, marzo 2016, ANNO III
CADZINE n° 1, marzo 2016, ANNO IIICADZINE n° 1, marzo 2016, ANNO III
CADZINE n° 1, marzo 2016, ANNO III
CADZINE
 
CADZINE n° 7, dicembre 2014, ANNO I
CADZINE n° 7, dicembre 2014, ANNO ICADZINE n° 7, dicembre 2014, ANNO I
CADZINE n° 7, dicembre 2014, ANNO I
CADZINE
 

Mehr von CADZINE (20)

Il passato intrecciato - Origine dei toponimi Finlandia e Suomi
Il passato intrecciato - Origine dei toponimi Finlandia e SuomiIl passato intrecciato - Origine dei toponimi Finlandia e Suomi
Il passato intrecciato - Origine dei toponimi Finlandia e Suomi
 
UNCOL traduzione.pdf
UNCOL traduzione.pdfUNCOL traduzione.pdf
UNCOL traduzione.pdf
 
Traduzione lettera Knuth a CACM.pdf
Traduzione lettera Knuth a CACM.pdfTraduzione lettera Knuth a CACM.pdf
Traduzione lettera Knuth a CACM.pdf
 
Origini della BNF.pdf
Origini della BNF.pdfOrigini della BNF.pdf
Origini della BNF.pdf
 
CADZINE n° 3, giugno luglio e agosto 2016, ANNO III
CADZINE n° 3, giugno luglio e agosto 2016, ANNO IIICADZINE n° 3, giugno luglio e agosto 2016, ANNO III
CADZINE n° 3, giugno luglio e agosto 2016, ANNO III
 
CADZINE n° 2, maggio 2016, ANNO III
CADZINE n° 2, maggio 2016, ANNO IIICADZINE n° 2, maggio 2016, ANNO III
CADZINE n° 2, maggio 2016, ANNO III
 
Chi è Bruno Munari? inserto speciale allegato a CADZINE n° 1 marzo 2016 ANNO III
Chi è Bruno Munari? inserto speciale allegato a CADZINE n° 1 marzo 2016 ANNO IIIChi è Bruno Munari? inserto speciale allegato a CADZINE n° 1 marzo 2016 ANNO III
Chi è Bruno Munari? inserto speciale allegato a CADZINE n° 1 marzo 2016 ANNO III
 
CADZINE n° 1, marzo 2016, ANNO III
CADZINE n° 1, marzo 2016, ANNO IIICADZINE n° 1, marzo 2016, ANNO III
CADZINE n° 1, marzo 2016, ANNO III
 
Sommari delle pubblicazioni del 2015
Sommari delle pubblicazioni del 2015Sommari delle pubblicazioni del 2015
Sommari delle pubblicazioni del 2015
 
Principi di funzionamento delle stampanti 3D, ottobre 2015
Principi di funzionamento delle stampanti 3D, ottobre 2015Principi di funzionamento delle stampanti 3D, ottobre 2015
Principi di funzionamento delle stampanti 3D, ottobre 2015
 
CADZINE n° 7, luglio 2015, ANNO III
CADZINE n° 7, luglio 2015, ANNO IIICADZINE n° 7, luglio 2015, ANNO III
CADZINE n° 7, luglio 2015, ANNO III
 
CADZINE n° 5, maggio 2015, ANNO II
CADZINE n° 5, maggio 2015, ANNO IICADZINE n° 5, maggio 2015, ANNO II
CADZINE n° 5, maggio 2015, ANNO II
 
CADZINE n° 6, giugno 2015, ANNO II
CADZINE n° 6, giugno 2015, ANNO IICADZINE n° 6, giugno 2015, ANNO II
CADZINE n° 6, giugno 2015, ANNO II
 
CADZINE n° 4, aprile 2015, ANNO II
CADZINE n° 4, aprile 2015, ANNO IICADZINE n° 4, aprile 2015, ANNO II
CADZINE n° 4, aprile 2015, ANNO II
 
CADZINE n° 3, marzo 2015, ANNO II
CADZINE n° 3, marzo 2015, ANNO IICADZINE n° 3, marzo 2015, ANNO II
CADZINE n° 3, marzo 2015, ANNO II
 
CADZINE n° 2, febbraio 2015, ANNO II
CADZINE n° 2, febbraio 2015, ANNO IICADZINE n° 2, febbraio 2015, ANNO II
CADZINE n° 2, febbraio 2015, ANNO II
 
CADZINE n° 1, gennaio 2015, ANNO II
CADZINE n° 1, gennaio 2015, ANNO IICADZINE n° 1, gennaio 2015, ANNO II
CADZINE n° 1, gennaio 2015, ANNO II
 
Raccolta sommari delle pubblicazioni 2014 anno i
Raccolta sommari delle pubblicazioni 2014   anno iRaccolta sommari delle pubblicazioni 2014   anno i
Raccolta sommari delle pubblicazioni 2014 anno i
 
CADZINE n° 7, dicembre 2014, ANNO I
CADZINE n° 7, dicembre 2014, ANNO ICADZINE n° 7, dicembre 2014, ANNO I
CADZINE n° 7, dicembre 2014, ANNO I
 
Il bromografo inserto speciale allegato al numero di novembre 2014 di cadzine
Il bromografo inserto speciale allegato al numero di novembre 2014 di cadzineIl bromografo inserto speciale allegato al numero di novembre 2014 di cadzine
Il bromografo inserto speciale allegato al numero di novembre 2014 di cadzine
 

Traduzione documento Backus ICIP 1959.pdf

  • 1. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus Traduzione de “The syntax and semantics of the proposed International Algebraic Language of the Zurich ACM-GAMM Conference” di John W. Backus, International Business Machines Corp., New York (USA) 15 - 20 giugno 1959 Traduzione effettuata da Google Traduttore Adattamento di Salvatore Giglio
  • 2. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
  • 3. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus Introduzione Ho deciso di tradurre in italiano e pubblicare liberamente questo documento attraverso cui John W. Backus presentò ufficialmente la sua notazione BNF alla prima ICIP, International Conference Information Processing, che si tenne a Parigi dal 15 al 20 giugno del 1959 ora considerata anche come il primo congresso dell’IFIP. Non essendo un madrelingua inglese mi sono avvalso di Google Traduttore ed ho poi dato una forma più comprensibile a certe frasi tradotte stranamente. Questo lavoro l’ho svolto per agevolare coloro che spinti da necessità di studio o, come me, da curiosità autodidattica e passione per l’informatica, si sono imbattuti nella Backus Naur Form e desiderano capire come sia nata. L’innovativa notazione ideata da Backus serviva per armonizzare e presentare gli sviluppi progressivi del nuovo linguaggio di programmazione ALGOL che venivano promulgati a mezzo stampa attraverso l’Algol Bulletin, redatto nelle fasi iniziali da Peter Naur quando lavorava alla Regnecentralen (la prima azienda di computer danese), e sul magazine dell’Association Computing Machinery, o ACM, Comunications of ACM. Una lettura a dir poco interessante che ci restituisce l’atmosfera di quei tempi lontani in cui, nonostante i disastrosi esiti della II guerra mondiale e il clima della guerra fredda, gli scienziati di due continenti uniscono le forze per realizzare uno straordinario esperimento di informatica. Attenzione! 1. Per non alterare i simboli impiegati originariamente da John Backus nel suo documento, ho ritenuto opportuno effettuare una serie di catture video lì dove comparivano segni grafici non presenti nel set di font Times New Roman con cui è stato redatto questo testo. Va da sé che il lettore/studioso/appassionato più zelante potrà riprodurre, se necessario, sicuramente con font vettoriali come il Cambria Math ciò che io mi sono limitato a copiare. 2. Il lettore noterà che la numerazione associata alla descrizione dei vari passi della notazione risulta alquanto discontinua; a tal proposito mi preme precisare che mi sono limitato a copiare verbatim il testo originale così come riportato nel documento di cui al seguente link: The syntax and semantics of the proposed international algebraic language of the Zurich ACM- GAMM Conference (softwarepreservation.org), limitandomi a disporre lo scritto su di una sola colonna anziché su due. Per la traduzione ho utilizzato una struttura tabellare che mi ha consentito di spostare, nella colonna di sinistra, i capoversi delle descrizioni in modo tale da agevolare la consultazione del documento tradotto. S. G.
  • 4. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
  • 5. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 1. Testo in lingua originale
  • 6. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
  • 7. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus The syntax and semantics of the proposed international algebraic language of the Zurich ACM- GAMM Conference By John W. Backus, International Business Machines Corp., New York (USA) This paper gives a summary of the syntax and interpretation rules of the proposed international algebraic language put forward by the Zurich ACM-GAMM Conference, followed by a formal, complete presentation of the same information. Notations are presented for numbers, numerical variables, Boolean variables, relations, n-dimensional arrays, functions, operators and algebraic expressions. Means are provided in the language for the assignment of values to variables, conditional execution of statements, iterative procedures, formation of compound statements from sequences of statements, definition of new statements for arbitrary procedures, and the re-use and alteration of program segments. The proposed language is intended to provide convenient and concise means for expressing virtually all procedures of numerical computation while employing relatively few syntactical rules and types of statement. 1. 1. General In May 1958 a conference in Zurich completed a joint project of the ACM (Association for Computing Machinery) and the GAMM (Association for Applied Mathematics and Mechanics) by approving a proposed International Algebraic Language (IAL) or ALGOL. Other papers to be presented here discuss the history of the project and various aspects of the language. It is the purpose of the present paper to describe precisely both the syntax and semantics of IAL. The description given here will be that of the so-called "reference language" which, for definiteness, employs a specific set of symbols and notational conventions. It should be kept in mind, however, that the reference language form of IAL exists primarily for the purpose of describing the rules of construction of the. language and its meanings. In actual use, a variety of symbolizations and notational conventions are envisaged, each representation being a fairly direct transliteration of the reference language and having the same rules of syntax and semantics. "Hardware representations" will generally use a smaller set of symbols than that employed in the reference language and will be suitable for mechanical translation into machine programs by a given type of machine. On the other hand, the "publication forms" of the language will employ many of the notational conventions of mathematics (e.g., exponents, subscripts, Greek letters) and will be used in human communication of IAL programs. The description of the reference language is given in two parts. Chapter 2 gives a brief informal description of the major elements of the language in terms of examples. Chapter 3 gives a formal description of the structure of the language. 2. Informal description 2.1 General An IAL program is a sequence of statements which may be interspersed with certain declarations. Each statement describes a rule of computation and, explicitly or implicitly, specifies a successor-statement (the successor being the next statement in the program unless otherwise stated). The computing rule given by a program is, of course, the sequence of computations specified by the statements when taken in the order provided by successor-relations. Declarations state certain facts which are to obtain throughout the computation. Their location in the program is generally unimportant. The" following paragraphs present some of the important properties of expressions and statements, with examples. 2.2 Algebraic expressions a) Algebraic expressions are composed of variables, constants, functions, and operators for the usual arithmetic operations. b) Names of variables, functions and other entities are composed of alphabetic and numeric characters, the first being alphabetic. A sequence of characters may be of any length. c) It is understood that the arithmetic operations in an expression signify a floating-point approximation of real number arithmetic. Some variables may be declared to be integer-valued. The effect of such a declaration is that any value which is to be assigned to such a variable is first rounded to the nearest integer. d) d) Array declarations (d. 2.5) may state that certain names are the names of arrays of data of various dimensions. These names may appear in expressions as subscripted variables which are followed by a - 1 -
  • 8. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus sequence of subscripts enclosed in a pair of square brackets, the number of subscripts corresponding to the dimensionality of the array and each subscript separated from the next by a comma. Since parentheses are used to enclose function arguments (and subexpressions), it is easy to distinguish between functions and subscripted variables. A subscript may be any expression; the value of the subscript is the integer formed by rounding the value of the expression (if it is not already an integer). Examples of algebraic expressions: In particular, if i and j both have the value 1 (or 1,2) when the above expression is encountered, it is then equivalent to: R2, 1 × S1, 2· 2.3 Boolean expressions Some variables or arrays of quantities may be declared to be Boolean-valued (i.e., having only the value 0, "false", or 1, "true"). These variables, the constants 0 and 1, Boolean-valued functions, and subexpressions of the form: (ErE') may be combined with the Boolean operators "and", "or", "not", and "equivalent" to form a Boolean expression. (In the above E and E' are algebraic expressions and r is a relation, e.g., (x/y> 1).) Examples of Boolean expressions: This Boolean expression is true if, and only if, either X is greater than Y or Y is greater than Z2 or both. The operator is that for "or". Here A and B must be Boolean-valued variables. The expression is true when either A is false and B is true or when A is true and X equals Y + 1. 2.4 Statements 2.41 a) Statements may be either basic or compound (formed from a sequence of statements enclosed in the statement parentheses, begin and end). Statements are separated one from the next, by the separator";". Example of a compound statement: begin a[i]: = b [i] + c [i]; x: = a [i] end In general, if S1, S2, …, Sn are statements then begin S1; S2; ; ; Sn end is a statement. - 2 -
  • 9. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus b) A statement may be labeled, as follows: L:S where L is a name or an integer; L thus becomes the label of statement S. 2.42 Assignment statements Assignment statements direct that an expression is to be evaluated and assigned as the value of a variable. Examples of assignment statements: a) x: = a + b means: assign the value of a + b as the value of x. b) alpha: = 4.63 c) r [i, j]: = s [i] + t [j] d) B: = (x > 0) ˄ A here A and B are Boolean variables and B receives the truth-value of the Boolean expression on the right. 2.43 go to statements a) A go to statement may specify some statement, other than the statement which follows it, as its successor in the computing process described by the program. This may be done explicitly by writing the label of the desired successor as follows: go to A where A is the label of some statement in the program. Or, the successor of the go to statement may be made to depend upon the value of some expression by the use of a switch variable whose subscript is the desired expression. The value of a switch variable is a label. Thus, if "branch" is the name of a switch variable, then: go to branch [i + j] has as its successor that statement whose label is the value of branch [i + j]. b) Switch variables are defined by switch declarations (2.53). Thus, the switch variable "branch" might be defined by the following declaration: switch branch (A1, A2, B1, B2) where A1, A2, B1, B2 are labels of statements. The value of branch [i + j] is then the (i + j) th label in the sequence (or the nth label, where n is the integer formed by rounding i + j). For example, if i + j equals 3, then the value of branch [i + j] is B1, and in that instance, "go to branch [i + j]" has the same significance as "go to B1". c) Switch variables may be used in the definition of other switch variables. Thus, the following two switch declarations might appear in a program: switch branch (A1, A2, B1, B2) switch fork (branch [i], A1, B1). In this case if i equals 4 and j equals 1, the value of fork [j] is B2. - 3 -
  • 10. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus d) A switch variable may have no value in some cases. For example, branch [i] as defined above has no value if the integer nearest i is less than 1 or greater than 4. In such an instance the successor of "go to branch [i]" is the next statement in the program. 2.44 if clauses and if statements The if clause, "if B", where B is some Boolean expression, combines with the statement, S, following it to form a compound statement. This· compound statement has the same effect as S if B is true and has the effect of "no operation" if B is false. Example of the use of if statement: if (a > 0); x: = 1; if (a = 0); begin x: = y; p: = 0 end; if (a < 0); go to B; S In the above program segment statement S is encountered unless a is negative, in which case "go to B" is executed; if a is positive and non-zero, x is 1 and p is unaffected when S is reached, otherwise x equals y and p equals 0. 2.45 for clauses and for statements: a) A for clause, like an if clause, combines with the statement, S, following it to forma compound statement. A for statement specifies that a given variable take on a succession of values and that the governed statement, S, be executed once for each value of the variable. Thus, for x: = 1, r + s, k, 6.3, -10; a: = (a + x)/x causes the governed statement to be repeated five times, once for each of the listed values of x. Since the statement governed by a for clause may be an involved compound statement which may include other for statements, complex recursive procedures may be easily specified by their use. b) Sequences of values may also be given as arithmetic progressions: this clause directs that i should assume the values: a 2, a 2 + b/2, a 2 + b,"', a 2 + nb/2,'" until y + 1 is reached but not passed. Several such progressions may be included in a single for clause; e.g. for r: = 1(3)10, 12(4)20, 21(-7)1 gives the sequence of r-values: 1,4, 7, 10, 12, 16, 20, 21, 14,7. 2.46 converge statements a) A converge statement preceding a compound statement S causes those sub statements comprising S which do not explicitly specify a successor, to have the statement following S as their common successor. However, in the case of an if statement, only the successor of the governed statement is altered. The successor of an if statement with a false Boolean expression is the next statement. Thus: converge; begin if B1; S1; if B2; S2; if B3; S3 end; S4 causes that single statement Si to be executed which corresponds to the first true Boolean expression Bi; this Si is then succeeded by S4. Thus, if B1, B2 and B3 are all true, the effect is to execute S1 and then S4. b) A converge statement may also be used to conveniently select a single statement for execution as follows: - 4 -
  • 11. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus converge; begin go to branch [I]; L1; S1; L2: S2; L3: S3 end; S4 If "branch [i]" takes on the values L1, L2, La for i = 1,2,3, then the statement following converge has the effect of the single statement Si followed by S4. 2.47 do statement a) A do statement is simply a shorthand way of rewriting a segment of a program which appears elsewhere. Thus, do A; x: = y + z; A: r: = x + r is another way of writing the following: B: r: = x + r; x: = y + z; A: r: =x + r where the copied statement has been given a new label, B, simply to avoid having two statements with the same label. The choice of new labels in the copy is immaterial as long as the reassignment is done consistently throughout the copy. b) A do statement may specify a sequence of statements to be copied by giving two labels. do R, S thus represents the sequence of statements from the one labeled R through the one labeled S. c) A do statement may require that certain alterations are to be made in the copy which it represents. do R, S (x + y → x, a[i] → beta) stands for the segment from R through S but with the name "x" replaced by "x + y" everywhere it appears and with "beta" replaced by "a [i]". 2.48 stop statements stop statements have no successor, hence they signify the operational end of the process described by a program. 2.49 return statements A return statement, written "return", is used only in programs which define the meaning of procedure statements. It signifies that the defined procedure has been completed and that the successor of the procedure statement which invoked the defining program is the next statement in the invoking program. 2.410 Procedure statements A procedure statement indicates that some particular process is to be performed, employing those entities indicated by input parameters and producing results which are designated by the output parameters. (Some procedure statements may also indicate specific successor statements by a list of labels or switch variables which are associated with various exit conditions). Thus, integrate (F(r), a, b, e) =: (int): (L) might indicate that is to be found with an error less than e (if possible, with the given procedure), that the result is to be assigned as the value of "int" and that if the desired result is not obtained the successor of this statement should be the one labelled L. Some procedure statements may simply be added to IAL as primitives (and realized by machine language subroutines). Others may refer, by the name which stands in front (e.g., "integrate"), to an IAL program (d procedure declarations 2.56) which represents the process indicated. Some procedure statements may not have any input parameters, others may have no output - 5 -
  • 12. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus parameters. Thus, a procedure statement which causes one number to be obtained from an external medium might be, in = :(a) indicating that the number should be assigned as the value of a. Another might be print (r, s, t). Another procedure statement may specify the replacement of a matrix, A, by its inverse: invert (A [,] =: (A [,]) In general, it is intended that virtually any process can be expressed by a procedure statement. 2.5 Declarations Declarations in an IAL program state certain facts which are to obtain throughout the program. They may appear at any point in the program, but their position in it is not significant. 2.51 Type declarations A type declaration, boolean or integer, asserts that the value of a variable or function or element of an array will always be of the given type. Thus, boolean (a, b, c) asserts that any value assigned to entities having the names a, b, or c will be changed to a zero or a one according to some rule, t, (e.g., t (x) = 1 when x = 1, otherwise t (x) = 0). Thus: a: = x in a program containing the above declaration would be equivalent to: a: = t(x) or again the appearance of a function b (x) in an expression in the program would be equivalent to t (b (x)). Similarly, integer (r, s) constrains entities having names r or s to have integer values by rounding non-integer values to the nearest integer. 2.52 array declarations array declarations specify the upper and lower bounds for the subscripts which may be meaningfully associated with an array. Thus: array (a, b, c [1: 100], r, s [-10,1: + 10,50]) indicates that a, b, c are one-dimensional arrays whose subscripts have meaning only in the range 1 to 100 (inclusive), and that r, s are two-dimensional arrays whose first subscript should lie between -10 and + 10 and the second between 1 and 50 (inclusive). 2.53 switch declarations switch declarations have already been described under the heading, "go to statements" (2.43). 2.54 Function declarations Certain functions may be defined for use within a program by a function declaration as follows: g (x, y): = w + x + f (y, x) If, in the program containing the above declaration, the following appears: g (t/v, h (v)), then its value is given by the expression: - 6 -
  • 13. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus w + t/v + f (h (v), t/v) Note, in this case, that g (x, y) is always a function of w even though it does not appear as an argument. 2.55 comment declarations comment declarations do not affect the behavior of the program, they simply provide the ability to incorporate verbal comments in a program. For example: comment This is the end of Section 1. The comment may be arbitrarily long provided it does not contain a statement separator, semicolon. 2.56 Procedure declarations Procedure declarations are unique among declarations: precisely one procedure declaration must precede the program it refers to. Such a declaration indicates that the IAL program following defines one or more procedure statements and/or functions. For example: procedure branch (a): (L1, L2, L3); begin branch: if (a < 0); go to L1; if (a = 0); go to L2; if (a > 0); go to L3 end This comprises a procedure declaration followed by a program of one compound statement. The procedure statement defined thereby is one named "branch" which selects one of three successors according as the value of the input is negative, zero, or positive. Thus, the procedure statement, branch (x - f (y)): (a [I], BB, MM) used in any program means, by virtue of its defining program: go to the statement indicated by the switch variable a [i] when x - f (y) is negative, if it is zero, go to BB, and if it is positive, go to MM. One more example: procedure root (a, b), ckroot (a, b) =: (c): (d); begin ckroot: if (a - b < 0); go to d; root: c: = sqrt (a - b); root: = c; return end The procedure declaration, together with the program, defines a function, root, and a procedure statement, named "ckroot". The calculation of the function begins with the statement labelled root, and its value is that of the variable, root, when return is encountered. The program for ckroot begins at the first statement, labelled ckroot. The process corresponding to ckroot (x, y/z) =: (a): (GL) therefore, either gives the value sqrt (x - y/z) or, if x-y/z is negative, specifies the statement labelled GL as its successor. On the other hand, v: = r + root (m, n) results in v having the value r + sqrt (m - n) regardless of the sign of m - n. 3. Formal description 3.1 General The Zurich ACM-GAMM Conference had two principal motives in proposing the IAL: - 7 -
  • 14. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus a) To provide a means of communicating numerical methods and other procedures between people. and, b) To provide a means for realizing a stated process on a variety of machines with the only differences between the realizations of a program on two machines being those imposed by differences in word lengths, overflow conditions and the like. It appears that IAL, as given by informal descriptions here and elsewhere [1], suffices rather well for goal (a). However, if programs are to be written for a variety of machines to translate from IAL to the machine's language in such a way that goal (b) is satisfied, two requirements must be met: c) There must exist a precise description of those sequences of symbols which constitute legal IAL programs. Otherwise, it will often be the case that a program which is legal and translatable for one translating program will not be so with respect to another. d) For every legal program there must be a precise description of its "meaning", the process or transformation which it describes, if any. Otherwise, the machine language programs obtained by two translating programs from a single IAL program may behave differently in one or more crucial respects. Heretofore there has existed no formal description of a machine-independent language (other than that provided implicitly by a complete translating program) which has met either of the two requirements above. Consequently, as anyone who has actually been involved in writing a translating program can testify, a large number of decisions affecting membership in the-class of legal programs and the meaning of legal programs must be made during the construction of the translating program. If, therefore, IAL is left in its present state of incomplete and informal description, it is likely that many man-years may be invested in producing a number of translating programs which will not reliably produce equivalent machine programs. In this case the great potential benefits and savings offered by goal (b) will be lost. The author had hoped to complete a formal description of the set of legal IAL programs and of their meanings in time to present it here. Only the description of legal programs has been completed however. Therefore, the formal treatment of the semantics of legal programs will be included in a subsequent paper. The work which has already been done in this direction indicates a need for minor modifications in IAL to facilitate its completion. These changes will require the approval of the appropriate groups. Since some of these changes are present in both chapters 2 and 3 of this paper, no official status for the descriptions contained in it should be assumed, although the changes are few and, for the most part, slight. 3.2 Syntax of IAL In the description of IAL syntax which follows we shall need some metalinguistic conventions for characterizing various strings of symbols. To begin, we shall need metalinguistic formulae. Their interpretation is best explained by an example: Sequences of characters enclosed in "< >" represent metalinguistic variables whose values are strings of symbols. The marks ": ==" and "or" are metalinguistic connectives. Any mark in a formula, which is not a variable or a connective, denotes itself (or the class of marks which are similar to it). Juxtaposition of marks and/or variables in a formula signifies juxtaposition of the strings denoted. Thus, the formula above gives a recursive rule for the formation of values of the variable <ab>. It indicates that <ab> may have the value "(" or "[" or that given some legitimate value of <ab>, another may be formed by following it with the character "(" or by following it with some value of the variable <d>. If the values of <d> are the decimal digits, some values of <ab) are: [(((1(37( (12345( ((( [86 - 8 -
  • 15. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 3.31 Integers and numbers 3.32 Identifiers and variables 3.33 Subscripted, variables and arrays 3.34 Parameters, functions and pure functions - 9 -
  • 16. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 3.35 Arithmetic expressions, Boolean expressions, and expressions 3.41 Assignment statements 3.42 go to statements and designational expressions 3.43 if statements 3.44 for statements 3.45 converge statements 3.46 do statements - 10 -
  • 17. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 3.47 stop statements 3.48 Procedure statements and pure procedures [a pure procedure may have any of the forms of a procedure statement but at least one position of one existing list must be empty: at least one input parameter position or one output position or one successor position]. 3.49 return statements 3.51 type declarations 3.52 array declarations - 11 -
  • 18. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 3.53 switch declarations 3.54 Function declarations 3.55 comment declarations 3.56 common declarations 3.57 Statements and declarations 3.6 Syntactic properties of IAL statement lists a) L is the entry label of a statement S if S has the form: L: <u stmt> b) If d 2 is a designational expression in statement list S and there is a switch declaration: switch X1: = (…, d2,…) then d2 is said to succeed any designational expression of the expression of the form X1 [< exp>]. Further, if d3 succeeds d2 and d2 succeeds d1, then d3 succeeds d1. 3.7 Definition of an IAL program An IAL program is a statement list (<sl>) with the following properties: a) No two statements or sub statements have the same prefixed label. b) No designational expression succeeds itself. c) Every designational expression has some label as successor, or is itself a label. d) To every n-place array name or subscripted variable name there corresponds one and only one entry of that name in an n-place array segment (n = 1/2 number of entries in the upper-lower-bound list, <ulbl>). - 12 -
  • 19. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 4. Acknowledgment The proposed International Algebraic Language is the direct and indirect product of many people's work. Most directly it is the result of the Zurich Conference at which the participants were: F. L. Bauer, H. Bottenbruch, H. Rutishauser, and K. Samelson (representing the GAMM), and J. W. Backus, C. Katz, A. J. Perlis, and J. H. Wegstein (representing the ACM). Extensive preparatory work was done by larger ACM and GAMM committees [1]. All of this, in turn, was based on prior work done by many individuals and groups in the field of automatic programming. The earliest work (to the author's knowledge) in this area was that of Rutishauser, in Switzerland, and of Laning and Zierler, in the United States. 5. Reference [l] PERLIS, A. J., and K. Samelson: Preliminary Report-International Algebraic Language. Communications of the ACM, Vol. 1, No. 12, Dec. 1958. - 13 -
  • 20. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
  • 21. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 2. Testo tradotto
  • 22. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
  • 23. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus Traduzione de: The syntax and semantics of the proposed International Algebraic Language by John W. Backus Questo articolo fornisce un riassunto della sintassi e dell'interpretazione delle regole del linguaggio algebrico internazionale proposto dalla Conferenza ACM-GAMM di Zurigo, seguita da una presentazione formale e completa delle stesse informazioni. Diverse notazioni sono qui proposte per rappresentare numeri, variabili numeriche, variabili booleane, relazioni, array n-dimensionali, funzioni, operatori ed espressioni algebriche. I procedimenti sono forniti nel linguaggio per eseguire: • l’assegnazione di valori a variabili, • l’esecuzione condizionale di enunciati, • le procedure iterative, • la formazione di enunciati composti da sequenze di affermazioni, • la definizione di nuove affermazioni per procedure arbitrarie, • la modifica e il riutilizzo di segmenti di programma. Il linguaggio proposto ha lo scopo di fornire uno strumento comodo e conciso per esprimere virtualmente tutte le procedure di calcolo numerico impiegando un numero relativamente basso di regole sintattiche e tipi di dichiarazione. Sintesi Nel maggio 1958 una conferenza a Zurigo completò il progetto congiunto dell'ACM (Association for Computing Machinery) e la GAMM (Association for Applied Mathematics and Meccanica) approvando una proposta di International Algebraic Language (IAL) o ALGOL. Saranno presentati qui altri materiali per discutere sia la storia del progetto che i vari aspetti del linguaggio. Lo scopo del presente documento, invece, è quello di descrivere con precisione sia la sintassi che la semantica di IAL. La descrizione data qui sarà quella del cosiddetto "linguaggio di riferimento" che, per chiarezza, impiega un insieme specifico di simboli e convenzioni di notazione. Va tenuto presente, tuttavia, che il linguaggio formale di riferimento di IAL è nato principalmente con lo scopo di descrivere le regole di costruzione del. linguaggio e dei suoi significati. Nell'uso effettivo sono previste una varietà di simbolizzazioni e convenzioni di notazione, poiché ogni rappresentazione è una traslitterazione abbastanza precisa del linguaggio di riferimento avendo in comune le stesse regole di sintassi e semantica. Le "rappresentazioni hardware" utilizzeranno generalmente un minor numero di simboli rispetto a quello impiegato nel linguaggio di riferimento risultando così più consone per la traduzione meccanica in linguaggio macchina per un determinato tipo di macchina. Le "forme di pubblicazione" del linguaggio, d'altro canto, impiegheranno molte notazioni convenzionali della matematica (ad es., esponenti, pedici, lettere greche) e saranno utilizzate nella comunicazione in scrittura umana dei programmi IAL. La descrizione del linguaggio di riferimento è divisa in due parti. Il capitolo 2 fornisce una breve descrizione informale dei principali elementi della lingua in termini di esempio mentre il capitolo 3 fornisce una descrizione formale della struttura del linguaggio. - 16 -
  • 24. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 2.1 Sintesi 2. Descrizione informale Un programma IAL è una sequenza di istruzioni che possono essere intervallate da alcune dichiarazioni. Ogni dichiarazione descrive una regola di calcolo e, esplicitamente o implicitamente, specifica un'istruzione successore (il successore è l’istruzione successiva nel programma se non diversamente indicato). La regola di calcolo data da un programma è, ovviamente, la sequenza di calcoli specificata dalle istruzioni quando prese nell'ordine previsto dai parenti successori. Le dichiarazioni affermano alcuni fatti che devono valere in tutto il calcolo. La loro posizione nel programma è generalmente irrilevante. I paragrafi seguenti presentano alcuni degli aspetti importanti proprietà di espressioni e proposizioni, con esempi 2.2 Espressioni algebriche a) Le espressioni algebriche sono composte da variabili, costanti, funzioni e operatori per la consueta aritmetica operazioni. b) Nomi di variabili, funzioni e altre entità sono composto da caratteri alfabetici e numerici, il primo essendo alfabetico. Una sequenza di caratteri può essere di qualsiasi lunghezza. c) Resta inteso che nelle operazioni aritmetiche, l’espressione in virgola mobile indica una rappresentazione approssimata dei numeri reali. Alcune variabili possono essere dichiarate per essere di valore intero. L'effetto di tale dichiarazione è che qualsiasi valore, che deve essere assegnato a tale variabile, è prima arrotondato all'intero più vicino. d) Le dichiarazioni di array (d. 2.5) possono indicare che alcuni nomi sono di array di dati di varie dimensioni. Questi nomi possono apparire nelle espressioni come indici di variabili seguite da una sequenza di pedici racchiusi tra parentesi quadre, dal numero di pedice corrispondente alla dimensionalità della matrice mentre ogni pedice sarà separato dal successivo da una virgola. Poiché le parentesi sono utilizzate per racchiudere gli argomenti delle funzioni (e sotto espressioni), è facile distinguere tra funzioni e variabili indicizzate. Un pedice può essere un’espressione qualsiasi; il valore del pedice è il numero intero formato dall'arrotondamento del valore dell'espressione (se non è già da un numero intero). Esempi di espressioni algebriche 1) significa 2) significa 3) significa 4) significa In particolare, se i e j hanno entrambi valore 1 (o 1,2) quando l'espressione di cui sopra è incrociata, allora è equivalente a: R2, 1 × S1, 2 Esempi di espressioni booleane È possibile dichiarare alcune variabili, o valori di matrici, con valore booleano (ovvero, con il solo valore 0, "FALSO", o 1, "VERO"). Queste variabili, le costanti 0 e 1, le funzioni con valori booleani e le sotto espressioni della forma: (E rE') possono essere combinate con gli operatori booleani "and", "or", "not" e "equivalent" per formare un'espressione booleana. (In quanto sopra, E ed E' sono espressioni algebriche ed r è una relazione come, ad esempio, (x/y> 1).) - 17 -
  • 25. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus Esempi di espressioni booleane 1) Questa espressione booleana è vera se, e solo se, X è maggiore di Y o Y è maggiore di Z2 o entrambi. L'operatore è quello "or". 2) Qui A e B sono due variabili con valori booleani. L'espressione è vera quando A è falsa e B è vera o quando A è vera e X è uguale a Y + 1. 2.4 Dichiarazioni Esempi di dichiarazioni composte 2.41 a) Gli enunciati possono essere di base o composti (formati da una sequenza di enunciati racchiusi tra parentesi di enunciato, inizio e fine). Le istruzioni sono separate una dall'altra dal separatore ";". begin a [i]: = b [i] + c [i]; x: = a [i] end In generale, se S1, S2, ... Sn sono dichiarazioni allora: begin S1; S2; ; ; Sn end è una dichiarazione. b) Una dichiarazione può essere etichettata, come segue: L:S dove L è un nome o un numero intero; L diventa così l'etichetta della dichiarazione S. Esempi di istruzioni di assegnazione 2.42 Dichiarazioni di assegnazione Le istruzioni di assegnazione indicano che un'espressione deve essere valutata e assegnata come valore di una variabile. a) x: = a + b significa: assegnare il valore di a + b come valore di x. b) alfa: = 4.63 c) r [i, j]: = s [i] + t [j] d) B: = (x > 0) ˄ A dove A e B sono variabili booleane e B riceve il valore di VERO dell'espressione booleana a destra. 2.43 Dichiarazione go to a) Un'istruzione go to può specificare un'istruzione, diversa dall'istruzione che la segue, come sua succeditrice nel processo di calcolo descritto dal programma. Questo può essere fatto esplicitamente scrivendo l'etichetta del successore desiderato come segue: go to A dove A è l'etichetta di qualche istruzione nel programma. Il successore dell'istruzione go to può essere creato, oppure già dipende dal valore di qualche altra espressione mediante l'uso di una VARIABILE SWITCH, il cui pedice è l'espressione desiderata. Il valore di una VARIABILE switch è un'etichetta. Quindi se "branch" è il nome di una VARIABILE SWITCH, si avrà: - 18 -
  • 26. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus Esempio dell'uso delle istruzioni if Esempio dell'uso delle clausole for go to branch [i + j] che ha come successore quella dichiarazione la cui etichetta è il valore del ramo [i + j]. b) Le VARIABILI SWITCH sono definite dalle DICHIARAZIONI SWITCH (Cfr.: 2.53). Pertanto la VARIABILE SWITCH "branch" potrebbe essere definita dalla seguente dichiarazione: switch branch (AI, A2, B1, B2) dove A1, A2, B1, B2 sono etichette di dichiarazioni. Il valore del ramo [i + J] è quindi la (i + j) esima etichetta nella sequenza (o l'n-esima etichetta, dove n è l'intero formato dall'arrotondamento: i + j). Ad esempio, se i + j è uguale a 3, il valore del ramo [i + j] è B1 e, in tal caso, "go to branch [i + j]" ha lo stesso significato di "go to B1". c) Le VARIABILI SWITCH possono essere utilizzate nella definizione di altre VARIABILI SWITCH. Così le seguenti due dichiarazioni SWITCH potrebbero apparire in un programma: switch branch (AI, A2, Bl, B2) switch fork (branch [i], AI, Bl). In questo caso se i è uguale a 4 e j è uguale a 1, il valore di fork [j] è B2. d) Una VARIABILE SWITCH, in alcuni casi, potrebbe non avere alcun valore. Ad esempio, il ramo [i] come definito sopra non ha valore se l'intero più vicino a i è minore di 1 o maggiore di 4. In tal caso il successore di "go to branch [i]" è l'istruzione successiva nel programma. 2.44 clausole if e istruzioni if La clausola if, "if B", dove B è un'espressione booleana, si combina con l'istruzione S che la segue per formare un'istruzione composta. Questa affermazione composta ha lo stesso effetto di S se B è vera e ha l'effetto di "nessuna operazione" se B è falsa. if (a > 0); x: = 1; if (a = 0); begin x: = y; p: = 0 end; if (a < 0); go to B; S 2.45 clausole for e dichiarazioni for a) Una clausola for, come una clausola if, si combina con l'istruzione S, che la segue per formare un'istruzione composta. Un'istruzione for specifica che una data variabile assume una successione di valori e che l'istruzione governata, S, deve essere eseguita una volta per ogni valore della variabile. Così, ad esempio: for x: = 1, r + s, k, 6.3, -10; a: = (a + x) /x fa sì che la dichiarazione governata venga ripetuta cinque volte, una volta per ciascuno dei valori elencati di x. Dalla dichiarazione composta governata da una clausola for può essere coinvolta un’istruzione che può includere altre istruzioni for, così procedure ricorsive complesse possono essere facilmente specificate dal loro impiego. b) Le sequenze di valori possono anche essere date come progressioni aritmetiche: questa clausola indica che i dovrebbe assumere i valori: a2 , a2 + b/2, a2 + b, …, a2 + nb/2, … finché y + 1 non viene raggiunto, ma non - 19 -
  • 27. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus Esempio di dichiarazioni convergenti superato. Molte di queste progressioni possono essere incluse in una sola clausola for; per esempio: for r: = 1(3)10, 12(4)20, 21(-7)1 fornisce la sequenza di valori r: 1, 4, 7, 10, 12, 16, 20, 21, 14, 7. 2.46 Dichiarazioni convergenti a) Un'istruzione di convergenza che precede un'istruzione composta S fa sì che quelle sottodichiarazioni comprendenti S, che non specificano esplicitamente un successore, abbiano l'affermazione che segue S come successore comune. Tuttavia, nel caso di una dichiarazione if è solo il successore della dichiarazione governata ad essere alterato. Il successore di un'istruzione if con un’espressione booleana falsa è l'istruzione successiva. Cosi, ad esempio: converge; begin if B1; S1; if B2; S2; if B3; S3 end; S4 fa eseguire quell'unica istruzione Si che corrisponde alla prima espressione booleana vera Bi; questo Si è poi seguito da S4. Quindi se B1, B2 e B3 sono tutti veri, l'effetto è eseguire S1 e poi S4. b) Un'istruzione converge può anche essere usata convenientemente selezionando una singola istruzione per l'esecuzione così come segue: converge; begin go to branch [i]; L1; S1; L2: S2; L3: S3 end; S4 Se "branch [i]" assume i valori L1, L2, L3 per i = 1,2,3, allora la dichiarazione che segue converge ha l'effetto dell'unica dichiarazione Si seguita da S4. 2.47 Istruzione do a) Un'istruzione do è semplicemente un modo abbreviato per riscrivere il segmento di un programma che appare altrove. Avremo così: do A; x: = y + z; A: r: = x + r che è un modo alternativo di scrivere quanto segue: B: r: = x + r; x: = y + z; A: r: =x + r dove all'enunciato copiato è stata assegnata una nuova etichetta, B, semplicemente per evitare di avere due enunciati con la stessa etichetta. La scelta di nuove etichette nella copia è irrilevante fintanto che la riassegnazione viene eseguita in modo coerente in tutta la copia. b) Un'istruzione do può specificare una sequenza di istruzioni da essere copiate dando due, o più, etichette. do R, S che rappresenta, quindi, la sequenza di istruzioni da quella etichettata R a quella etichettata S. c) Una istruzione do può richiedere che vengano apportate determinate modifiche alla copia che essa rappresenta: do R, S (x + y → x, a [i] → beta) che si deve interpretare: per il segmento da R a S, ma con il nome "x", sostituito da "x + y" ovunque appaia e con "beta" sostituito da "a [i]". 2.48 Istruzione stop Le istruzioni stop non hanno successori, quindi rappresentano il termine operativo del processo descritto da un programma. - 20 -
  • 28. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 2.49 Istruzione return Un'istruzione return, scritta "return", è usata solo nei programmi che definiscono il significato delle istruzioni di procedura. Ciò significa che la procedura definita è stata completata e che il successore dell'istruzione di procedura, che ha invocato il programma di definizione, è l'istruzione successiva nel programma invocante. 2.410 Dichiarazioni procedurali L'istruzione procedurale indica che un particolare processo deve essere eseguito impiegando quelle entità indicate dai parametri di input e producendo risultati che sono designati dai parametri di output. (Alcune istruzioni procedurali possono anche indicare specifiche istruzioni successive mediante un elenco di etichette o variabili di commutazione associate a varie condizioni di uscita). Avremo così, ad esempio: integrate (F(r), a, b, e) =: (int): (L) che potrebbe indicare F (r, x) dx, che deve essere trovato con un errore minore di e (se possibile con la procedura data), che il risultato deve essere assegnato come valore di "int" e che, se non si ottiene il risultato desiderato, il successore di quest’istruzione dovrebbe essere quello etichettato con L. Alcune istruzioni procedurali possono essere aggiunte semplicemente a IAL come primitive (e realizzate da subroutine in linguaggio macchina). Altre possono fare riferimento, con il nome che le precede (ad esempio, "integrate"), a un programma IAL (cfr.: dichiarazioni procedurali d 2.56) che rappresenta il processo indicato. Alcune istruzioni procedurali potrebbero non avere parametri di input, altre potrebbero non avere parametri di output. Quindi, un'istruzione procedurale, che produce, ad esempio, l'ottenimento di un numero da un supporto esterno, potrebbe essere: in = :(a) indicando che il numero deve essere assegnato come valore di a. Un altro potrebbe essere: print (r, s, t). Un'altra dichiarazione procedurale può specificare la sostituzione di una matrice, A, dalla sua inversa: invert (A [,] =: (A [,]) In generale, si intende che praticamente qualsiasi processo può essere espresso da una dichiarazione procedurale. 2.5 Dichiarazioni Le dichiarazioni in un programma IAL affermano determinati fatti che devono essere ottenuti durante tutto il programma. Possono apparire in qualsiasi punto del programma, ma la loro posizione non è significativa. 2.51 Dichiarazioni di tipo Una dichiarazione di tipo, booleana o intera, afferma che il valore di una variabile o funzione o elemento di un array sarà sempre del tipo specificato. Avremo così: boolean (a, b, c) asserisce che qualsiasi valore assegnato a entità con i nomi a, b o c sarà cambiato in uno 0 o 1 secondo qualche regola, t, (ad esempio, t (x) = 1 - 21 -
  • 29. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus quando x = 1, altrimenti t (x) = 0). Avremo così: a: = x o ancora la comparsa di una funzione b (x) in un'espressione nel programma sarebbe equivalente a t (b (x)). Allo stesso modo avremo: integer (r, s) vincola le entità con nomi r o s ad avere valori interi arrotondando i valori non interi all'intero più vicino. 2.52 dichiarazioni di array le dichiarazioni di array specificano i limiti, superiore e inferiore, per i pedici a cui possono essere associati, in modo significativo, gli array. Avremo così: array (a, b, c [1: 100], r, s [-10,1: + 10,50]) indica che a, b, c sono array unidimensionali i cui pedici hanno significato solo nell'intervallo da 1 a 100 (inclusi), e che r, s sono array bidimensionali i cui il primo pedice dovrebbe essere compreso tra -10 e + 10 e il secondo tra 1 e 50 (inclusi). 2.53 dichiarazioni di commutazione Le DICHIARAZIONI SWITCH sono già state descritte sotto il titolo "Istruzioni go to" (Cfr.: 2.43). 2.54 Dichiarazioni di funzioni Alcune funzioni possono essere definite per l'uso all'interno di un programma mediante una dichiarazione di funzione così come segue: g (x, y): = w + x + f (y, x) Se nel programma, contenente la suddetta dichiarazione, compare: g (t/v, h (v)), allora il suo valore è dato dall'espressione: w + t/v + f (h (v), t/v) Si noti, in questo caso, che g (x, y) è sempre una funzione di w anche se non appare come argomento. 2.55 Commenti I commenti non influiscono sul comportamento del programma, forniscono semplicemente la possibilità di incorporare commenti verbali in un programma. Per esempio: comment This is the end of Section 1. Il commento può essere arbitrariamente lungo a condizione che non contenga un separatore di istruzioni, punto e virgola. 2.56 Dichiarazioni procedurali Le dichiarazioni procedurali sono uniche tra le dichiarazioni: una sola dichiarazione procedurale deve precedere il programma a cui si riferisce. Tale dichiarazione indica che il programma IAL che segue definisce una o più istruzioni e/o funzioni procedurali. Per esempio: procedure branch (a): (L1, L2, L3); begin branch: if (a < 0); go to L1; if (a = 0); go to L2; if (a > 0); go to L3 end - 22 -
  • 30. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus comprende una dichiarazione procedurale seguita da un programma di una dichiarazione composta. L'istruzione della procedura così definita è quella denominata "branch" che seleziona uno dei tre successori a seconda che il valore dell'input sia negativo, zero o positivo. Così, dunque, sarà la dichiarazione procedurale: branch (x - f (y)): (a [i], BB, MM) usato in qualsiasi programma significa, in virtù del suo programma che lo definisce: vai all'istruzione indicata dalla VARIABILE SWITCH a [i] quando x - f (y) è negativo, se è zero, vai a BB, e se è positivo, vai a MM. Un altro esempio: procedure root (a, b), ckroot (a, b) =: (c): (d); begin ckroot: if (a - b < 0); go to d; root: c: = sqrt (a - b); root: = c; return end La dichiarazione procedurale, insieme al programma, definisce una funzione, una radice e un'istruzione procedurale, denominata "ckroot". Il calcolo della funzione inizia con l'istruzione etichettata root, e il suo valore è quello della variabile root, quando si incontra return. Il programma per ckroot inizia dalla prima istruzione, denominata ckroot. Il processo corrispondente a: ckroot (x, y/z) =: (a): (GL) quindi o fornisce a del valore sqrt (x - y/z) oppure, se x-y/z è negativo, specifica l'istruzione etichettata GL come suo successore. D'altro canto v: = r + root (m, n) 3 Descrizione formale 3.1 Generale La Conferenza ACM-GAMM di Zurigo ha avuto due motivazioni principali nel proporre IAL: a) Fornire un mezzo per comunicare metodi numerici, e altre procedure, tra le persone. e, b) Fornire un mezzo per realizzare un determinato processo su di una molteplicità di macchine, con le uniche differenze tra le esecuzioni di un programma su due macchine diverse essendo queste imposte dalle differenze di lunghezza delle parole, condizioni di overflow e simili. Sembra che IAL, come indicato da descrizioni informali qui e altrove [1], sia sufficiente per raggiungere l'obiettivo (a). Tuttavia, se i programmi devono essere scritti per una varietà di macchine per tradurre da IAL al linguaggio della macchina ospite, in modo tale da soddisfare l'obiettivo (b), devono essere adempiuti due requisiti: c) Deve esistere una descrizione precisa di quelle sequenze di simboli che costituiscono i programmi IAL validi. Diversamente accadrà spesso che un programma che è corretto e traducibile per un programma traduttore non lo sarà rispetto ad un altro. d) Per ogni programma valido deve esserci una precisa descrizione del suo "significato", che illustri il suo eventuale processo o trasformazione. In caso contrario, i programmi in linguaggio macchina ottenuti da due programmi di traduzione da un singolo programma IAL potrebbero comportarsi diversamente in uno o più aspetti cruciali. - 23 -
  • 31. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus Finora non è esistita alcuna descrizione formale di un linguaggio indipendente dalla macchina (diversa da quella fornita implicitamente da un programma di traduzione completo) che soddisfacesse uno dei due requisiti di cui sopra. Di conseguenza, come può testimoniare chiunque sia stato effettivamente coinvolto nella stesura di un programma di traduzione, un gran numero di decisioni che riguardano l'appartenenza alla classe dei programmi legittimi e il significato dei programmi legittimi devono essere prese durante la costruzione del programma di traduzione. Se, quindi, IAL viene lasciato così com’è nel suo stato attuale di incompletezza e di sola descrizione informale, è probabile che trascorreranno molti anni nella produzione di una serie di programmi di traduzione che comunque non produrranno in modo affidabile programmi macchina equivalenti. In questo caso andranno perduti i grandi potenziali in termini di benefici e risparmi offerti dall'obiettivo (b). L'autore sperava di completare una descrizione formale dell'insieme dei programmi legittimi IAL, e dei loro significati, in tempo utile per poterla presentare qui. Tuttavia, è stata completata solo la descrizione dei programmi legittimi. Pertanto la trattazione formale della semantica dei programmi ufficiali sarà inclusa in un successivo lavoro. Il lavoro che è già stato fatto in questa direzione indica la necessità di apportare ulteriori modifiche minori in IAL per facilitarne il completamento. Queste modifiche richiederanno l'approvazione degli appositi gruppi. Poiché alcuni di questi cambiamenti sono presenti in entrambi i capitoli 2 e 3 di questo documento, non si dovrebbe assumere uno status ufficiale per le descrizioni in esso contenute, sebbene i cambiamenti siano pochi e, per la maggior parte, lievi. 3.2 Sintassi di IAL Nella descrizione della sintassi IAL che segue avremo bisogno di alcune convenzioni metalinguistiche per caratterizzare varie stringhe di simboli. Per cominciare, avremo bisogno di formule metalinguistiche. La loro interpretazione è meglio spiegata da un esempio: Le sequenze di caratteri racchiuse tra "< >" rappresentano variabili metalinguistiche i cui valori sono stringhe di simboli. I segni ": ≡" e "or" sono connettivi metalinguistici. Qualsiasi segno in una formula, che non è una variabile o un connettivo, denota sé stesso (o la classe di segni che sono simili ad esso). Giustapposizione di segni e/o variabili in una formula significa giustapposizione delle stringhe denotate. Così la formula di cui sopra fornisce una regola ricorsiva per la formazione di valori della variabile <ab>. Indica che <ab> può avere il valore "(" o "[" o quello dato da alcuni valori legittimi di <ab>, se ne può formare un altro, facendolo seguire dal carattere" “(" o facendolo seguire da qualche valore della variabile <d>. Se i valori di <d> sono le cifre decimali, alcuni valori di <ab> sono: [(((1(37( (12345( ((( [86 - 24 -
  • 32. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 3.31 Interi e numeri 3.32 Identificatori e variabili 3.33 Sottotitoli, variabili e array 3.34 Parametri, funzioni e funzioni pure 3.35 Espressioni aritmetiche, espressioni booleane ed espressioni - 25 -
  • 33. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 3.41 Dichiarazioni di assegnazione 3.42 dichiarazioni go to ed espressioni designative 3.43 istruzioni if 3.44 Istruzioni for 3.45 Istruzioni converge 3.46 Istruzioni do 3.47 Istruzione stop - 26 -
  • 34. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 3.48 Enunciati procedurali e procedure pure [una procedura pura può avere una qualsiasi delle forme di una dichiarazione procedurale, ma almeno una posizione di un elenco esistente deve essere vuota: almeno una posizione di parametro di input o una posizione di output o una posizione di successore]. 3.49 istruzioni return 3.50 Dichiarazioni di tipi (N.d.R.: 3.51 sul documento originale) 3.51 Dichiarazioni di array (N.d.R.: 3.52 sul documento originale) 3.52 Dichiarazioni switch (N.d.R.: 3.53 sul documento originale) 3.53 Dichiarazioni di funzioni (N.d.R.: 3.54 sul documento originale) 3.54 Dichiarazione di commenti (N.d.R.: 3.55 sul documento originale) - 27 -
  • 35. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 3.55 Dichiarazione comuni (N.d.R.: 3.56 sul documento originale) 3.56 Statements e declarations (N.d.R.: 3.57 sul documento originale) 3.6 Proprietà sintattiche degli elenchi di istruzioni IAL a) L è l'etichetta iniziale di una proposizione S se S ha la forma: b) Se d2 è un'espressione di designazione nell'elenco di istruzioni S ed è presente una DICHIARAZIONE SWITCH: switch x1: = (..., d2,...) che si leggerà d2 succede a qualsiasi designazione dell'espressione della forma x1 [< exp>]. Inoltre, se d3 succede a d2 e d2 succede a d1, allora d3 succede a dl. 3.7 Definizione di un programma IAL Un programma IAL è un elenco di istruzioni <sl>) con le seguenti proprietà: a) Non esistono due affermazioni o sottoasserzioni uguali all’etichetta prefissata. b) Nessuna espressione designativa succede a sé stessa. c) Ogni espressione designazionale ha una qualche etichetta come successore, o è essa stessa un'etichetta. d) Ad ogni nome di matrice di n posizioni o variabile con indice nome vi corrisponde una ed una sola voce di quel nome in un segmento di array di n posizioni (n = 1/2 numero di voci nell'elenco upper-lower-bound, <ulbl>). - 28 -
  • 36. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus 4. Riconoscimenti Il linguaggio algebrico internazionale proposto è il prodotto diretto e indiretto del lavoro di molte persone. Più direttamente è il risultato della Conferenza di Zurigo in cui i partecipanti erano: F. L. Bauer, H. Bottenbruch, H. Rutishauser e K. Samelson (in rappresentanza del GAMM), e JW Backus, C. Katz, AJ Perlis e JH Wegstein (che rappresentano l'ACM). È stato svolto un ampio lavoro preparatorio dai comitati ACM e GAMM [1]. Tutto questo, a sua volta, era basato sul lavoro precedente svolto da molti individui e gruppi impegnati nel settore della programmazione automatica. Il primo lavoro (a conoscenza dell'autore) in quest’area era quello di Rutishauser, in Svizzera, e di Laning e Zierler, negli Stati Uniti. 5 Note [l] A. J. Perlis, K. Samelson: Preliminary Report-International Algebraic Language. Communications of the ACM, Vol. 1, No. 12, Dec. 1958. Traduzione eseguita con Google Traduttore, adattamento di Salvatore Giglio - 29 -
  • 37. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus
  • 38. Traduzionede: “The syntax and semantics of the proposed International Algebraic Language” di John Backus