mod(1) — VAX — Unsupported
Name
mod − Modula-2 compiler
Syntax
mod [ options ] name ...
Description
The mod command compiles one or more Modula-2 programs or implementation modules. Definition modules are not compiled. In the absence of options, it will compile all specified modules and link them together into an executable file called a.out.
Each program or implementation module must be in a separate file with a name ending with .mod. Each definition module must be in a separate file called module.def where module is the name of the module. Object files ending with .o compiled with mod or some other compiler may be specified.
File name arguments ending with .pcd, and .s, are assumed to be −pcode and assembly language files respectively, and are translated and assembled into object files.
Options
−cCreate object files but do not link them together.
−gGenerate additional symbol table information for the debugger dbx(.).
−iIgnore the errors in some of the modules and continue compiling the rest of them.
−m flags
Perform intermodule checking. If an out-of-date module is encountered, recompile it using the specified flags. The flags are separated by commas or spaces, and must be quoted if spaces are used.
−nWrite out what will happen when the same command is entered without the “-n” option.
−o name
Create an executable file called “name” instead of the default “a.out”.
−pgSet up object files for profiling by gprof(.).
−rRetain pcode and assembly language files in the current directory after compilation.
−sUse standard conventions for reserved word case, cardinal data type, and strings. See Extensions below.
−scUse standard conventions for cardinal data type (See Extensions, below).
−skUse standard conventions for reserved word case (See Extensions, below).
−ssUse standard conventions for string constants (See Extensions, below).
−uConvert all identifiers and reserved words to upper case (that is, ignore the case of identifiers and reserved words on input).
−vPrint out messages which state what is occurring during compilation.
−CGenerate runtime checks for illegal pointers, subrange and index bounds, and variant record tags.
−D directory
Use the specified directory for the phases of the compiler and the location of the standard definition modules and libraries.
−LIgnore references to modules not specified while performing intermodule checking. This is useful when checking modules to be placed in a library.
−MPerform intermodule checking, but do not recompile if inconsistencies are found.
−N
Ignore references to the module name while performing intermodule checking. This is useful when the module name is not a Modula-2 module. You may use this option as many times as needed.
−O
Perform code optimizations.
−P
Stop after generating pcode in a file ending with .pcd.
−S
Stop after generating assembly language in a file ending with .s.
Library Modules
By default, an import of a global module will cause the compiler to look for the definition module first in the working directory and then in the standard library directory. The standard library modules are automatically linked with the program.
The default may be overridden to specify other directories of definition modules using the MODPATH environment variable. MODPATH is set to a sequence of directory names separated by colons. Those directories will be searched in the order specified to find a definition module. The corresponding object files or libraries are specified when linking. The MODPATH environment variable may be set by the user in .login or in .modpath in the working directory. If the file .modpath exists in the working directory, the mod command will use its first line as the value of the MODPATH variable.
The following modules are provided by this implementation of Modula-2. Note that system, memory, io, and bitoperations are builtin modules; definition modules for them are provided for documentation purposes only. Only strings and parameters are actually implemented in Modula-2.
system Built in system module. Contains types of what word, address, etc., and process routines.
memory Built in storage module. Sets up pointers properly for runtime checks. Contains ALLOCATE and DEALLOCATE.
io Built in I/O module that provides formatted read and write similar to scanf() and printf(.).
bitoperations
Built in bit manipulation module. Performs operations such as shift, exclusive or, etc., on integer operands.
math Performs mathematical functions. Interface to the C math library.
parameters Accesses command line parameters and environment variables.
strings Compares, assigns, and links strings.
unix Defines some UNIX system calls and C library routines.
Storage Standard storage module, for compatibility with standard Modula-2. Contains ALLOCATE and DEALLOCATE.
Differences And Extensions
This implementation of Modula-2 has compiled and run Wirth’s Modula-2 compiler (as modified by Cambridge University for the VAX) with only minor changes to make Wirth’s compiler more portable. However, the definition of the language has been relaxed in some areas. For the most part, these changes are compatible.
The following is an incomplete list of differences between this compiler and Wirth’s compiler:
Reserved words and standard identifiers are recognized in upper and lower case, Thus, case variations of reserved words may not be used for identifiers. This feature is disabled by the −sk option.
Cardinal and non-negative subranges that do not exceed MAXINT are considered to be subranges of integer and are compatible with integers. Subranges that exceed MAXINT are compatible with cardinal and non-negative subranges. This feature is disabled by the −sc option.
A built in module called io provides formatted input and output. The readf and writef routines can accept any number of parameters, as long as their types correspond properly with the format string. Supported formats include: for integer and cardinal, d, x, and o; for real, g (output only), f, and e; for longreal, G (output only), F, and E; for char, c; and for string (array of char), s and [] (input only).
No import of allocate or deallocate is required to use new and dispose if the standard memory allocation routines are desired. Programs that require checking import allocate and deallocate from memory rather than storage.
The sizes returned by size and tsize and expected by allocate, deallocate and newprocess are in units of bits.
The system module includes the type byte, which is analogous to word, as well as appropriate related constants. There is also a function cputime, which returns the accumulated program CPU time in milliseconds.
There is a standard type called longreal that stores a double precision real value. A standard function longfloat converts cardinals, integers, or reals to longreal.
Additional standard procedures include:
min(a,b) Returns the smaller of two cardinal, integer, real, or longreal values.
max(a,b) Returns the larger of two cardinal, integer, real, or longreal values.
assert(condition[,message])
Aborts the program (with the optional message) if the condition is false.
number(a) Returns the number of elements in the specified array.
first(type) Returns the smallest legal value of the specified type.
last(type) Returns the largest legal value of the specified type.
Definition modules are not compiled.
Escape sequences may be placed in strings to specify non-printing characters. E.g., \n, \t, \r, \f, \b, \\, \’, and \" mean linefeed, tab, carriage return, form feed, backspace, backslash, single quote, and double quote, respectively. In addition a \ followed by up to three octal digits specifies the the character whose ASCII code is the octal value. A single (double) quote also may be put in a string delimited with single (double) quotes by specifying two single (double) quotes. This feature is disabled by the −ss option.
The interface to Unix is through a module called unix rather than the system module. The unixcall procedure is handled for compatibility with the Cambridge compiler, but is not recommended.
Additional keywords are recognized in certain contexts. These keywords are prefixed by @ to avoid conflicting with valid identifiers.
Pointer attributes
Attributes may be specified between the keywords pointer and to in order to change the default assumptions of Modula-2 pointer with checking. Recognized attributes are:
@nocheckModula-2 pointer, no checking
@cC/malloc pointer, no checking
@pascalPascal pointer, Pascal checking
Size and alignment
The size and alignment of data types may be specified preceding any type specification. The size and alignment multiples are in bits. For example,
type Register = @align 2 @size 4 [-8..7];
defines a type that occupies 4 bits aligned on a multiple of two bits.
Exports
Exports from a definition module are assumed qualified. Unqualified exports are permitted if the @unqualified keyword is used. Multiple export statements are permitted, but they must occur next to each other.
External variables and procedures
A procedure or variable may be accessed by C and Pascal routines using its unqualified name if the @external attribute occurs between the keyword procedure and the name of the procedure or precedes the variable declaration.
Uncounted open arrays
Open array parameters appear as two parameters, the address of the array and the number of element-to-non-Modula-2 programs. If necessary, the count may be omitted by placing the attribute @nocount between the keywords array and of in the open array declaration.
Restrictions
This is an experimental compiler, and thus no warranties are expressed or implied about its conformance to the definition of the Modula-2 language or about its proper functioning. We will endeavor to report and fix bugs, but users should be aware that this compiler is not a supported product.
Diagnostics
All error messages suppress subsequent compilation phases. Error messages ending with a question mark are internal errors, and probably represent compiler bugs. When pointer checking is running in a Modula-2 program, segmentation faults may be generated by the pointer validation test. These are intentional and should be considered as invalid pointer messages. The compiler runs with runtime checks enabled, and may produce core dumps. Report problems to the author.
Files
file.modProgram or implementation module
file.defDefinition module
file.pcdPcode (−P or −r)
file.sAssembly code (−S or −r)
/usr/local/lib/mod/mod2.0Modula-2 compiler front-end
/usr/local/lib/mod/mod2.1Modula-2 compiler back-end
/usr/local/lib/mod/mod2.2Intermodule checker
/usr/local/lib/mod/*.defStandard definition modules
/usr/local/lib/mod/modlibDefault library
/tmp/modNNNNNN.pcdTemporary Pcode file
/tmp/modNNNNNN.sTemporary assembly code file