The standalone batch compiler is used to produce components from source files.
The <input file> is compiled as an Alice source program and a corresponding component is written as output. If <output file> is given, it is used as the output file name, else the basename of <input file> is used with .ozf as extension. Compiled components can be executed by invoking the virtual machine.
<input file> may be a URL. See below for notes on how it is interpreted. <output file> may only be omitted if <input file> represents a local file.
To compile a component, the compiler requires access to all imported component files. If one does not exist, but a source file for it (i.e., a file with same name but ending in .aml, .sml, or .sig) can be located, the compiler first invokes itself recursively to compile the imported component. If a component does exist, the compiler does not perform any check to verify whether it is up-to-date. External tools like make have to be used, in conjunction with the dependency analyzer, to ensure proper recompilation if necessary.
It is possible to import Mozart components (Mozart "functors"), as long as they are augmented with an Alice signature file. See the interop section for details.
The second form just causes the compiler to print the standard extension for components (currently ozf) and exit immediately.
Print compiler version.
Set assertion level (0 by default).
Trace compilation phases.
Output component's export signature.
Warn about violations of standard naming conventions (on by default).
Warn about shadowing of identifiers (off by default, gives a lot of spurious warnings).
Use dependency file to automatically derive import announcements.
The Alice employs a compilation model that is quite different from other Standard ML systems. In particular, Alice ML requires putting explicit import announcements into source files to enable separate compilation.
In order to allow for easier migration or sharing of SML source code with other SML systems, the Alice compiler supports two methods for inserting import announcements automatically:
If the input file has the file extension .sml or .sig, then the compiler looks for a file with the same name but the extension .import. If found, the contents of that file is prepended to the actual input file.
The --dependency-file option allows specifying a file listing the dependencies between ML source files. The format of a dependency file is as follows:
dep-file | ::= | {dep-line}* |
depend-line | ::= | file-name : {file-name}* |
The format resembles (a subset of) makefile syntax:
Each line is headed by the file name denoting a source file, the target. After the colon follows a list of files the target depends on, its prerequisites. When a source file is compiled with a dependency file that contains its name as a target, then the source file is modified by prepending an import announcement for each prerequisite of the target. Extensions of target file names are ignored, a target is assumed to denote the current source file if its base name is the same. Likewise, prerequisites are stripped of their extension. That allows using makefile dependencies directly as dependency files.
Consider the following dependency file:
# project.depend A.ozf: B.ozf C.ozf D.ozf B.ozf: C.ozf: D.ozf
By invoking
alicec --dependency-file project.depend A.sml
A.sml will be compiled as if it contained the following import announcements:
import "B" import "C" import "D"
Moreover, if both, a requisite and the respective target are relative paths, then the requisite's path is rewritten relative to its target. For example, assume:
# project.depend sub/A.ozf: B.ozf ../C.ozf sub/D.ozf
By invoking
alicec --dependency-file project.depend sub/A.sml
sub/A.sml will be compiled as if it contained the following import announcements:
import "../B" import "../../C" import "D"
If a target is contained multiple times in a dependency file the corresponding prerequisites are accumulated. The compiler may be invoked with multiple dependency files, with the effect of invoking it with the concatenation of those files.
The first of these options essentially requires creating a separate import file for each individual SML file. The second option allows gathering all the necessary information into a single dependency file.
Please note that these methods are provided solely for better compatibility with other SML systems. Using them for native Alice components is strongly discouraged.
The batch compiler is parameterized by the same environment variables as the virtual machine, plus:
specifies how source file URLs are interpreted. If set, the value of this environment variable is parsed by the parse method of the Resolver.Handler structure. If not set, uses only the default identity method.