man m2c (Commandes) - Modula-2 translator

NAME

m2c - Modula-2 translator

SYNOPSIS

m2c [ options ] file ...

DESCRIPTION

The m2c command accepts options and file names as operands. Multiple single-letter options may not be grouped after delimiter `-'. The command m2c uses C compiler for processing some files. The C compiler is specified for installation time (for example it may be gcc(1), cc(1) or pcc(1)).

In general case, m2c command does compilation, assembly and linking. Files with names ending in .def are only tested on syntax and semantics; files with names ending in .mod are taken as Modula-2 source to be compiled into C files; C files generated by the Modula-2 translator and files with name ending in .c are taken as C source to be preprocessed and compiled; file names ending in .i are taken as preprocessor output to be compiled if the used C compiler does it; C compiler output files plus any input files with names ending in .s are assembled; then the resulting object files, plus any other input files, are linked together to produce an executable.

Command options allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker. Then the output consists of object files output by the assembler.

Each definition, implementation or main module must be in a separate file with a name relatively ending with .def , .mod where name is the module name. For compilation time of Modula-2 module also all explicitly and implicitly imported definition modules are compiled. After module compilation into C file number of lines of all these modules and size of intermediate code is output onto standard error output.

If any error which does not allow object file generation is fixed for compilation time of a file, m2c continues processing other files but does not execute linking.

OPTIONS

The options which are known for the Modula-2 translator are:

-3
The translator implements language Modula-2 described in 3rd edition of Wirth's book. Implicitly the translator implements the language described in the 4th edition.
-strict
Prohibit language extensions.
-C
Stop after compilation of Modula-2 modules to C code. The name of generated file is module name with suffix .c . If the C compiler recognizes option `-o file' when option `-c' is specified, the name of output C file may be given in option `-o file'.
-Pdir
Search of imported definition modules in this directory. List of searched directories separated by semicolons is also taken from shell variable `m2paths' . Order of searching the directories is: current directory

standard library directory

directories given in options `-P'

directories given in shell variables `m2paths'.
-test
Generation of code for dynamic tests of ranges and pointers.
-upper-case
Allow only upper case keywords and standard identifiers (`-strict' means `-upper-case').
-v
Output of command lines of processes loaded by m2c. If the C compiler recognizes this option the one is also passed to the C compiler.
-update
Updating instead of creating any Modula-2 module output. It may be output C (if `-C' option is specified), assembler (if `-S' option is specified) or object file (in other cases).
-CM
Output of make(1) dependence line for output of each Modula-2 module to standard output. None files are generated.
-all
Only one Modula-2 module must be in command line. In addition to this requirement the module must be main module. All program modules are processed with removing procedures unused in program. Modula-2 translator assumes that implementation module is placed in the relative definition module directory.
-make
Only one Modula-2 module must be in command line. In addition to this requirement the module must be main module. All program modules in the current directory are processed as in update option case. Object files of the program which is placed in other directories are used for loader execution time (if linkage is specified). Modula-2 translator assumes that implementation module and its object files is placed in the relative definition module directory.
-MAKE
Output of make dependence lines that describes processing modules as in `-make' option specification case. None files are generated.

The m2c command are also recognized other options which are passed to the used C compiler. To output the list of such options specify command m2c without options and files.

LANGUAGE EXTENSIONS

New primitive types SHORTINT, SHORTCARD, SHORTREAL, LONGINT, LONGCARD, LONGREAL, BYTE are included in the language.

Type of function result may be structural.

Opaque export is restricted only to type the size and the alignment of which are the same as for type WORD .

Interface with C functions are included in the language. All integer C functions are assumed to be placed in the pseudo-module CPROC .

Control character sequence as in C language may be used. Such string constant starts with ``' and finishes by `'' .

C code fragments may be inserted in declaration or statement sections of Modula-2 program. The fragments are placed between brackets `%{' and `%}' .

As a consequence of multipass implementation an identifier may be used before its definition, for example VAR v : t ;

TYPE t = CARDINAL ;

STANDARD MODULES

The following modules are provided by this implementation of Modula-2.

ASCII

Files

InOut

MathLib0

NumConv

RealConv

RealInOut

ShellVars

Storage

String

Terminal

For more details about its see relative definition modules.

DEBUGGING

Debuggers dbx (1) or gdb (1). can be used for debugging Modula-2 program by virtue of accurate implementation of `#line' construction in most C compiler and clear correspondence between object names in Modula-2 and C. For example for output values of current procedure variables can be used debugger command

print var

for output variables values of module `sieve' can be used command

print var_sieve

EXAMPLES

Command

m2c -make -g -o XREF XREF.mod math.o -lm

creates object files XREF.o and Table.o (if its are obsolete) and executable file XREF containing also code of object file math.o XREF contains additional symbol table for the debugger dbx (1) or gdb (1).

Command

m2c -update -c -O Table.mod

creates optimized object file Table.o (if it is obsolete).

Command

m2c -C -all sieve.mod

creates C files of all program sieve modules. Code for procedures unused in the program are absent in the C files.

FILES

file.def Modula-2 definition module

file.mod Modula-2 main or implementation module

file.c C source file

file.i C source file

file.s assembly language file

file.o object file

a.out link edited output

/tmp/m2cNNNNN.c temporary files

BINDIR/m2c translator

LIBDIR/m2lib.a run-time library

LIBDIR/*.def standard definition modules

LIBDIR/*.mod standard implementation modules

LIBDIR/*.o object files of standard modules BINDIR is usually /usr/local/bin. LIBDIR is usually /usr/local/lib/m2lib.

SEE ALSO

cc(1), gcc(1), pcc(1), make(1), dbx(1), gdb(1).

BUGS

Bugs should be reported to vmakarov@usa.net.

COPYING

Copyright (c) 1993-1997. The translator is distributed under GNU Public License.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English.

AUTHOR

Vladimir Makarov (The Institute for Problems of Cybernetics of the USSR Academy of Sciences).