Cours the implementation-specific features of the ACK Modula-2 compiler, tutoriel & guide de travaux pratiques en pdf.
Introduction
This document describes the implementation-specific features of the ACK 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].
The ACK Modula-2 compiler is currently available for use with the VAX, Motorola MC68020, Motorola MC68000, PDP-11, and Intel 8086 code-generators. For the 8086, MC68000, and MC68020, floating point emulation is used. This is made available with the -fp option, which must be passed to ack[4,5].
The language implemented
This section 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 num-bers of the Report.
Syntax (section 2)
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.
Vocabulary and Representation (section 3)
The input « 10.. » is parsed as two tokens: « 10 » and « .. ».
The empty string « » has type
ARRAY [0 .. 0] OF CHAR
and contains one character: 0C.
The Foreign pragma is only meaningful in a DEFINITION MODULE, and indicates that this DEFINI-TION MODULE describes an interface to a module written in another language (for instance C, Pascal, or EM). Runtime checks that can be disabled are: range checks, CARDINAL overflow checks, checks when assigning a CARDINAL to an INTEGER and vice versa, and checks that FOR-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.
Constants of type LONGINT are integers with a suffix letter D (for instance 1987D). Constants of type LONGREAL have suffix D if a scale factor is missing, or have D in place of E in the scale factor (f.i. 1.0D, 0.314D1). 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.
Declarations and scope rules (section 4)
Standard identifiers are considered to be predeclared, and valid in all parts of a program. They are called pervasive. Unfortunately, the Report does not state how this pervasiveness is accomplished. How-ever, page 87 of [1] states: « Standard identifiers are automatically imported into all modules ». Our imple-mentation therefore allows redeclarations of standard identifiers within procedures, but not within modules.
Constant expressions (section 5)
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 ABS, CAP, CHR, LONG, MAX, MIN, ODD, ORD, SIZE, SHORT, TSIZE, or VAL, with constant argument(s); TSIZE and SIZE may also have a variable as argument.
Floating point expressions are never evaluated compile time, because the compiler basically functions as a cross-compiler, and thus cannot use the floating point instructions of the machine on which it runs. Also, MAX(REAL) and MIN(REAL) are not allowed.