Using the COMALC compiler (supplied with V3.11 Developers').

UniCOMAL V3.11 Developers' has a compiler for COMAL programs included along with the editor and the interpreter. The compiler takes the form of a DOS executable program called COMALC.EXE, which can be run from the DOS prompt or from within the UniCOMAL editor. In either case, the compiler can be run from inside an MS-Windows window if required.

Recently, we had a call from a teacher who was having trouble making the compiler work properly (actually, work at all!). He had difficulty in making sense of the interactive Compiler Help file, and couldn't find his "Development Toolkit" reference manual. He wondered if a step-by-step account of compiling a UniCOMAL program could be published on the website, so here it is, and why didn't we think of it for ourselves? Our thanks to him for a most constructive suggestion.

The documentation

First, though, some notes on the documentation for, and the operation of, the compiler. (If you want to get started quickly, you might like to skip this paragraph and go straight on to the next one). The main documentation is to be found in the UniCOMAL "Development Toolkit" manual, chapter 5, 6, 7 8, 9 and 10, pages 107 to 151. This gives a full account of the compiler and how to use it, with some very useful practical examples in chapter 9. The interactive help text, however, is not so useful. It is called the "UniCOMAL Compiler Help Document" and is 84 screens long, hyperlinked. It contains a full description of the compiler and its options but is difficult to read and has few illustrative examples. So, if you intend making much use of the compiler, especially with students, it's really important to have read the Development Toolkit manual sections first. In particular, notice the section on pages 108-109, which explains how this, most unusual, compiler actually does its compiling. It seems that the compiler builds a stand-alone executable program by linking together the COMAL source code, with any modules which it requires, with a run-time interpreter which executes the standalone program by interpreting a compressed and optimized version of the source code. For this reason, compiled UniCOMAL programs rarely run any faster than the interpreted versions do.

A step-by-step example

Here is how the MCEDIT.EXE machine code editor program, uploaded on Jan 2nd 1999, was produced and compiled. If you want to follow through with the MCEDIT.CML source file for yourself, you can download it from the downloads section by clicking on the link above.

SCANning source files before Compiling

COMALC won't compile a source program unless it has been checked by the interpreter for any structure errors which might have escaped the syntax checker in the editor. Before SAVEing a source program which is going to be compiled, you must at least SCAN the code to check for structure errors. Otherwise, COMALC will fail and issue the "Program not SCANned" error message as shown below:

	SAVE "unscan
	>COMALC

	 The UniComal Compiler System for COMAL. Version 3.11
	 (C) Copyright UniComal A/S 1987-1992.
	     All rights reserved.

	 Registration number: 920916-569999

	Program files   [C:\COMAL\.CML+.PRC]: unscan.cml
	Run file        [C:\COMAL\UNSCAN.EXE]:
	Module files    [C:\COMAL\.MOD]:
	Message file    [C:\COMAL\RUNUS.MSG]:

	C:\COMAL\UNSCAN.CML: C:\COMAL\UNSCAN.CML: Program not SCANned

However, the UniCOMAL interpreter SCANs programs automatically when they are RUN, so if you SAVE a program after successfully RUNning it, it should compile without encountering the above error.


Updated 20-05-1999