<< Prev | - Up - | Next >> |
Directive Syntax
The Mozart compiler understands the full syntax of Oz programs. Additionally, it also accepts directives in its input. A directive can start anywhere on a line and is introduced by a backslash; it always extends until the end of the line.
Directives come in two flavors. So-called compiler directives provide a way to change the compiler's switches, whereas macro directives can be used for inserting files or performing compilation conditionally. While macro directives may appear between any two tokens in the input, the use of compiler directives underlies restrictions as described below.
Compilation Units
A single input file is split into a number of compilation units as follows:
Each compiler directive forms a compilation unit.
Each declare
statement starts a compilation unit, which includes all following non-declare
statements.
A sequence of statements without declare
forms a compilation unit.
Note that this implies that compiler directives can only appear between top-level Oz statements.
All compilation units in a file are processed sequentially.
\switch
( "+" <switchname> | "-" <switchname> )* Set ("+") resp. reset ("-") the specified switches. The values for <switchname> the compiler understands are described in Appendix A. Case matters.
\pushSwitches
Save the current settings of all switches onto the internal switch state stack.
\popSwitches
Restore all switch settings from the topmost element of the internal switch state stack, provided it is not empty, else do nothing.
\localSwitches
Save the current settings of all switches as well as the internal switch state stack if no \localSwitches
has occurred in the current input before, else do nothing. They are automatically restored after the last compilation unit of the current input has been processed.
\line
<filename> \line
<int> <filename> sets the internal file name (and the line number of the subsequent line) to the given values. This data will appear in the error messages and debug information generated by the compiler.
\insert
<filename> is substituted by the contents of the referenced file. The ~user
syntax is supported under Unix for absolute file names. If the file name is relative, it is first resolved against the directory in which the file containing the \insert
resides, then against all directories named in the OZPATH
environment variable (which has standard PATH
syntax).
Macro Names
Note that although macro names have the same syntax as Oz variables, there is absolutely no connection between macro names and Oz variables.
\define
<variable> adjoins <variable> to the set of macro names.
\undef
<variable> removes <variable> from the set of macro names.
\ifdef
<variable> causes the text until the next balanced \else
or \endif
only to be compiled if <variable> is a macro name.
\ifndef
<variable> caused the text until the next balanced \else
or \endif
to be ignored if <variable> is a macro name.
\else
causes the text until the next balanced \endif
to be
ignored, if the \else
occurs after a text region that was being compiled;
compiled, if the \else
occurs after a text region that was being ignored.
\endif
terminates the active \ifdef
or \ifndef
. Every \ifdef
and every \ifndef
must be terminated by a corresponding \endif
.
<< Prev | - Up - | Next >> |