Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bd5c3d824c3db63ffd9226c15941e6ad > files > 290

mozart-1.4.0-1mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>2 Directives</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node1.html#chapter.intro">&lt;&lt; Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="node3.html#chapter.applications">Next &gt;&gt;</A></TD></TR></TABLE><DIV id="chapter.directives"><H1><A name="chapter.directives">2 Directives</A></H1><DIV class="apropos"><P class="margin">Directive Syntax</P><P> The Mozart compiler understands the full syntax of Oz programs. Additionally, it also accepts <EM>directives</EM> 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. </P></DIV><P> Directives come in two flavors. So-called <EM>compiler directives</EM> provide a way to change the compiler's switches, whereas <EM>macro directives</EM> 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. </P><DIV class="apropos"><P class="margin">Compilation Units</P><P> A single input file is split into a number of compilation units as follows: </P><UL><LI><P>Each compiler directive forms a compilation unit. </P></LI><LI><P>Each <CODE><SPAN class="keyword">declare</SPAN></CODE> statement starts a compilation unit, which includes all following non-<CODE><SPAN class="keyword">declare</SPAN></CODE> statements. </P></LI><LI><P>A sequence of statements without <CODE><SPAN class="keyword">declare</SPAN></CODE> forms a compilation unit. </P></LI></UL><P> Note that this implies that compiler directives can only appear between top-level Oz statements. </P></DIV><P> All compilation units in a file are processed sequentially. </P><H2><A name="label2">2.1 Compiler Directives</A></H2><P> </P><DL><DT><CODE><SPAN class="reference">\switch</SPAN></CODE> ( <SPAN class="terminal">&quot;+&quot;</SPAN> &lt;<I>switchname</I>&gt; | <SPAN class="terminal">&quot;-&quot;</SPAN> &lt;<I>switchname</I>&gt; )* </DT><DD><P>Set (<SPAN class="terminal">&quot;+&quot;</SPAN>) resp. reset (<SPAN class="terminal">&quot;-&quot;</SPAN>) the specified switches. The values for &lt;<I>switchname</I>&gt; the compiler understands are described in <A href="node5.html#appendix.switches">Appendix&nbsp;A</A>. Case matters. </P></DD><DT><CODE><SPAN class="reference">\pushSwitches</SPAN></CODE> </DT><DD><P>Save the current settings of all switches onto the internal switch state stack. </P></DD><DT><CODE><SPAN class="reference">\popSwitches</SPAN></CODE> </DT><DD><P>Restore all switch settings from the topmost element of the internal switch state stack, provided it is not empty, else do nothing. </P></DD><DT><CODE><SPAN class="reference">\localSwitches</SPAN></CODE> </DT><DD><P>Save the current settings of all switches as well as the internal switch state stack if no <CODE><SPAN class="reference">\localSwitches</SPAN></CODE> 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. </P></DD></DL><P> </P><DIV id="section.directives.macro"><H2><A name="section.directives.macro">2.2 Macro Directives</A></H2><P> </P><DL><DT><CODE><SPAN class="reference">\line</SPAN></CODE> &lt;<I>filename</I>&gt; </DT><DT><CODE><SPAN class="reference">\line</SPAN></CODE> &lt;<I>int</I>&gt; &lt;<I>filename</I>&gt; </DT><DD><P>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. </P></DD><DT><CODE><SPAN class="reference">\insert</SPAN></CODE> &lt;<I>filename</I>&gt; </DT><DD><P>is substituted by the contents of the referenced file. The <CODE>~user</CODE> 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 <CODE><SPAN class="reference">\insert</SPAN></CODE> resides, then against all directories named in the <CODE>OZPATH</CODE> environment variable (which has standard <CODE>PATH</CODE> syntax). </P></DD></DL><P> </P><DIV class="apropos"><P class="margin">Macro Names</P><P> Note that although macro names have the same syntax as Oz variables, there is absolutely no connection between macro names and Oz variables. </P><DL><DT><CODE><SPAN class="reference">\define</SPAN></CODE> &lt;<I>variable</I>&gt; </DT><DD><P>adjoins &lt;<I>variable</I>&gt; to the set of macro names. </P></DD><DT><CODE><SPAN class="reference">\undef</SPAN></CODE> &lt;<I>variable</I>&gt; </DT><DD><P>removes &lt;<I>variable</I>&gt; from the set of macro names. </P></DD><DT><CODE><SPAN class="reference">\ifdef</SPAN></CODE> &lt;<I>variable</I>&gt; </DT><DD><P>causes the text until the next balanced <CODE><SPAN class="reference">\else</SPAN></CODE> or <CODE><SPAN class="reference">\endif</SPAN></CODE> only to be compiled if &lt;<I>variable</I>&gt; is a macro name. </P></DD><DT><CODE><SPAN class="reference">\ifndef</SPAN></CODE> &lt;<I>variable</I>&gt; </DT><DD><P>caused the text until the next balanced <CODE><SPAN class="reference">\else</SPAN></CODE> or <CODE><SPAN class="reference">\endif</SPAN></CODE> to be ignored if &lt;<I>variable</I>&gt; is a macro name. </P></DD><DT><CODE><SPAN class="reference">\else</SPAN></CODE> </DT><DD><P>causes the text until the next balanced <CODE><SPAN class="reference">\endif</SPAN></CODE> to be </P><UL><LI><P>ignored, if the <CODE><SPAN class="reference">\else</SPAN></CODE> occurs after a text region that was being compiled; </P></LI><LI><P>compiled, if the <CODE><SPAN class="reference">\else</SPAN></CODE> occurs after a text region that was being ignored. </P></LI></UL><P> </P></DD><DT><CODE><SPAN class="reference">\endif</SPAN></CODE> </DT><DD><P>terminates the active <CODE><SPAN class="reference">\ifdef</SPAN></CODE> or <CODE><SPAN class="reference">\ifndef</SPAN></CODE>. Every <CODE><SPAN class="reference">\ifdef</SPAN></CODE> and every <CODE><SPAN class="reference">\ifndef</SPAN></CODE> must be terminated by a corresponding <CODE><SPAN class="reference">\endif</SPAN></CODE>. </P></DD></DL><P></P></DIV></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node1.html#chapter.intro">&lt;&lt; Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="node3.html#chapter.applications">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~kornstae/">Leif&nbsp;Kornstaedt</A><BR><SPAN class="version">Version 1.4.0 (20090610)</SPAN></ADDRESS></BODY></HTML>