-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalgolw.tex
executable file
·3449 lines (2811 loc) · 123 KB
/
algolw.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
% algolw.tex -- The 'ALGOL W Language Description', typeset in LaTeX -*-latex-*- -*-outline-*-
\documentclass[a4paper]{article}
\pdfinfo{
/Title (ALGOL W Language Description)
/Author (Henry Bauer, Sheldon Becker, Susan L. Graham, Edwin Satterthwaite, Richard L. Sites)
}
\usepackage{enumerate}
\usepackage{multind}
\usepackage{listings}
\usepackage{syntax}
\usepackage{slashbox}
\usepackage{longtable}
\usepackage{threeparttable}
\usepackage[mathscr]{euscript}
% (In Debian Squeeze these packages are available after installing the
% texlive-latex-extra package. You may need to download slashbox.sty
% and multind.sty from CTAN https://www.ctan.org/)
% Note: there are \newpage commands in this document to prevent
% examples and tables from being split up, and hard column widths for
% the syntax diagrams. These will matter if you change the font or
% paper size.
\def\ALGOLW{\textsc{Algol W}}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Table of contents.
\setcounter{secnumdepth}{4} %Allow numbered paragraphs.
\setcounter{tocdepth}{3}
% A \quietsubsubsection is numbered but does not go into the contents page:
\def\quietsubsubsection#1{\addtocounter{subsubsection}{1}\subsubsection*{\thesubsubsection. #1}}
% These subsubsections are too short and numerous to go into the contents page:
\def\Syntax{\quietsubsubsection{Syntax}}
\def\Semantics{\quietsubsubsection{Semantics}}
\def\Examples{\quietsubsubsection{Examples}}
\def\Example{\quietsubsubsection{Example}}
\def\SyntaxUnnumbered{\subsubsection*{Syntax}}
\def\SemanticsUnnumbered{\subsubsection*{Semantics}}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Index. (Uses the "multind" package.)
\makeindex{special}
\makeindex{syntax}
% "\IndexAlgolW{classification}{code}" indexes an Algol W identifier or
% item of syntax in the source code listing format. (See below.)
\def\IndexAlgolW#1{\index{special}{#1@\A{#1}}}
\def\IndexReservedWord#1{\IndexAlgolW{#1}}
\def\IndexField#1{\IndexAlgolW{#1}}
\def\IndexRecord#1{\IndexAlgolW{#1}}
% Some Algol W procedure and variable names contain underscores,
% but the "listings" package produces unindexable TeX code for
% identifiers containing underscores. Hence the use of \texttt{x}
% in place of \A!x! here.
\def\IndexAlgolWID#1{\index{special}{#1@\texttt{#1}}}
\def\IndexProcedure#1{\IndexAlgolWID{#1}}
\def\IndexVariable#1{\IndexAlgolWID{#1}}
\def\IndexType#1{}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% BNF syntax sections. (Uses the "syntax" package.)
\renewcommand{\ulitleft}{\normalfont\rmfamily\bfseries\frenchspacing}
\renewcommand{\ulitright}{}
\renewcommand{\litleft}{`\bgroup\normalfont\ttfamily\frenchspacing}
\renewcommand{\litright}{\egroup'}
\grammarparsep1pt % put very little extra space between production rules
\def\<#1>{\synt{#1}} % \<x> = format x as a non-terminal production name
%The T symbols that represent type affixes in production rules:
\def\Tee{$\mathscr{T}$ }
\def\TeeSub#1{$\mathscr{T}_{#1}$}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Formatted Algol W source code. (Uses the "listings" package.)
% Reserved words are bold lowercase because the "syntax" package will
% not allow underlined uppercase. Section 2.1. Basic Symbols has been
% altered (two words) to explain the correct substitution.
\lstdefinelanguage{AlgolW}{%
keywords={true,false,null,integer,real,complex,logical,bits,string,%
reference,long,array,procedure,record,begin,end,if,then,else,case,%
of,div,rem,shr,shl,is,abs,long,short,and,or,goto,go
to,for,step,until,%
do,while,comment,value,result,assert,algol,fortran},%
sensitive=false,%
string=[d]{"},%
keywordcommentsemicolon={end}{else,end}{comment}, %this doesn't seem to work!
literate={~}{$\lnot$}{1}{(LNOT)}{$\lnot$}{1},% the (LNOT) is for places where "~" would confuse LaTeX
}[keywords,comments,keywordcomments]
\lstdefinestyle{ReferenceManual}{%
basicstyle=\small\ttfamily,%
keywordstyle=\rmfamily\bfseries,%
flexiblecolumns=true,%
xleftmargin=\parindent,%
escapechar=`,%
mathescape=true}
% These are the not and not-equals symbols used by ALgol W:
\def\NOT{$\lnot$}
\def\NE{${\lnot}{=}$}
% Inline Algol W source code:
\def\A{\lstinline[language=AlgolW,style=ReferenceManual]}
% Inline Algol W reserved word:
\def\R#1{\lstinline[language=AlgolW,style=ReferenceManual]{#1}}
% Inline Algol W reserved word that should be indexed:
\def\Ri#1{\IndexReservedWord{#1}\R{#1}}
% Inline Algol W type name:
% (The names of Algol types are in italics to match nonterminal production names.
\def\T#1{\textit{#1}}
% Inline Algol W type name, to be indexed:
\def\Ti#1{\IndexType{#1}\T{#1}}
% "Quantities which transcend the ALGOL W language",
% for use in algorithms demonstrating ALGOL W behaviour:
\def\Transcendent#1{\textrm{\textit{\small #1}}}
% Block of Algol W source code:
\lstnewenvironment{AlgolW}{
\lstset{language=AlgolW,style=ReferenceManual}
}{}
% Block of Algol W source code, example code for the manual:
\lstnewenvironment{AlgolWExample}{
\lstset{language=AlgolW,style=ReferenceManual}
}{}
% Algol W built-in procedure declaration:
\lstnewenvironment{ProcedureDeclaration}[2]{
\IndexProcedure{#2}
\lstset{language=AlgolW,style=ReferenceManual}
}{}
% Algol W built-in variable declaration:
\lstnewenvironment{VariableDeclaration}[2]{
\lstset{language=AlgolW,style=ReferenceManual}
\IndexVariable{#2}
}{}
%------------------------------------------------------------------------------------------------------
\begin{document}
\title{\ALGOLW\\Language Description}
\author{by\\Henry Bauer\\Sheldon Becker\\Susan L. Graham\\Edwin Satterthwaite\\Richard L. Sites}{}
\date{June 1972}
\maketitle
\newpage
\tableofcontents
%------------------------------------------------------------------------------------------------------
\newpage
\section{Terminology, Notation and Basic Definitions}
The Reference Language is a phrase structure language, defined by a
formal metalanguage. This metalanguage makes use of the notation and
definitions explained below. The structure of the language \ALGOLW\ is
determined by:
\begin{enumerate}
\item $\mathscr{V}_N$, the set of basic (or \emph{terminal}) constituents of the language,
\item $\mathscr{V}_T$, the set of syntactic entities (or \emph{nonterminal symbols}), and
\item $\mathscr{P}$, the set of syntactic rules (or productions)
\end{enumerate}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\subsection{Notation}
A syntactic entity is denoted by its name (a sequence of letters)
closed in the brackets $\langle$ and $\rangle$. A syntactic rule has
the form
\begin{center}
\syntax{<A> ::= x}
\end{center}
where \<A> is a member of $\mathscr{V}_T$, $x$ is any possible sequence of
basic constituents and syntactic entities, simply to be called a
``sequence''. In \ALGOLW, the set $P$ contains the syntactic rule \index{syntax}{\<bar>|textbf} %
\begin{center}
\syntax{<bar> ::= `|'}
\end{center}
implying that \syntax{`|'} is a basic symbol of the language. Adopting
the convention that all references to this basic symbol in other
syntactic rules shall be replaced by \<bar> permits the unambiguous
use subsequently of the notation %
\begin{center}
\syntax{<A> ::= x | y | \ldots | z}
\end{center}
as an abbreviation for the set of syntactic rules %
\begin{center}
\syntax{<A> ::= x\\<A> ::= y\\$\ldots$\\<A> ::= z}
\end{center}
\noindent In the syntactic rule %
\index{syntax}{\<empty>}
\begin{center}
\syntax{<empty> ::= }
\end{center}
the sequence contains zero symbols, i.e. the empty sequence.
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\newpage
\subsection{Definitions}
\begin{enumerate}
\item A sequence $x$ is said to {\em directly produce} a sequence $y$
if and only if there exist (possibly empty) sequences $u$ and $w$,
so that either (i) for some \<A> in $\mathscr{V}_T$, $x = u$\<A>$w$, $y =
uvw$, and \<A> $::= v$ is a rule in $\mathscr{P}$; or (ii) $x = uw$, $y =
uvw$ and $v$ is a ``comment'' (see below).
\item A sequence $x$ is said to \emph{produce} a sequence $y$ if and
only if there exists an ordered set of sequences $s_0, s_1, ...,
s_n$, so that $x = s_0$, $s_n = y$, and $s_{i-1}$ directly produces
$s_i$ for all $i = 1, ... , n$.
\item A sequence $x$ is said to be an \ALGOLW\ program if and only if
its constituents are members of the set $\mathscr{V}_N$, and $x$ can be
produced from the syntactic entity \<program>.
\end{enumerate}
The sets $\mathscr{V}_N$ and $\mathscr{V}_T - \{$`\verb!|!'$\}$ are
defined through enumeration of their members given throughout in
Section \ref{Sets of Basic Symbols and Syntactic Entities} and
Appendix \ref{Syntactic Entities} of this Report (cf.~also
\ref{Strings}). To provide explanations for the meaning of
\ALGOLW\ programs, the letter sequences denoting syntactic entities
have been chosen to be English words describing approximately the
nature of that syntactic entity or construct. Where words which have
appeared in this manner are used elsewhere in the text, they refer to
the corresponding syntactic definition. Along with these letter
sequences the symbol \Tee may occur. It is understood that this symbol
must be replaced by any one of a finite set of English words (or word
pairs). Unless otherwise specified in the particular section, all
occurrences of the symbol \Tee within one syntactic rule must be
replaced consistently, and the replacing words are
\begin{quote}
\begin{tabular}{ll}
\T{integer} & \T{logical} \\
\T{real} & \T{bit} \\
\T{long real} & \T{string} \\
\T{complex} & \T{reference} \\
\T{long complex}
\end{tabular}
\end{quote}
\noindent For example, the production
\begin{center}
\syntax{<\Tee term> ::= <\Tee factor>}
\end{center}
corresponds to
\begin{center}
\syntax{<integer term> ::= <integer factor>\\
<real term> ::= <real factor>\\
<long real term> ::= <long real factor>\\
<complex term> ::= <complex factor>\\
<long complex term> ::= <long complex factor>}
\end{center}
The production
\begin{center}
\syntax{<\TeeSub0 primary> ::= "long" <\TeeSub1 primary>}
\end{center}
corresponds to
\begin{center}
\syntax{<long real primary> ::= "long" <real primary>\\
<long integer primary> ::= "long" <integer primary> \\
<long complex primary> ::= "long" <complex primary>}
\end{center}
It is recognized that typographical entities exist of lower order than
basic symbols, called characters. The accepted characters are those of
the IBM System 360 EBCDIC code.
The symbol \Ri{comment} followed by any sequence of characters not
containing semicolons, followed by a semicolon, is called a comment.
A comment has no effect on the meaning of a program, and is ignored
during execution of the program. An identifier (cf. \ref{Identifiers})
immediately following the basic symbol \Ri{end} is also regarded as a
comment.
The execution of a program can be considered as a sequence of units of
action. The sequence of these units of action is defined as the
evaluation of expressions and the execution of statements as denoted
by the program. In the definition of the implemented language the
evaluation or execution of certain constructs is either (1) defined by
System 360 operations, e.g., real arithmetic, or (2) left undefined,
e.g., the order of evaluation of arithmetic primaries in expressions,
or (3) said to be \emph{not valid} or \emph{not defined}.
%------------------------------------------------------------------------------------------------------
\newpage
\section{Sets of Basic Symbols and Syntactic Entities}
\label{Sets of Basic Symbols and Syntactic Entities}
\subsection{Basic Symbols}
\index{syntax}{\<bar>}
\begin{quote}
\begin{synshorts}
`A' | `B' | `C' | `D' | `E' | `F' | `G' | `H' | `I' | `J' | `K' | `L' | `M' |
`N' | `O' | `P' | `Q' | `R' | `S' | `T' | `U' | `V' | `W' | `X' | `Y' | `Z' | `_' | \\
\\
`0' | `1' | `2' | `3' | `4' | `5' | `6' | `7' | `8' | `9' | \\
\\
"true" | "false" | `"' | "null" | `#' | `\'' | \\
"integer" | "real" | "complex" | "logical" | "bits" | "string" |
"reference" | "long real" | "long complex" | "array" |
"procedure" | "record" | \\
`,' | `;' | `:' | `.' | `(' | `)' | "begin" | "end" | "if" | "then" | "else" |
"case" | "of" | `+' | `-' | `*' | `/' | `**' | "div" | "rem" | "shr" | "shl" | "is" |
"abs" | "long" | "short" | "and" | "or" | `\NOT' | <bar> | `<=' | `\NE' | `<' |
`=' | `>' | `>=' | `::' |
`:=' | "goto" | "go to" | "for" | "step" | "until" | "do" | "while" |
"comment" | "value" | "result" | "assert" | "algol" | "fortran"
\end{synshorts}
\end{quote}
%All underlined words, which we call ``reserved words'',
All bold lowercase words, which we call ``reserved words'',
are represented by the same words in capital letters in an
actual program, with no intervening blanks.
Adjacent reserved words, identifiers (cf. \ref{Identifiers}) and
numbers must include no blanks and must be separated by at least one
blank space. Otherwise blanks have no meaning and can be used freely
to improve the readability of the program.
\subsection{Syntactic entities}
\label{Syntactic entities}
(See the \emph{Syntactic Entities} appendix on page \pageref{Syntactic Entities}.)
%------------------------------------------------------------------------------------------------------
\newpage
\section{Identifiers}
\label{Identifiers}
\grammarindent1.8in
\index{syntax}{\<\Tee array identifier>|textbf}
\index{syntax}{\<\Tee field identifier>|textbf}
\index{syntax}{\<\Tee function identifier>|textbf}
\index{syntax}{\<\Tee variable identifier>|textbf}
\index{syntax}{\<control identifier>|textbf}
\index{syntax}{\<identifier>|textbf}
\index{syntax}{\<identifier list>|textbf}
\index{syntax}{\<label identifier>|textbf}
\index{syntax}{\<procedure identifier>|textbf}
\index{syntax}{\<record class identifier>|textbf}
\begin{grammar}
<identifier> ::= <letter>
\alt <identifier> <letter>
\alt <identifier> <digit>
\alt <identifier> `_'
<\Tee variable identifier> ::= <identifier>
<\Tee array identifier> ::= <identifier>
<procedure identifier> ::= <identifier>
<\Tee function identifier> ::= <identifier>
<record class identifier> ::= <identifier>
<\Tee field identifier> ::= <identifier>
<label identifier> ::= <identifier>
<control identifier> ::= <identifier>
<letter> ::= `A' | `B' | `C' | `D' | `E' | `F' | `G'
\alt `H' | `I' | `J' | `K' | `L' | `M' | `N'
\alt `O' | `P' | `Q' | `R' | `S' | `T' | `U'
\alt `V' | `W' | `X' | `Y' | `Z'
<digit> ::= `0' | `1' | `2' | `3' | `4' | `5' | `6' | `7' | `8' | `9'
<identifier list> ::= <identifier>
\alt <identifier list> `,' <identifier>
\end{grammar}
\SemanticsUnnumbered
Variables, arrays, procedures, record classes and record fields are
said to be quantities. Identifiers serve to identify quantities, or
they stand as labels, formal parameters or control identifiers.
Identifiers have no inherent meaning, and can be chosen freely in the
reference language. In an actual program a reserved word cannot be
used as an identifier.
Every identifier used in a program must be defined. This is achieved
through
\begin{enumerate}[(a)]
\item declaration (cf. Section \ref{Declarations}), if the identifier
identifies a quantity. It is then said to denote that quantity and
to be a \Tee variable identifier, \Tee array identifier, \Tee
procedure identifier, \Tee function identifier, record class
identifier or \Tee field identifier, where the symbol \Tee
stands for the appropriate word reflecting the type of the declared
quantity;
\item a label definition (cf. \ref{Blocks}), if the identifier stands
as a label. It is then said to be a label identifier;
\item its occurrence in a formal parameter list (cf. \ref{Procedure Declarations}).
It is then said to be a formal parameter;
\item its occurrence following the symbol \Ri{for} in a for clause
(cf. \ref{Iterative Statements}). It is then said to be a control identifier;
\item its implicit declaration in the language. Standard procedures,
standard functions, and predefined variables (cf. \ref{Standard Procedures}
and \ref{Standard Functions and Predeclared Identifiers})
may be considered to be declared in a block containing the program.
\end{enumerate}
The recognition of the definition of a given identifier is determined
by the following rules:
\begin{enumerate}[{Step} 1.]
\item If the identifier is defined by a declaration of a quantity or
by its standing as a label within the smallest block (cf.
\ref{Blocks}) embracing a given occurrence of that identifier, then
it denotes that quantity or label. A statement following a procedure
heading (cf. \ref{Procedure Declarations}) or a \R{for} clause (cf.
\ref{Iterative Statements}) is considered to be a block.
\item Otherwise, if that block is a procedure body and if the given
identifier is identical with a formal parameter in the associated
procedure heading, then it stands as that formal parameter.
\item Otherwise, if that block is preceded by a \R{for} clause
and the identifier is identical to the control identifier of that
\R{for} clause, then it stands as that control identifier.
\end{enumerate}
Otherwise, these rules are applied considering the smallest block
embracing the block which has previously been considered.
If either step 1 or step 2 could lead to more than one definition,
then the identification is undefined.
The scope of a quantity, a label, a formal parameter, or a control
identifier is the set of statements in which occurrences of an
identifier may refer by the above rules to the definition of that
quantity, label, formal parameter or control identifier.
\Examples
\begin{AlgolWExample}
I
PERSON
ELDERSIBLING
X15, X20, X25
NEW_PAGE
\end{AlgolWExample}
%------------------------------------------------------------------------------------------------------
\newpage
\section{Values and Types}
\label{Values and Types}
Constants and variables (cf. \ref{Variables}) are said to possess a
value. The value of a constant is determined by the denotation of the
constant. In the language, all constants (except references) have a
reference denotation (cf. \ref{Numbers} -- \ref{Strings}). The value
of a variable is the one most recently assigned to that variable. A
value is (recursively) defined as either a simple value or a
structured value (an ordered set of one or more values). Every value
is said to be of a certain type.
\index{general}{Data types} The following types of simple values are distinguished:
\begin{quote}
\begin{tabular}[t]{lp{3.5in}}
\Ti{integer} & the value is a 32 bit integer, \\
\Ti{real} & the value is a 32 bit floating point number, \\
\Ti{long real} & the value is a 64 bit floating point number, \\
\Ti{complex} & the value is a complex number composed of two numbers of type \T{real}, \\
\Ti{long complex} & the value is a complex number composed of two \T{long real} numbers, \\
\Ti{logical} & the value is a logical value, \\
\Ti{bits} & the value is a linear sequence of 32 bits, \\
\Ti{string} & the value is a linear sequence of at most 256 characters, \\
\Ti{reference} & the value is a reference to a record.
\end{tabular}
\end{quote}
The following types of structured values are distinguished:
\begin{quote}
\begin{tabular}[t]{lp{3.5in}}
\Ti{array} & the value is an ordered set of values, all of identical simple type, \\
\Ti{record} & the value is an ordered set of simple values.
\end{tabular}
\end{quote}
A procedure may yield a value, in which case it is said to be a
function procedure, or it may not yield a value, in which case it is
called a proper procedure. The value of a function procedure is
defined as the value which results from the execution of the procedure
body (cf. \ref{Function Designators, Semantics}).
Subsequently, the reference denotation of constants is defined. The
reference denotation of any constant consists of a sequence of
characters. This, however, does not imply that the value of the
denoted constant is a sequence of characters, nor that it has the
properties of a sequence of characters, except, of course, in the case
of strings.
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\newpage
\subsection{Numbers}
\label{Numbers}
\Syntax
\grammarindent1.8in
\index{syntax}{\<\Tee constant>|textbf}
\index{syntax}{\<integer constant>|textbf}
\index{syntax}{\<real constant>|textbf}
\index{syntax}{\<long real constant>|textbf}
\index{syntax}{\<complex constant>|textbf}
\index{syntax}{\<long complex constant>|textbf}
\begin{grammar}
<long complex constant> ::= <complex constant> `L'
<complex constant> ::= <imaginary constant>
<imaginary constant> ::= <real constant> `I'
\alt <integer constant> `I'
<long real constant> ::= <real constant> `L'
\alt <integer constant> `L'
<real constant> ::=
<unscaled real>
\alt <unscaled real> <scale factor>
\alt <integer constant> <scale factor>
\alt <scale factor>
<unscaled real> ::=
<integer constant> `.' <integer constant>
\alt `.' <integer constant>
\alt <integer constant> `.'
<scale factor> ::=
`'' <integer constant>
\alt `'' <sign> <integer constant>
<integer constant> ::=
<digit>
\alt <integer constant> <digit>
<sign> ::= `+' | `-'
\end{grammar}
(Note: a long complex constant may have the \A!I! and \A!L! in either
order in a program, but they must be in the order \A!IL! on data
cards.)
\Semantics
Numbers are interpreted according to the conventional decimal
notation. A scale factor denotes an integral power of 10 which is
multiplied by the unscaled real or integer number preceding it. Each
number has a uniquely defined type. (Note that all \<\Tee constant>s are
unsigned.)
\Examples
\begin{AlgolWExample}
1 05 11
0100 1'3 0.671
3.1416 6.02486'+23 1IL
2.718281828459045235360287L 2.3'-6
\end{AlgolWExample}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\newpage
\subsection{Logical Values}
\label{Logical Values}
\Syntax
\IndexReservedWord{true}
\IndexReservedWord{false}
\IndexType{logical}
\grammarindent0pt
\index{syntax}{\<\Tee constant>|textbf}
\index{syntax}{\<logical constant>|textbf}
\begin{grammar}
<logical constant> ::= "true" | "false"
\end{grammar}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\subsection{Bit Sequences}
\label{Bit Sequences}
\Syntax
\grammarindent1.2in
\index{syntax}{\<\Tee constant>|textbf}
\index{syntax}{\<bit constant>|textbf}
\begin{grammar}
<bit constant> ::=
`#' <hex digit>
\alt <bit constant> <hex digit>
<hex digit> ::=
`0' | `1' | `2' | `3' | `4' | `5' | `6' | `7'
\alt `8' | `9' | `A' | `B' | `C' | `D' | `E' | `F'
\end{grammar}
\noindent Note that \syntax{`A' | \ldots | `F'} corresponds to $10_{10} | ... | 15_{10}$.
\Semantics
The number of bits in a bit sequence is 32, or 8 hex digits. The bit
sequence is always represented by a 32 bit word with the specified bit
sequence right justified in the word and zeros filled in on the left.
\Examples
\begin{AlgolWExample}
#4F `{\rm= 0000 0000 0000 0000 0000 0000 0100 1111}`
#9 `{\rm= 0000 0000 0000 0000 0000 0000 0000 1001}`
\end{AlgolWExample}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\subsection{Strings}
\label{Strings}
\Syntax
\grammarindent1.4in
\index{syntax}{\<\Tee constant>|textbf}
\index{syntax}{\<string constant>|textbf}
\begin{grammar}
<string constant> ::= <string>
<string> ::= `"' <open string> `"'
<open string> ::= <character> | <open string> <character>
\end{grammar}
\Semantics
Strings consist of any sequence of (at least one and at most 256)
characters accepted by the System 360 enclosed by \lit{"}, the string
quote. If the string quote appears in the sequence of characters it
must be immediately followed by a second string quote which is then
ignored. The number of characters in a string is said to be the
length of the string. The characters accepted by the IBM system 360
are listed in Appendix \ref{Character Encodings}.
\Example
\begin{AlgolWExample}
"JOHN"
"""" `{\rm This is the string of length 1 consisting of the string quote.}`
\end{AlgolWExample}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\newpage
\subsection{References}
\label{References}
\Syntax
\IndexReservedWord{null}
\grammarindent0pt
\index{syntax}{\<\Tee constant>|textbf}
\index{syntax}{\<reference constant>|textbf}
\begin{grammar}
<reference constant> ::= "null"
\end{grammar}
\Semantics
The reference value \Ri{null} fails to designate a record; if a
reference expression occurring in a field designator (cf.~\ref{Variables})
has this value, then the field designator is undefined.
%------------------------------------------------------------------------------------------------------
\newpage
\section{Declarations}
\label{Declarations}
Declarations serve to associate identifiers with the quantities used
in the program, to attribute certain permanent properties to these
quantities (i.e:. type, structure), and to determine their scope. The
quantities declared by declarations are simple variables, arrays,
procedures and record classes.
Upon exit from a block, all quantities declared or defined within that
block lose their value and significance (cf. \ref{Blocks, Semantics}
and \ref{Goto Statements, Semantics}).
\SyntaxUnnumbered
\grammarindent1.1in
\index{syntax}{\<declaration>|textbf}
\index{syntax}{\<\Tee array declaration>}
\index{syntax}{\<procedure declaration>}
\index{syntax}{\<record class declaration>}
\index{syntax}{\<simple variable declaration>}
\begin{grammar}
<declaration> ::= <simple variable declaration>
\alt <\Tee array declaration>
\alt <procedure declaration>
\alt <record class declaration>
\end{grammar}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\subsection{Simple Variable Declarations}
\label{Simple Variable Declarations}
\IndexReservedWord{integer}
\IndexReservedWord{real}
\IndexReservedWord{long real}
\IndexReservedWord{complex}
\IndexReservedWord{long complex}
\IndexReservedWord{logical}
\IndexReservedWord{bits}
\IndexReservedWord{string}
\IndexReservedWord{reference}
\Syntax
\grammarindent1.1in
\index{syntax}{\<simple type>|textbf}
\index{syntax}{\<simple variable declaration>|textbf}
\index{syntax}{\<integer constant>}
\index{syntax}{\<identifier list>}
\index{syntax}{\<record class identifier>}
\begin{grammar}
<simple variable declaration> ::= <simple type> <identifier list>
<simple type> ::=
"integer" | "real" | "long real" | "complex"
\alt "long complex" | "logical" |
\alt "bits" | "bits" `(' `32' `)'
\alt "string" | "string" `(' <integer constant> `)'
\alt "reference" `(' <record class identifier list> `)'
<record class identifier list> ::=
<record class identifier>
\alt <record class identifier list>`,' <record class identifier>
\end{grammar}
\Semantics
Each identifier of the identifier list is associated with a variable
which is declared to be of the indicated type. A variable is called a
simple variable, if its value is simple (cf. Section
\ref{Declarations}). If a variable is declared to be of a certain
type, then this implies that only values which are assignment
compatible with this type (cf. \ref{Assignment Statements, Semantics})
can be assigned to it. It is understood that the value of a variable
is equal to the value of the expression most recently assigned to it.
A variable of type \Ti{bits} is always of length 32 whether or not
the declaration specification is included.
A variable of type \Ti{string} has a length equal to the unsigned
integer in the declaration specification. If the simple type is given
only as \A!string!, the length of the variable is 16 characters.
A variable of type
\Ti{reference} may refer only to records of the record classes whose
identifiers appear in the record class identifier list of the
reference declaration specification.
\newpage
\Example
\begin{AlgolWExample}
integer I, J, K, M, N
real X, Y, Z
long complex C
logical L
bits G, H
string (10) S, T
reference (PERSON) JACK, JILL
\end{AlgolWExample}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\subsection{Array Declarations}
\label{Array Declarations}
\IndexReservedWord{array}
\Syntax
\grammarindent1.6in
\index{syntax}{\<\Tee array declaration>|textbf}
\index{syntax}{\<\Tee expression>}
\index{syntax}{\<identifier list>}
\index{syntax}{\<simple type>}
\begin{grammar}
<\Tee array declaration> ::= <simple type> "array" <identifier list> \\
`(' <bound pair list> `)'
<bound pair list> ::= <bound pair>
\alt <bound pair list> `,' <bound pair>
<bound pair> ::= <lower bound> `::' <upper bound>
<lower bound> ::= <integer expression>
<upper bound> ::= <integer expression>
\end{grammar}
\Semantics
Each identifier of the identifier list of an array declaration is
associated with a variable which is declared to be of type \T{array}.
A variable of type \T{array} is an ordered set of variables whose type is
the simple type preceding the symbol array. The dimension of the array
is the number of entries in the bound pair list.
Every element of an array is identified by a list of indices. The
indices are the integers between and including the values of the
lower bound and the upper bound. Every expression in the bound pair list is
evaluated exactly once upon entry to the block in which the
declaration occurs. The bound pair expressions can depend only on
variables and procedures global to the block in which the declaration
occurs. In order to be valid, for every bound pair, the value of the
upper bound must not be less than the value of the lower bound.
\Example
\begin{AlgolWExample}
integer array H(1::100)
real array A, B(1::M, 1::N)
string (12) array STREET, TOWN, CITY (J::K + 1)
\end{AlgolWExample}
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\newpage
\subsection{Procedure Declarations}
\label{Procedure Declarations}
\IndexReservedWord{procedure}
\label{Procedure Declarations, Syntax}
\Syntax
\grammarindent2.4in
\index{syntax}{\<\Tee function procedure declaration>|textbf}
\index{syntax}{\<formal parameter list>|textbf}
\index{syntax}{\<procedure heading>|textbf}
\index{syntax}{\<proper procedure declaration>|textbf}
\index{syntax}{\<\Tee expression>}
\index{syntax}{\<block body>}
\index{syntax}{\<external reference>}
\index{syntax}{\<formal array parameter>}
\index{syntax}{\<formal type>}
\index{syntax}{\<identifier>}
\index{syntax}{\<identifier list>}
\index{syntax}{\<simple type>}
\index{syntax}{\<statement>}
\begin{grammar}
<procedure declaration> ::=
<proper procedure declaration>
\alt <\Tee function procedure declaration>
<proper procedure declaration> ::=
"procedure" <procedure heading> `;' \\
<proper procedure body>
<\Tee function procedure declaration> ::=
<simple type> \\
"procedure" <procedure heading> `;' \\
<\Tee function procedure body>
<proper procedure body> ::=
<statement>
\alt <external reference>
<\Tee function procedure body> ::=
<\Tee expression>
\alt <block body> <\Tee expression> "end"
\alt <external reference>
<procedure heading> ::=
<identifier>
\alt <identifier> \\
`(' <formal parameter list> `)'
<formal parameter list> ::=
<formal parameter segment>
\alt <formal parameter list> `;' \\
<formal parameter segment>
<formal parameter segment> ::=
<formal type> <identifier list>
\alt <formal array parameter>
\end{grammar}
\IndexReservedWord{value}
\IndexReservedWord{result}
\index{syntax}{\<formal type>|textbf}
\index{syntax}{\<identifier list>}
\index{syntax}{\<simple type>}
\begin{grammar}
<formal type> ::=
<simple type>
\alt <simple type> "value"
\alt <simple type> "result"
\alt <simple type> "value" "result"
\alt <simple type> "procedure"
\alt "procedure"
<formal array parameter> ::=
<simple type> "array" <identifier list> \\
`(' <dimension specification> `)'
<dimension specification> ::=
`*'
\alt <dimension specification> `,' `*'
\end{grammar}
\IndexReservedWord{fortran}
\IndexReservedWord{algol}
\index{syntax}{\<external reference>|textbf}
\index{syntax}{\<string constant>}
\begin{grammar}
<external reference> ::=
"fortran" <string constant>
\alt "algol" <string constant>
\end{grammar}
\Semantics
\setcounter{paragraph}{0}
\label{Procedure Declarations, Semantics}
A procedure declaration associates the procedure body with the
identifier immediately following the symbol \Ri{procedure}. The
principal part of the procedure declaration is the procedure body.
Other parts of the block in whose heading the procedure is declared
can then cause this procedure body to be executed or evaluated. A
proper procedure is activated by a procedure statement (cf.
\ref{Procedure Statements}), a function procedure by a function
designator (cf. \ref{Function Designators}). Associated with the
procedure body is a heading containing the procedure identifier and
possibly a list of formal parameters.
\paragraph{Type specification of formal parameters.} All formal
parameters of a formal parameter segment are of the same indicated
type. The type must be such that the replacement of the formal
parameter by the actual parameter of this specified type leads to
correct \ALGOLW\ expressions and statements
(cf. \ref{Procedure Statements, Semantics}).
\paragraph{} \label{Value/Result Semantics}The effect of the symbols
\R{value} and \R{result} appearing in a formal type is explained by
the following rule, which is applied to the procedure body before the
procedure is invoked:
\begin{enumerate}
\item The procedure body is enclosed by the symbols \R{begin} and