-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathACK.7
2090 lines (2090 loc) · 63.4 KB
/
ACK.7
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
.TH ACK 7
.SH NAME
ACK \- Additional information on the Amsterdam Compiler Kit compilers
.SH DESCRIPTION
.de SP
.if t .sp 0.4
.if n .sp
..
.de XS
.SP
.in +.5i
.nf
..
.de XE
.fi
.in -.5i
.SP
..
.de NS
.PP
.B ANS\ \\$1
..
.de UX
\s-2UNIX\s+2
..
.de MX
.if n MINIX 3
.if t \s-1MINIX 3\s-1
..
.if n .ds Mx MINIX 3
.if t .ds Mx \s-1MINIX 3\s-1
.if n .ds Mp Minix-PC
.if t .ds Mx \s-2MINIX-PC\s+2
.if n .ds Mv Minix-vmd
.if t .ds Mv \s-1MINIX 3\s-1-vmd
.if n .ds Cw \fR
.if t .ds Cw \fC
.de CW
.if n .ft R
.if t .ft C
..
.\"
These are the details on the Amsterdam Compiler Kit compilers for the
languages C, Modula-2, and Pascal. The design decisions that were made
where the respective standards allowed or mandated this, and the extensions
that were implemented.
.SH "ANSI C REPORT"
This section specifies the implementation-defined behavior of the ANSI-C
compiler as required by ANS X3.159-1989.
.NS A.6.3.1
.IP \(bu
Diagnostics are placed on the standard error output. They have the
following specification:
.XS
"<file>", line <nr>: [(<class>)] <diagnostic>
.XE
There are three classes of diagnostics: 'error', 'strict' and 'warning'.
When the class is 'error', the class specification is absent.
The class 'strict' is used for violations of the standard which are
not severe enough to stop compilation, for example the occurrence
of non white-space after an '#endif' preprocessing
directive. The class 'warning' is used for legal but dubious
constructions, for example the declaration of a structure-tag in a
parameter type list.
.NS A.6.3.2
.IP \(bu
The function 'main' can have zero or two parameters. When it has two
parameters, the first parameter is an integer specifying the number of
arguments on the command line (including the command). The second
parameter is a pointer to an array of pointers to the arguments
(as strings).
.IP \(bu
Interactive devices are terminals.
.NS A.6.3.3
.IP \(bu
The number of significant characters is 64.
Corresponding upper-case and lower-case letters are different.
.NS A.6.3.4
.IP \(bu
The compiler assumes ASCII-characters in both the source and execution
character set.
.IP \(bu
There are no multibyte characters.
.IP \(bu
There are 8 bits in a character.
.IP \(bu
Character constants that cannot be represented in 8 bits
are truncated.
.IP \(bu
Character constants that are more than 1 character wide will have the
first character specified in the least significant byte.
.IP \(bu
The only supported locale is 'C'.
.IP \(bu
A plain 'char' has the same range of values as 'signed char'.
.NS A.6.3.5
.IP \(bu
The i80x86 and 68000 both have a two's complement binary-number system.
Shorts are 2 bytes; ints are 2 bytes under 16-bits \*(Mp and 68000 \*(Mx, 4
bytes under 32-bits \*(Mp; longs occupy 4 bytes.
.IP \(bu
Converting an integer to a shorter signed integer is implemented by
ignoring the high-order byte(s) of the former.
Converting a unsigned integer to a signed integer of the same type is
only done in administration. This means that the bit-pattern remains
unchanged.
.IP \(bu
The result of bitwise operations on signed integers are what can be
expected on a two's complement machine.
.IP \(bu
When either operand is negative, the result of the / operator is the
largest integer less than or equal to the algebraic quotient.
The sign of the remainder on integer division is the sign of the
enumerator.
.IP \(bu
The right-shift of a negative value is negative.
.NS A.6.3.6
.IP \(bu
The compiler uses IEEE format for floating-point numbers.
High-precision floating-point is used for constant folding.
.IP \(bu
Truncation is done to the nearest floating-point number that can
be represented.
.NS A.6.3.7
.IP \(bu
The type of the sizeof-operator (also known as size_t) is 'unsigned int'.
.IP \(bu
Casting an integer to a pointer or vice versa has no effect in
bit-pattern when the sizes are equal. Otherwise the value will be
truncated or zero-extended (depending on the direction of the
conversion and the relative sizes).
.IP \(bu
The type of a 'ptrdiff_t' is 'int' on \*(Mp, and 'long' on the 68000
\*(Mx versions.
.NS A.6.3.8
.IP \(bu
Since the front end has only limited control over the registers, it can
only make it more likely that variables that are declared as
registers also end up in registers. The only things that can possibly be
put into registers are plain ints and pointers.
.NS A.6.3.9
.IP \(bu
When a member of a union object is accessed using a member of a
different type, the resulting value will usually be garbage. The
compiler makes no effort to catch these errors.
.IP \(bu
The alignment of types under 16-bit \*(Mp is 1 byte for characters and 2
bytes for all other types. Under other MINIX 3 versions 'int' and smaller
types are aligned to a multiple of their size, bigger scalar types are
aligned like 'int'. Arrays have the same alignment as their elements;
structs and unions are aligned like their field with the worst alignment.
.IP \(bu
A plain 'int' bit-field is taken as a 'signed int'. This means that
a field with a size 1 bit-field can only store the values 0 and \(mi1.
.IP \(bu
In bit-fields, high-order bits are allocated first.
.IP \(bu
An enum has the same size as a plain 'int'.
.NS A.6.3.10
.IP \(bu
An access to a volatile object is either a load or a store. Just
mentioning a volatile variable is not enough.
E.g. the statement 'x;' where x is declared volatile, does not
constitute an access. When a volatile object should be read, but its
value ignored, 'if (x);' should do the trick.
.NS A.6.3.11
.IP \(bu
There is no fixed limit on the number of declarators that may modify an
arithmetic, structure or union type, although specifying too many may
cause the compiler to run out of memory.
.NS A.6.3.12
.IP \(bu
The maximum number of cases in a switch-statement is in the order of
1e9, although the compiler may run out of memory somewhat earlier.
.NS A.6.3.13
.IP \(bu
Since both the preprocessor and the compiler assume ASCII-characters,
a single character constant in a conditional-inclusion directive
matches the same value in the execution character set.
.IP \(bu
The preprocessor recognizes \fI\(enI...\fR command-line options. The
directories thus specified are searched first. After that, /usr/include is
visited.
.IP \(bu
Quoted names are first looked for in the directory in which the file
which does the include resides.
.IP \(bu
The characters in a h- or q- char-sequence are taken to be
.UX
paths.
.IP \(bu
Neither the front-end nor the preprocessor know any pragmas.
.IP \(bu
Since the compiler runs on
.MX ,
_\^_DATE_\^_ and _\^_TIME_\^_ will always be
defined.
.NS A.6.3.14
.IP \(bu
NULL is defined as ((void *)0). This in order to detect dubious
constructions like 'int x = NULL;'.
.IP \(bu
The diagnostic printed by 'assert' is as follows:
.XS
Assertion "<expr>" failed, file "<file>", line <line>
.XE
where <expr> is the argument to the assert macro, printed as string.
(the <file> and <line> should be clear)
.IP \(bu
The sets for character test macros for the C locale are as follows:
.XS
.ta +\w'isalnum 'u
\fBName Set\fR
\fIisalnum\fR 0-9A-Za-z
\fIisalpha\fR A-Za-z
\fIiscntrl\fR \e000-\e037\e177
\fIislower\fR a-z
\fIisupper\fR A-Z
\fIisprint\fR \e040-\e176
.DT
.XE
As an addition, there is an \fIisascii\fR macro, which tests whether a character
is an ASCII character. Characters in the range from \e000 to \e177 are ASCII
characters.
.IP \(bu
The behavior of ACK mathematical functions on domain error is as follows:
.XS
.ta +\w'log10 'u
\fBName Returns\fR
\fIasin\fR 0.0
\fIacos\fR 0.0
\fIatan2\fR 0.0
\fIfmod\fR 0.0
\fIlog\fR \(miHUGE_VAL
\fIlog10\fR \(miHUGE_VAL
\fIpow\fR 0.0
\fIsqrt\fR 0.0
.DT
.XE
\*(Mv uses the BSD4.4 C library and the Sun FDLIBM C math library instead
of the ACK library. See
.BR math (3)
for details about the math functions. The \*(Mv libraries offer at
least the same functionality as the ACK library.
.IP \(bu
Underflow range errors do not cause \fIerrno\fR to be set.
.IP \(bu
The function \fIfmod\fR returns 0.0 and sets \fIerrno\fR to EDOM when the second
argument is 0.0.
.IP \(bu
The set of signals for the \fIsignal\fR function is as described by
.BR sigaction (2).
.IP \(bu
A text-stream need not end in a new-line character.
.IP \(bu
White space characters before a new-line appear when read in.
.IP \(bu
There may be any number of null characters appended to a binary
stream.
.IP \(bu
The file position indicator of an append mode stream is initially
positioned at the beginning of the file.
.IP \(bu
A write on a text stream does not cause the associated file to be
truncated beyond that point.
.IP \(bu
The buffering intended by the standard is fully supported.
.IP \(bu
A zero-length file actually exists.
.IP \(bu
A file name can consist of any character, except for the '\e0' and
the '/'.
.IP \(bu
A file can be open multiple times.
.IP \(bu
When a \fIremove\fR is done on an open file, reading and writing behave
just as can be expected from a non-removed file. When the associated
stream is closed, however, all written data will be lost.
.IP \(bu
When a file exists prior to a call to \fIrename\fR, it is removed.
.IP \(bu
The %p conversion in \fIfprintf\fR has the same effect as %#x on \*(Mp and
%#lx on the 68000 versions of \*(Mx.
.IP \(bu
The %p conversion in \fIfscanf\fR has the same effect as %x on \*(Mp and
%lx on the 68000 versions of \*(Mx.
.IP \(bu
A \(mi character that is neither the first nor the last character in the
scanlist for %[ conversion is taken to be a range indicator. When the
first character has a higher ASCII-value than the second, the \(mi will
just be put into the scanlist.
.IP \(bu
The value of \fIerrno\fR when \fIfgetpos\fR or \fIftell\fR failed is that of \fIlseek\fR.
This means:
.XS
.ta +\w'ESPIPE 'u +\w'\- 'u
EBADF \- when the stream is not valid
ESPIPE \- when fildes is associated with a pipe
EINVAL \- the resulting file pointer would be negative
.XE
.IP \(bu
The messages generated by \fIperror\fR depend on the value of \fIerrno\fR.
The mapping of errors to strings is done by \fIstrerror\fR.
.IP \(bu
When the requested size is zero, \fImalloc\fR, \fIcalloc\fR and \fIrealloc\fR
return a null-pointer under \*(Mx. Under \*(Mv a unique non-null pointer is
returned.
.IP \(bu
When \fIabort\fR is called, output buffers will be flushed. Temporary files
(made with the \fItmpfile\fR function) will have disappeared when SIGABRT
is not caught or ignored.
.IP \(bu
The \fIexit\fR function returns the low-order eight bits of its argument
to the environment.
.IP \(bu
The predefined environment names are controlled by the user.
Setting environment variables is done through the \fIputenv\fR function.
This function accepts a pointer to char as its argument.
To set, for example, the environment variable TERM to a230 one writes
.XS
static char terminal[] = "TERM=a230";
putenv(terminal);
.XE
The argument to \fIputenv\fR is stored in an internal table, so malloc'ed
strings cannot be freed until another call to \fIputenv\fR (which sets the
same environment variable) is made. The argument to \fIputenv\fR must be
writable, which means that officially, the argument cannot be a string
constant.
The function returns 1 if it fails, 0 otherwise.
.LP
.IP \(bu
The argument to \fIsystem\fR is passed as argument to \fI/bin/sh \(enc\fR.
.IP \(bu
The strings returned by \fIstrerror\fR depend on \fIerrno\fR. They are
listed in
.BR intro (2).
Everything else causes \fIstrerror\fR to return "unknown error" under \*(Mx,
or the result of sprintf("Error %d", errno) under \*(Mv.
.IP \(bu
The local time zone is per default GMT. This can be
changed through the TZ environment variable, e.g. TZ=EST6.
See
.BR TZ (5).
.IP \(bu
The \fIclock\fR function returns the number of ticks since process
startup.
.SS References
.IP [1]
ANS X3.159-1989
.ft I
American National Standard for Information Systems -
Programming Language C
.ft R
.SH "THE MINIX MODULA-2 COMPILER"
This section describes the implementation-specific features of the
.MX
Modula-2 compiler.
It is not intended to teach Modula-2 programming.
For a description of the Modula-2 language,
the reader is referred to [1].
.SS "The language implemented"
.PP
This paragraph discusses the deviations from the Modula-2 language as described
in the 'Report on The Programming Language Modula-2',
as it appeared in [1],
from now on referred to as 'the Report'.
Also,
the Report sometimes leaves room for interpretation.
The section numbers
mentioned are the section numbers of the Report.
.SS "Syntax (section 2)"
.PP
The syntax recognized is that of the Report,
with some extensions to
also recognize the syntax of an earlier definition,
given in [2].
Only one compilation unit per file is accepted.
.SS "Vocabulary and Representation (section 3)"
.PP
The input '\*(Cw10..\fR' is parsed as two tokens: '\*(Cw10\fR' and '\*(Cw..\fR'.
.PP
The empty string \*(Cw""\fR has type
.XS
.CW
ARRAY [0 .. 0] OF CHAR
.ft P
.XE
and contains one character: \*(Cw0C\fR.
.PP
When the text of a comment starts with a '\*(Cw$\fR',
it may be a pragma.
Currently,
the following pragmas exist:
.nf
.SP
.CW
(*$F (F stands for Foreign) *)
(*$R[+|-] (Runtime checks, on or off, default on) *)
(*$A[+|-] (Array bound checks, on or off, default off) *)
(*$U (Allow for underscores within identifiers) *)
.ft P
.SP
.fi
The Foreign pragma is only meaningful in a \*(CwDEFINITION MODULE\fR,
and indicates that this
\*(CwDEFINITION MODULE\fR describes an interface to a module written in another
language (for instance C or Pascal).
Runtime checks that can be disabled are:
range checks,
\*(CwCARDINAL\fR overflow checks,
checks when assigning a \*(CwCARDINAL\fR to an \*(CwINTEGER\fR and vice versa,
and checks that \*(CwFOR\fR-loop control-variables are not changed
in the body of the loop.
Array bound checks can be enabled,
because many EM implementations do not
implement the array bound checking of the EM array instructions.
When enabled,
the compiler generates a check before generating an
EM array instruction.
Even when underscores are enabled,
they still may not start an identifier.
.PP
Constants of type \*(CwLONGINT\fR are integers with a suffix letter \*(CwD\fR
(for instance \*(Cw1987D\fR).
Constants of type \*(CwLONGREAL\fR have suffix \*(CwD\fR if a scale factor is missing,
or have \*(CwD\fR in place of \*(CwE\fR in the scale factor (f.i. \*(Cw1.0D\fR,
\*(Cw0.314D1\fR).
This addition was made,
because there was no way to indicate long constants,
and also because the addition was made in Wirth's newest Modula-2 compiler.
.SS "Declarations and scope rules (section 4)"
.PP
Standard identifiers are predeclared,
and valid in all
parts of a program.
They are called \fIpervasive\fR.
Unfortunately,
the Report does not state how this pervasiveness is accomplished.
However,
page 87 of [1] states: 'Standard identifiers are automatically
imported into all modules'.
Our implementation therefore allows
redeclarations of standard identifiers within procedures,
but not within
modules.
.SS "Constant expressions (section 5)"
.PP
Each operand of a constant expression must be a constant:
a string,
a number,
a set,
an enumeration literal,
a qualifier denoting a
constant expression,
a type transfer with a constant argument,
or one of the standard procedures
\*(CwABS\fR,
\*(CwCAP\fR,
\*(CwCHR\fR,
\*(CwLONG\fR,
\*(CwMAX\fR,
\*(CwMIN\fR,
\*(CwODD\fR,
\*(CwORD\fR,
\*(CwSIZE\fR,
\*(CwSHORT\fR,
\*(CwTSIZE\fR,
or \*(CwVAL\fR,
with constant argument(s);
\*(CwTSIZE\fR and \*(CwSIZE\fR may also have a variable as argument.
.SS "Type declarations (section 6)"
.LP
.ft I
1. Basic types (section 6.1)
.PP
The type \*(CwCHAR\fR includes the ASCII character set as a subset.
Values range from
\*(Cw0C\fR to \*(Cw377C\fR,
not from \*(Cw0C\fR to \*(Cw177C\fR.
.LP
.ft I
2. Enumerations (section 6.2)
.PP
The maximum number of enumeration literals in any one enumeration type
is \*(CwMAX(INTEGER)\fR.
.LP
.ft I
3. Record types (section 6.5)
.PP
The syntax of variant sections in [1] is different from the one in [2].
Our implementation recognizes both,
giving a warning for the older one.
.LP
.ft I
4. Set types (section 6.6)
.PP
The only limitation imposed by the compiler is that the base type of the
set must be a subrange type,
an enumeration type,
\*(CwCHAR\fR,
or \*(CwBOOLEAN\fR.
So,
the lower bound may be negative.
However,
if a negative lower bound is used,
the compiler gives a warning of the \fIrestricted\fR class.
.PP
The standard type \*(CwBITSET\fR is defined as
.XS
.CW
TYPE BITSET = SET OF [0 .. 8*SIZE(INTEGER)-1];
.ft P
.XE
.SS "Expressions (section 8)"
.LP
.ft I
1. Operators (section 8.2)
.LP
.ft I
1.1. Arithmetic operators (section 8.2.1)
.PP
The Report does not specify the priority of the unary
operators \*(Cw+\fR or \*(Cw-\fR:
It does not specify whether
.XS
.CW
- 1 + 1
.ft P
.XE
means
.XS
.CW
- (1 + 1)
.ft P
.XE
or
.XS
.CW
(-1) + 1
.ft P
.XE
The
.MX
Modula-2 compiler implements the second alternative.
.SS "Statements (section 9)"
.LP
.ft I
1. Assignments (section 9.1)
.PP
The Report does not define the evaluation order in an assignment.
Our compiler certainly chooses an evaluation order,
but it is explicitly left undefined.
Therefore,
programs that depend on it may cease to work later.
.PP
The types \*(CwINTEGER\fR and \*(CwCARDINAL\fR are assignment-compatible with
\*(CwLONGINT\fR,
and \*(CwREAL\fR is assignment-compatible with \*(CwLONGREAL\fR.
.LP
.ft I
2. Case statements (section 9.5)
.PP
The size of the type of the case-expression must be less than or equal to
the word-size.
.PP
The Report does not specify what happens if the value of the case-expression
does not occur as a label of any case,
and there is no \*(CwELSE\fR-part.
In our implementation,
this results in a runtime error.
.LP
.ft I
3. For statements (section 9.8)
.PP
The Report does not specify the legal types for a control variable.
Our implementation allows the basic types (except \*(CwREAL\fR),
enumeration types,
and subranges.
A runtime warning is generated when the value of the control variable
is changed by the statement sequence that forms the body of the loop,
unless runtime checking is disabled.
.LP
.ft I
4. Return and exit statements (section 9.11)
.PP
The Report does not specify which result-types are legal.
Our implementation allows any result type.
.SS "Procedure declarations (section 10)"
.PP
Function procedures must exit through a RETURN statement,
or a runtime error occurs.
.LP
.ft I
1. Standard procedures (section 10.2)
.PP
Our implementation supports \*(CwNEW\fR and \*(CwDISPOSE\fR
for backwards compatibility,
but issues warnings for their use.
.PP
Also,
some new standard procedures were added,
similar to the new standard procedures in Wirth's newest compiler:
.IP \-
\*(CwLONG\fR converts an argument of type \*(CwINTEGER\fR or \*(CwREAL\fR to the
types \*(CwLONGINT\fR or \*(CwLONGREAL\fR.
.IP \-
\*(CwSHORT\fR performs the inverse transformation,
without range checks.
.IP \-
\*(CwFLOATD\fR is analogous to \*(CwFLOAT\fR,
but yields a result of type
\*(CwLONGREAL\fR.
.IP \-
\*(CwTRUNCD\fR is analogous to \*(CwTRUNC\fR,
but yields a result of type
\*(CwLONGINT\fR.
.SS "System-dependent facilities (section 12)"
.PP
The type \*(CwBYTE\fR is added to the \*(CwSYSTEM\fR module.
It occupies a storage unit of 8 bits.
\*(CwARRAY OF BYTE\fR has a similar effect to \*(CwARRAY OF WORD\fR,
but is safer.
In some obscure cases the \*(CwARRAY OF WORD\fR mechanism does not quite
work properly.
.PP
The procedure \*(CwIOTRANSFER\fR is not implemented.
.SS "Backwards compatibility"
.PP
Besides recognizing the language as described in [1],
the compiler recognizes most of the language described in [2],
for backwards compatibility.
It warns the user for old-fashioned
constructions (constructions that [1] does not allow).
If the \fI\(en3\fR option is passed to \fIm2\fR,
this backwards compatibility feature is disabled.
.SS "Compile time errors"
.PP
The compile time error messages are intended to be self-explanatory,
and not listed here.
The compiler also sometimes issues warnings,
recognizable by a warning-classification between parentheses.
There are 3 classifications:
.IP "(old-fashioned use)"
.br
These warnings are given on constructions that are not allowed by [1],
but are allowed by [2].
.IP (strict)
.br
These warnings are given on constructions that are supported by the
.MX
Modula-2 compiler,
but might not be supported by others.
Examples: functions returning structured types,
SET types of subranges with
negative lower bound.
.IP (warning)
.br
The other warnings,
such as warnings about variables that are never assigned,
never used,
etc.
.SS "Runtime errors"
.PP
The \fITraps\fR module enables the user to install his own runtime
error handler.
The default one just displays what happened and exits.
Basically,
a trap handler is just a procedure that takes an INTEGER as
parameter.
The INTEGER is the trap number.
This INTEGER can be one of the
EM trap numbers,
listed in [3],
or one of the numbers listed in the
\fITraps\fR definition module.
.PP
The following runtime errors may occur:
.IP "array bound error"
.br
This error is detected if the \fI\(enA\fR option is given to \fIm2\fR.
.IP "range bound error"
.br
Range bound errors are always detected,
unless runtime checks are disabled.
.IP "set bound error"
.IP "cardinal overflow"
.br
This error is detected,
unless runtime checks are disabled.
.IP "cardinal underflow"
.br
This error is detected,
unless runtime checks are disabled.
.IP "divide by 0"
.IP "divide by 0.0"
.IP "conversion error"
.br
This error occurs when assigning a negative value of type INTEGER to a
variable of type CARDINAL,
or when assigning a value of CARDINAL that is > MAX(INTEGER),
to a variable of type INTEGER.
It is detected,
unless runtime checking is disabled.
.IP "heap overflow"
.br
This might happen when ALLOCATE fails.
.IP "case error"
.br
This error occurs when non of the cases in a CASE statement are selected,
and the CASE statement has no ELSE part.
.IP "stack size of process too large"
.br
This is most likely to happen if the reserved space for a coroutine stack
is too small.
In this case,
increase the size of the area given to
\*(CwNEWPROCESS\fR.
It can also happen if the stack needed for the main
process is too large and there are coroutines.
In this case,
the only fix is to reduce the stack size needed by the main process,
f.i. by avoiding local arrays.
.IP "too many nested traps + handlers"
.br
This error can only occur when the user has installed his own trap handler.
It means that during execution of the trap handler another trap has occurred,
and that several times.
In some cases,
this is an error because of overflow of some internal tables.
.IP "no RETURN from function procedure"
.br
This error occurs when a function procedure does not return properly
('falls' through).
.IP "illegal instruction"
.br
This error might occur when you use floating point operations on an
implementation that does not have floating point.
.PP
In addition,
some of the library modules may give error messages.
The \fBTraps\fR-module has a suitable mechanism for this.
.SS "The procedure call interface"
.PP
Parameters are pushed on the stack in reversed order.
For VAR parameters,
its address is passed,
for value parameters its value.
The only exception to this rule is with conformant arrays.
For conformant arrays,
the address is passed,
and an array descriptor is
passed.
The descriptor is an EM array descriptor.
It consists of three
fields: the lower bound (always 0),
upper bound \(mi lower bound,
and the size of the elements.
The descriptor is pushed first.
If the parameter is a value parameter,
the called routine must make sure
that its value is never changed,
for instance by making its own copy
of the array.
.PP
When the size of the return value of a function procedure is larger than
the maximum of \*(CwSIZE(LONGREAL)\fR and twice the pointer-size,
the caller reserves this space on the stack,
above the parameters.
Callee then stores
its result there,
and returns no other value.
.SS "The Modula-2 runtime library"
.PP
The definition modules of the modules available in the
.MX
Modula-2 runtime library reside in the directory \fI/usr/lib/ack/m2\fR.
.SS References
.IP [1]
Niklaus Wirth,
.ft I
Programming in Modula-2, third, corrected edition,
.ft R
Springer-Verlag, Berlin (1985)
.IP [2]
Niklaus Wirth,
.ft I
Programming in Modula-2,
.ft R
Stringer-Verlag, Berlin (1983)
.IP [3]
A.S.Tanenbaum, J.W.Stevenson, Hans van Staveren, E.G.Keizer,
.ft I
Description of a machine architecture for use with block structured languages,
.ft R
Informatica rapport IR-81, Vrije Universiteit, Amsterdam
.SH "THE MINIX PASCAL COMPILER"
.PP
.de IT
.PP
.B BS\ \\$1:
..
.de IS
.PP
.in +.5i
..
.PP
This section refers to the (1982) BSI standard for Pascal [1].
.MX
Pascal complies with the requirements of level 1 of BS 6192: 1982, with
the exceptions as listed in this section.
.PP
The standard requires an accompanying document describing the
implementation-defined and implementation-dependent features,
the reaction on errors and the extensions to standard Pascal.
These four items will be treated in the rest of this section.
.SS "Implementation-defined features"
.PP
For each implementation-defined feature mentioned in the BSI standard
we give the section number, the quotation from that section and the definition.
First we quote the definition of implementation-defined:
.PP
.RS
Possibly differing between processors, but defined for any particular
processor.
.RE
.IT 6.1.7
Each string-character shall denote an implementation-defined value of the
required char-type.
.IS
All 7-bit ASCII characters except linefeed LF (10) are allowed.
.IT 6.4.2.2
The values of type real shall be an implementation-defined subset
of the real numbers denoted as specified by 6.1.5 by the signed-real values.
.IS
The set of real values range from a low of \(mi1.7976931348623157e+308 to
a high of 1.7976931348623157e+308.
.IT 6.4.2.2
The type char shall be the enumeration of a set of implementation-defined
characters, some possibly without graphic representations.
.IS
The 7-bit ASCII character set is used, where LF (10) denotes the
end-of-line marker on text-files.
.IT 6.4.2.2
The ordinal numbers of the character values shall be values of integer-type,
that are implementation-defined, and that are determined by mapping
the character values on to consecutive non-negative integer values
starting at zero.
.IS
The normal ASCII ordering is used: ord('0')=48, ord('A')=65, ord('a')=97, etc.
.IT 6.6.5.2
The post-assertions imply corresponding activities on the external entities,
if any, to which the file-variables are bound.
These activities, and the
point at which they are actually performed, shall be
implementation-defined.
.IS
The reading and writing writing of objects on files is buffered.
This means that when a program terminates abnormally, I/O may be
unfinished.
Terminal I/O is unbuffered.
Files are closed whenever they are rewritten or reset, or on
program termination.
.IT 6.7.2.2
The predefined constant \fImaxint\fR shall be of integer-type and shall denote
an implementation-defined value, that satisfies the following conditions:
.IP (a)
All integral values in the closed interval from \fI\(mimaxint\fR to \fI+maxint\fR
shall be values of the integer-type.
.IP (b)
Any monadic operation performed on an integer value in this interval
shall be correctly performed according to the mathematical rules for
integer arithmetic.
.IP (c)
Any dyadic integer operation on two integer values in this same interval
shall be correctly performed according to the mathematical rules for
integer arithmetic, provided that the result is also in this interval.
.IP (d)
Any relational operation on two integer values in this same interval
shall be correctly performed according to the mathematical rules for
integer arithmetic.
.SP
The representation of integers under 16-bit \*(Mp or under 68000 \*(Mx
is a 16-bit word using two's complement arithmetic. The integers range
from \(mi32768 to +32767. Under 32-bit \*(Mp a 32-bit integer is used
ranging from \(mi2147483648 to +2147483647.
.IT 6.7.2.2
The result of the real arithmetic operators and functions shall be
approximations to the corresponding mathematical results.
The accuracy of
this approximation shall be implementation-defined
.IS
The default size of reals is 8 bytes, the accuracy is 11 bits for the exponent,
and 53 bits for the mantissa.
This gives an accuracy of about 16 digits.
and exponents ranging from \(mi307 to +307.
.IT 6.9.3.1
The default TotalWidth values for integer, Boolean and real types
shall be implementation-defined.
.IS
The defaults are:
.XS
.ta +\w'Boolean 'u +\w'14 'u
integer 6 (16-bit)
integer 11 (32-bit)
Boolean 5
real 14
.DT
.XE
.IT 6.9.3.4.1
ExpDigits, the number of digits written in an exponent part of a real,
shall be implementation-defined.
.IS
ExpDigits is defined as 3.
.IT 6.9.3.4.1
The character written as part of the representation of
a real to indicate the beginning of the exponent part shall be
implementation-defined, either 'E' or 'e'.
.IS
The exponent part starts with 'e'.
.IT 6.9.3.5
The case of the characters written as representation of the
Boolean values shall be implementation-defined.
.IS
The representations of true and false are 'true' and 'false'.
.IT 6.9.5
The effect caused by the standard procedure page
on a text file shall be implementation-defined.
.IS
The ASCII character form feed FF (12) is written.
.IT 6.10
The binding of the variables denoted by the program-parameters
to entities external to the program shall be implementation-defined if
the variable is of a file-type.
.IS
The program parameters must be files and all, except input and output,
must be declared as such in the program block.
.PP
The program parameters input and output, if specified, will correspond
with the UNIX streams 'standard input' and 'standard output'.
.PP
The other program parameters will be mapped to the argument strings
provided by the caller of this program.
The argument strings are supposed to be path names of the files to be
opened or created.
The order of the program parameters determines the mapping:
the first parameter is mapped onto the first argument string, etc.
Note that input and output are ignored in this mapping.
.PP
The mapping is recalculated each time a program parameter
is opened for reading or writing by a call to the standard procedures
reset or rewrite.
This gives the programmer the opportunity to manipulate the list
of string arguments using the external procedures argc, argv and argshift
available in the Pascal library.
.IT 6.10
The effect of an explicit use of reset or rewrite
on the standard text files input or output shall be implementation-defined.
.IS
The procedures reset and rewrite are no-ops
if applied to input or output.
.in 0
.SS "Implementation-dependent features"
.PP
For each implementation-dependent feature mentioned in the BSI standard,
we give the section number, the quotation from that section and the way
this feature is treated by the
.MX
Pascal system.
First we quote the definition of 'implementation-dependent':
.PP
.RS
Possibly differing between processors and not necessarily defined for any
particular processor.
.RE
.IT 6.7.2.1
The order of evaluation of the operands of a dyadic operator
shall be implementation-dependent.
.IS
Operands are always evaluated, so the program part
.XS
if (p<>nil) and (p^.value<>0) then
.XE
is probably incorrect.
.PP
The left-hand operand of a dyadic operator is almost always evaluated
before the right-hand side.
Some peculiar evaluations exist for the following cases:
.IP 1.
The modulo operation is performed by a library routine to
check for negative values of the right operand.
.IP 2.
The expression
.XS
set1 <= set2
.XE
where set1 and set2 are compatible set types is evaluated in the
following steps:
.XS
.ta +\w'\- 'u
\- evaluate set2;