/usr/share/mozart/doc/notation/node3.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>3 Context-Free Syntax</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="node2.html#chapter.lexical"><< Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="node4.html#chapter.core">Next >></A></TD></TR></TABLE><DIV id="chapter.context-free"><H1><A name="chapter.context-free">3 Context-Free Syntax</A></H1><P> In this section, we give a context-free grammar for a superset of Oz programs. Any sequence of tokens that is not a member of the language described by this grammar, starting from the <<I>statement</I>> nonterminal, is considered erroneous. </P><P> Implementations may accept a larger language, e. g., something more than only a statement at top-level, or treat lexical syntax that has no assigned meaning in the report as compiler directives. </P><H2><A name="label14">3.1 The Base Language</A></H2><DIV class="apropos"><P class="margin">Statements</P><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>statement</I>></TD><TD align="center"> ::= </TD><TD><<I>statement</I>> <<I>statement</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">local</SPAN></CODE> <<I>in statement</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>(</CODE>"</SPAN> <<I>in statement</I>> <SPAN class="terminal">"<CODE>)</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">proc</SPAN></CODE> { <<I>atom</I>> } <SPAN class="terminal">"<CODE>{</CODE>"</SPAN> <<I>expression</I>> { <<I>pattern</I>> } <SPAN class="terminal">"<CODE>}</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><<I>in phrase</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">fun</SPAN></CODE> { <<I>atom</I>> } <SPAN class="terminal">"<CODE>{</CODE>"</SPAN> <<I>expression</I>> { <<I>pattern</I>> } <SPAN class="terminal">"<CODE>}</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><<I>in expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>{</CODE>"</SPAN> <<I>expression</I>> { <<I>expression</I>> } <SPAN class="terminal">"<CODE>}</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">if</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in statement</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <<I>else statement</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">case</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">of</SPAN></CODE> <<I>case statement clause</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <CODE><SPAN class="keyword">[]</SPAN></CODE> <<I>case statement clause</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <<I>else statement</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">lock</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in statement</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">thread</SPAN></CODE> <<I>in statement</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">try</SPAN></CODE> <<I>in statement</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <CODE><SPAN class="keyword">catch</SPAN></CODE> <<I>case statement clause</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>case statement clause</I>> } ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <CODE><SPAN class="keyword">finally</SPAN></CODE> <<I>in statement</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">raise</SPAN></CODE> <<I>in expression</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE>=</CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">.</SPAN></CODE>"</SPAN> <<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">skip</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><DIV class="apropos"><P class="margin">Expressions</P><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>expression</I>></TD><TD align="center"> ::= </TD><TD><CODE><SPAN class="keyword">local</SPAN></CODE> <<I>in expression</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>(</CODE>"</SPAN> <<I>in expression</I>> <SPAN class="terminal">"<CODE>)</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">proc</SPAN></CODE> { <<I>atom</I>> } <SPAN class="terminal">"<CODE>{</CODE>"</SPAN> <SPAN class="terminal">"<CODE>$</CODE>"</SPAN> { <<I>pattern</I>> } <SPAN class="terminal">"<CODE>}</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><<I>in phrase</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">fun</SPAN></CODE> { <<I>atom</I>> } <SPAN class="terminal">"<CODE>{</CODE>"</SPAN> <SPAN class="terminal">"<CODE>$</CODE>"</SPAN> { <<I>pattern</I>> } <SPAN class="terminal">"<CODE>}</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><<I>in expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>{</CODE>"</SPAN> <<I>expression</I>> { <<I>expression</I>> } <SPAN class="terminal">"<CODE>}</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">if</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><<I>else expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">case</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">of</SPAN></CODE> <<I>case expression clause</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <CODE><SPAN class="keyword">[]</SPAN></CODE> <<I>case expression clause</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <<I>else expression</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">lock</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in expression</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">thread</SPAN></CODE> <<I>in expression</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">try</SPAN></CODE> <<I>in expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <CODE><SPAN class="keyword">catch</SPAN></CODE> <<I>case expression clause</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>case expression clause</I>> } ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <CODE><SPAN class="keyword">finally</SPAN></CODE> <<I>in statement</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">raise</SPAN></CODE> <<I>in expression</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE>=</CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <CODE><SPAN class="keyword">orelse</SPAN></CODE> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <CODE><SPAN class="keyword">andthen</SPAN></CODE> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>monop</I>> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <<I>binop</I>> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">.</SPAN></CODE>"</SPAN> <<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>possibly escaped variable</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>_</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>atom</I>> | <<I>int</I>> | <<I>float</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">unit</SPAN></CODE> | <CODE><SPAN class="keyword">true</SPAN></CODE> | <CODE><SPAN class="keyword">false</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>label</I>> <SPAN class="terminal">"<CODE>(</CODE>"</SPAN> { <<I>subtree</I>> } [ <SPAN class="terminal">"<CODE><SPAN class="keyword">...</SPAN></CODE>"</SPAN> ] <SPAN class="terminal">"<CODE>)</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>[</CODE>"</SPAN> { <<I>expression</I>> }+ <SPAN class="terminal">"<CODE>]</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">|</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">#</SPAN></CODE>"</SPAN> <<I>expression</I>> }+</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>$</CODE>"</SPAN></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>label</I>></TD><TD align="center"> ::= </TD><TD><<I>variable label</I>> | <<I>atom label</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>unit label</I>> | <<I>true label</I>> | <<I>false label</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>feature</I>></TD><TD align="center"> ::= </TD><TD><<I>variable</I>> | <<I>atom</I>> | <<I>int</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">unit</SPAN></CODE> | <CODE><SPAN class="keyword">true</SPAN></CODE> | <CODE><SPAN class="keyword">false</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>subtree</I>></TD><TD align="center"> ::= </TD><TD>[ <<I>feature</I>> <SPAN class="terminal">"<CODE>:</CODE>"</SPAN> ] <<I>expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><DIV class="apropos"><P class="margin">Precedence</P><P> Note that in both <<I>statement</I>>s and <<I>expression</I>>s there is potential ambiguity between <<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>> and <<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">.</SPAN></CODE>"</SPAN> <<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>>. In fact <SPAN class="terminal">"<CODE><SPAN class="keyword">.</SPAN> <SPAN class="keyword">:=</SPAN></CODE>"</SPAN> is a ternary operator and has precedence. Parenthesis must be used for the alternate parse, that is, (<<I>expression</I>><SPAN class="terminal">"<CODE><SPAN class="keyword">.</SPAN></CODE>"</SPAN><<I>expression</I>>) <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>>. </P></DIV><P> The assignment operators <SPAN class="terminal">"<CODE><SPAN class="keyword">.</SPAN> <SPAN class="keyword">:=</SPAN></CODE>"</SPAN> and <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN>, when used in expression position, perform an atomic exchange, the result of the operation being the previous value of the stateful entity assigned to. </P><DIV class="apropos"><P class="margin">Operators</P><P> Expressions with operators need additional disambiguating rules introduced in <A href="node3.html#section.context-free.operators">Section 3.5</A>. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>monop</I>></TD><TD align="center"> ::= </TD><TD><SPAN class="terminal">"<CODE><SPAN class="keyword">~</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">!!</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">@</SPAN></CODE>"</SPAN></TD></TR></TABLE></BLOCKQUOTE><P></P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>binop</I>></TD><TD align="center"> ::= </TD><TD><SPAN class="terminal">"<CODE><SPAN class="keyword">.</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE>^</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE><SPAN class="keyword">==</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">\=</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword"><</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">=<</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">></SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">>=</SPAN></CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE><SPAN class="keyword">+</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">-</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">*</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">/</SPAN></CODE>"</SPAN> | <CODE><SPAN class="keyword">div</SPAN></CODE> | <CODE><SPAN class="keyword">mod</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P></P></DIV><DIV class="apropos"><P class="margin">Declarations</P><P> A <<I>declaration part</I>> is a sequence of variables and statements. Singleton variables serve only for explicit declaration and are otherwise ignored. Variables within statements are implicitly declared if they occur at a <EM>pattern position</EM>. A prefixed escape (<CODE><SPAN class="keyword">!</SPAN></CODE>) prevents implicit declaration. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>declaration part</I>></TD><TD align="center"> ::= </TD><TD><<I>variable</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>statement</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>declaration part</I>> <<I>declaration part</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>in statement</I>></TD><TD align="center"> ::= </TD><TD>[ <<I>declaration part</I>> <CODE><SPAN class="keyword">in</SPAN></CODE> ] <<I>statement</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>in expression</I>></TD><TD align="center"> ::= </TD><TD>[ <<I>declaration part</I>> <CODE><SPAN class="keyword">in</SPAN></CODE> ] [ <<I>statement</I>> ] <<I>expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>possibly escaped variable</I>></TD><TD align="center"> ::= </TD><TD>[ <SPAN class="terminal">"<CODE><SPAN class="keyword">!</SPAN></CODE>"</SPAN> ] <<I>variable</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><P> As procedure body either a statement or an expression may be possible, depending on whether the procedure's formal parameter patterns contain a nesting marker (<CODE>$</CODE>) or not. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>in phrase</I>></TD><TD align="center"> ::= </TD><TD><<I>in statement</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>in expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><DIV class="apropos"><P class="margin">Patterns</P><P> Pattern matching is performed as a top-down left-to-right sequence of tests. Record patterns test a value's constructor; constant patterns and escaped variable patterns test for equality with the given value; nonlinearities (variables occurring multiply in one pattern) test for equality of the corresponding subtrees. Equation patterns and non-escaped variables introduce variable bindings. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>pattern</I>></TD><TD align="center"> ::= </TD><TD><<I>label</I>> <SPAN class="terminal">"<CODE>(</CODE>"</SPAN> { <<I>subpattern</I>> } [ <SPAN class="terminal">"<CODE><SPAN class="keyword">...</SPAN></CODE>"</SPAN> ] <SPAN class="terminal">"<CODE>)</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>[</CODE>"</SPAN> { <<I>pattern</I>> }+ <SPAN class="terminal">"<CODE>]</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>pattern</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">|</SPAN></CODE>"</SPAN> <<I>pattern</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>pattern</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">#</SPAN></CODE>"</SPAN> <<I>pattern</I>> }+</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>atom</I>> | <<I>int</I>> | <<I>float</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">unit</SPAN></CODE> | <CODE><SPAN class="keyword">true</SPAN></CODE> | <CODE><SPAN class="keyword">false</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>possibly escaped variable</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>_</CODE>"</SPAN></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>pattern</I>> <SPAN class="terminal">"<CODE>=</CODE>"</SPAN> <<I>pattern</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE>(</CODE>"</SPAN> <<I>pattern</I>> <SPAN class="terminal">"<CODE>)</CODE>"</SPAN></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>subpattern</I>></TD><TD align="center"> ::= </TD><TD>[ <<I>feature</I>> <SPAN class="terminal">"<CODE>:</CODE>"</SPAN> ] <<I>pattern</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><P> Following the pattern an additional side condition can be given. It is only evaluated if the pattern matched, in the environment extended by the bindings introduced by the pattern. The variables introduced in the optional <<I>declaration part</I>> are also visible in the clause's body. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>case statement clause</I>></TD><TD align="center"> ::= </TD><TD><<I>pattern</I>> [ <CODE><SPAN class="keyword">andthen</SPAN></CODE> [ <<I>declaration part</I>> <CODE><SPAN class="keyword">in</SPAN></CODE> ] <<I>expression</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in statement</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>case expression clause</I>></TD><TD align="center"> ::= </TD><TD><<I>pattern</I>> [ <CODE><SPAN class="keyword">andthen</SPAN></CODE> [ <<I>declaration part</I>> <CODE><SPAN class="keyword">in</SPAN></CODE> ] <<I>expression</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><DIV class="apropos"><P class="margin">Else Clauses</P><P> If the <CODE><SPAN class="keyword">else</SPAN></CODE> part to an <CODE><SPAN class="keyword">if</SPAN></CODE> statement is omitted, it is taken to be <CODE><SPAN class="keyword">else</SPAN> <SPAN class="keyword">skip</SPAN></CODE>. The <CODE><SPAN class="keyword">else</SPAN></CODE> part to an <CODE><SPAN class="keyword">if</SPAN></CODE> expression is mandatory. </P></DIV><P> If the <CODE><SPAN class="keyword">else</SPAN></CODE> part to a <CODE><SPAN class="keyword">case</SPAN></CODE> statement or expression is omitted and no pattern matches, an error exception is raised. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>else statement</I>></TD><TD align="center"> ::= </TD><TD><CODE><SPAN class="keyword">elseif</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in statement</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <<I>else statement</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">elsecase</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">of</SPAN></CODE> <<I>case statement clause</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>case statement clause</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <<I>else statement</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">else</SPAN></CODE> <<I>in statement</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>else expression</I>></TD><TD align="center"> ::= </TD><TD><CODE><SPAN class="keyword">elseif</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><<I>else expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">elsecase</SPAN></CODE> <<I>expression</I>> <CODE><SPAN class="keyword">of</SPAN></CODE> <<I>case expression clause</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>case expression clause</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <<I>else expression</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">else</SPAN></CODE> <<I>in expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><H2><A name="label15">3.2 Constraint Extensions and Combinators</A></H2><DIV class="apropos"><P class="margin">Statements</P><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>statement</I>></TD><TD align="center"> += </TD><TD><<I>fd compare</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>fd in</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">fail</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">not</SPAN></CODE> <<I>in statement</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">cond</SPAN></CODE> <<I>cond statement clause</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>cond statement clause</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <CODE><SPAN class="keyword">else</SPAN></CODE> <<I>in statement</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">or</SPAN></CODE> <<I>dis statement clause</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>dis statement clause</I>> }+ <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">dis</SPAN></CODE> <<I>dis statement clause</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>dis statement clause</I>> }+ <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">choice</SPAN></CODE> <<I>in statement</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>in statement</I>> } <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>cond statement clause</I>></TD><TD align="center"> ::= </TD><TD>[ <<I>declaration part</I>> <CODE><SPAN class="keyword">in</SPAN></CODE> ] <<I>statement</I>> <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in statement</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>dis statement clause</I>></TD><TD align="center"> ::= </TD><TD>[ <<I>declaration part</I>> <CODE><SPAN class="keyword">in</SPAN></CODE> ] <<I>statement</I>> [ <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in statement</I>> ]</TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><DIV class="apropos"><P class="margin">Expressions</P><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>expression</I>></TD><TD align="center"> += </TD><TD><<I>fd compare</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>fd in</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">fail</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">cond</SPAN></CODE> <<I>cond expression clause</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>cond expression clause</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <CODE><SPAN class="keyword">else</SPAN></CODE> <<I>in expression</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">or</SPAN></CODE> <<I>cond expression clause</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>cond expression clause</I>> }+ <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">dis</SPAN></CODE> <<I>cond expression clause</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>cond expression clause</I>> }+ <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">choice</SPAN></CODE> <<I>in expression</I>> { <SPAN class="terminal">"<CODE><SPAN class="keyword">[]</SPAN></CODE>"</SPAN> <<I>in expression</I>> } <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>cond expression clause</I>></TD><TD align="center"> ::= </TD><TD>[ <<I>declaration part</I>> <CODE><SPAN class="keyword">in</SPAN></CODE> ] <<I>statement</I>> <CODE><SPAN class="keyword">then</SPAN></CODE> <<I>in expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>fd compare</I>></TD><TD align="center"> ::= </TD><TD><<I>expression</I>> ( <SPAN class="terminal">"<CODE><SPAN class="keyword">=:</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">\=:</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword"><:</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">=<:</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">>:</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">>=:</SPAN></CODE>"</SPAN> ) <<I>expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>fd in</I>></TD><TD align="center"> ::= </TD><TD><<I>expression</I>> ( <SPAN class="terminal">"<CODE><SPAN class="keyword">::</SPAN></CODE>"</SPAN> | <SPAN class="terminal">"<CODE><SPAN class="keyword">:::</SPAN></CODE>"</SPAN> ) <<I>expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><H2><A name="label16">3.3 Class Extensions</A></H2><DIV class="apropos"><P class="margin">Class Definitions</P><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>statement</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">class</SPAN></CODE> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <<I>class descriptor</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <<I>method</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>expression</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">class</SPAN></CODE> [ <SPAN class="terminal">"<CODE>$</CODE>"</SPAN> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <<I>class descriptor</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>{ <<I>method</I>> }</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P></P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>class descriptor</I>></TD><TD align="center"> ::= </TD><TD><CODE><SPAN class="keyword">from</SPAN></CODE> { <<I>expression</I>> }+</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">prop</SPAN></CODE> { <<I>expression</I>> }+</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">attr</SPAN></CODE> { <<I>attr or feat</I>> }+</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">feat</SPAN></CODE> { <<I>attr or feat</I>> }+</TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><P> Non-escaped variables are implicitly introduced with class scope, bound to new names. This allows to model private components. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>attr or feat</I>></TD><TD align="center"> ::= </TD><TD>[ <SPAN class="terminal">"<CODE><SPAN class="keyword">!</SPAN></CODE>"</SPAN> ] <<I>variable</I>> | <<I>atom</I>> | <<I>int</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">unit</SPAN></CODE> | <CODE><SPAN class="keyword">true</SPAN></CODE> | <CODE><SPAN class="keyword">false</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P><DIV class="apropos"><P class="margin">Methods</P><P> The first-class message used to invoke a method can be referenced by appending <CODE>=</CODE> <<I>variable</I>> to the method head. This message does not contain defaulted arguments (see below) if they have not been explicitly given. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>method</I>></TD><TD align="center"> ::= </TD><TD><CODE><SPAN class="keyword">meth</SPAN></CODE> <<I>method head</I>> [ <SPAN class="terminal">"<CODE>=</CODE>"</SPAN> <<I>variable</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><<I>in phrase</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD><CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><P> If dots are given, any additional features are allowed in the first-class message; else, extraneous features cause an error exception to be raised. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>method head</I>></TD><TD align="center"> ::= </TD><TD>[ <SPAN class="terminal">"<CODE><SPAN class="keyword">!</SPAN></CODE>"</SPAN> ] <<I>variable</I>> | <<I>atom</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">unit</SPAN></CODE> | <CODE><SPAN class="keyword">true</SPAN></CODE> | <CODE><SPAN class="keyword">false</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>method head label</I>> <SPAN class="terminal">"<CODE>(</CODE>"</SPAN> { <<I>method formal</I>> } [ <SPAN class="terminal">"<CODE><SPAN class="keyword">...</SPAN></CODE>"</SPAN> ] <SPAN class="terminal">"<CODE>)</CODE>"</SPAN></TD></TR></TABLE></BLOCKQUOTE><P></P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>method head label</I>></TD><TD align="center"> ::= </TD><TD>[ <SPAN class="terminal">"<CODE><SPAN class="keyword">!</SPAN></CODE>"</SPAN> ] <<I>variable label</I>> | <<I>atom label</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>unit label</I>> | <<I>true label</I>> | <<I>false label</I>></TD></TR></TABLE></BLOCKQUOTE><P> </P><P> A default <CODE><SPAN class="keyword"><=</SPAN></CODE> after a formal argument allows for the corresponding actual argument to be omitted from a first-class method. In this case, the default expression will be evaluated (inside the method) and the formal argument variable bound to the result. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>method formal</I>></TD><TD align="center"> ::= </TD><TD>[ <<I>feature</I>> <SPAN class="terminal">"<CODE>:</CODE>"</SPAN> ] ( <<I>variable</I>> | <SPAN class="terminal">"<CODE>_</CODE>"</SPAN> | <SPAN class="terminal">"<CODE>$</CODE>"</SPAN> )</TD></TR><TR valign="top"><TD></TD><TD align="center"></TD><TD>[ <SPAN class="terminal">"<CODE><SPAN class="keyword"><=</SPAN></CODE>"</SPAN> <<I>expression</I>> ]</TD></TR></TABLE></BLOCKQUOTE><P> </P><DIV class="apropos"><P class="margin">Operations</P><P> To the following operators, <CODE><SPAN class="keyword">self</SPAN></CODE> is an implicit operand. Their use is syntactically restricted to the body of method definitions. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>statement</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">lock</SPAN></CODE> <<I>in statement</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword"><-</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">,</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR></TABLE></BLOCKQUOTE><P> The assignment operators <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN>, <SPAN class="terminal">"<CODE><SPAN class="keyword"><-</SPAN></CODE>"</SPAN>, when used in an expression position, perform an atomic exchange, the result of the operation being the previous value of the attribute assigned to. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>expression</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">lock</SPAN></CODE> <<I>in expression</I>> <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><SPAN class="terminal">"<CODE><SPAN class="keyword">@</SPAN></CODE>"</SPAN><<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">:=</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword"><-</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>expression</I>> <SPAN class="terminal">"<CODE><SPAN class="keyword">,</SPAN></CODE>"</SPAN> <<I>expression</I>></TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">self</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><H2><A name="label17">3.4 Functor Extensions</A></H2><P> A functor definition creates a chunk with (at least) features <CODE><SPAN class="string">'import'</SPAN></CODE> and <CODE><SPAN class="string">'export'</SPAN></CODE> describing its interface and a feature <CODE>apply</CODE> containing a procedure mapping an import record to an export module. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>statement</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">functor</SPAN></CODE> <<I>expression</I>> { <<I>functor descriptor</I>> } <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>expression</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">functor</SPAN></CODE> [ <SPAN class="terminal">"<CODE>$</CODE>"</SPAN> ] { <<I>functor descriptor</I>> } <CODE><SPAN class="keyword">end</SPAN></CODE></TD></TR></TABLE></BLOCKQUOTE><P> </P><DIV class="apropos"><P class="margin">Import Specification</P><P> The import specification names values (usually modules) to be made available to the body. They represent formal arguments to the body abstraction. The additional <CODE><SPAN class="keyword">at</SPAN></CODE> clause allows to specify where the actual argument is to come from. This must be an atom (interpreted as a relative URL) so that a functor creating the referenced module may be located at compile time. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>functor descriptor</I>></TD><TD align="center"> ::= </TD><TD><CODE><SPAN class="keyword">import</SPAN></CODE> { <<I>import clause</I>> }+</TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>import clause</I>></TD><TD align="center"> ::= </TD><TD><<I>variable</I>> [ <CODE><SPAN class="keyword">at</SPAN></CODE> <<I>atom</I>> ]</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><<I>variable label</I>> <<I>import features</I>> [ <CODE><SPAN class="keyword">at</SPAN></CODE> <<I>atom</I>> ]</TD></TR></TABLE></BLOCKQUOTE><P> If the expected structure of an imported value is partially specified, occurrences of the module name are restricted to a single syntactic context: the first operand in applications of the dot operator, where the second operand is one of the features mentioned in the import specification. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>import features</I>></TD><TD align="center"> ::= </TD><TD><SPAN class="terminal">"<CODE>(</CODE>"</SPAN> { <<I>module feature</I>> <<I>import alias</I>> }+ <SPAN class="terminal">"<CODE>)</CODE>"</SPAN></TD></TR></TABLE></BLOCKQUOTE><P> </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>module feature</I>></TD><TD align="center"> ::= </TD><TD><<I>atom</I>> | <<I>int</I>></TD></TR></TABLE></BLOCKQUOTE><P> An <EM>import alias</EM> introduces a variable bound to one of the imported module's subtrees. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>import alias</I>></TD><TD align="center"> ::= </TD><TD>[ <SPAN class="terminal">"<CODE>:</CODE>"</SPAN> <<I>variable</I>> ]</TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><DIV class="apropos"><P class="margin">Functor Body</P><P> The body of the functor is a statement (usually a sequence of definitions that compute the exported values). This statement is a pattern position. Note the difference between this abbreviated declaration and the <<I>in statement</I>> rule: The <<I>statement</I>> following the <CODE><SPAN class="keyword">in</SPAN></CODE> keyword is optional, not the <<I>declaration part</I>> preceding it. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>functor descriptor</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">define</SPAN></CODE> <<I>declaration part</I>> [ <CODE><SPAN class="keyword">in</SPAN></CODE> <<I>statement</I>> ]</TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><DIV class="apropos"><P class="margin">Export Specification</P><P> The export specification specifies the structure the modules created by applications of this functor will have. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>functor descriptor</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">export</SPAN></CODE> { [ <<I>module feature</I>> <SPAN class="terminal">"<CODE>:</CODE>"</SPAN> ] <<I>variable</I>> }+</TD></TR></TABLE></BLOCKQUOTE><P> The value of the variables mentioned in the export declaration are made available under the given features. If a feature is omitted, then it is computed from the corresponding variable's print name by changing its initial capital letter into a lower-case letter (unless it's a backquote variable, in which case the print name is taken as-is). </P></DIV><P> All variables introduced in the import and the body are visible in the export declaration. </P><DIV class="apropos"><P class="margin">Computed Functors</P><P> A functor that contains one of the following additional functor descriptors is called a <EM>computed functor</EM>. The <CODE><SPAN class="keyword">require</SPAN></CODE> and <CODE><SPAN class="keyword">prepare</SPAN></CODE> clauses correspond to the <CODE><SPAN class="keyword">import</SPAN></CODE> and <CODE><SPAN class="keyword">define</SPAN></CODE> clauses respectively, only they are executed upon functor definition instead of functor application. The variables introduced by these clauses are visible in the <CODE><SPAN class="keyword">define</SPAN></CODE> and <CODE><SPAN class="keyword">export</SPAN></CODE> clauses. </P><BLOCKQUOTE><TABLE border="0" cellpadding="0" cellspacing="0"><TR valign="top"><TD><<I>functor descriptor</I>></TD><TD align="center"> += </TD><TD><CODE><SPAN class="keyword">require</SPAN></CODE> { <<I>import clause</I>> }+</TD></TR><TR valign="top"><TD></TD><TD align="center"> | </TD><TD><CODE><SPAN class="keyword">prepare</SPAN></CODE> <<I>declaration part</I>> [ <CODE><SPAN class="keyword">in</SPAN></CODE> <<I>statement</I>> ]</TD></TR></TABLE></BLOCKQUOTE><P> </P></DIV><DIV id="section.context-free.operators"><H2><A name="section.context-free.operators">3.5 Operator Associativity and Precedence</A></H2><P> The grammar given above is ambiguous. Some ambiguities do not affect the semantics (such as associativity of <<I>statement</I>>s and <<I>declaration part</I>>s). Those that do are resolved according to the following table stating the associativity of operators in increasing order of precedence: </P><TABLE align="center" bgcolor="#f0f0e0"><TR valign="top"><TH><P>Operators</P></TH><TH><P>Associativity</P></TH></TR><TR valign="top"><TD><P><CODE>X=Y</CODE></P></TD><TD><P>right</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword"><-</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">:=</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">.</SPAN>Y<SPAN class="keyword">:=</SPAN>Z</CODE></P></TD><TD><P>right</P></TD></TR><TR valign="top"><TD><P><CODE>X <SPAN class="keyword">orelse</SPAN> Y</CODE></P></TD><TD><P>right</P></TD></TR><TR valign="top"><TD><P><CODE>X <SPAN class="keyword">andthen</SPAN> Y</CODE></P></TD><TD><P>right</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">==</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">\=</SPAN>Y</CODE> <CODE>X<SPAN class="keyword"><</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">=<</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">></SPAN>Y</CODE> <CODE>X<SPAN class="keyword">>=</SPAN>Y</CODE></P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">=:</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">\=:</SPAN>Y</CODE> <CODE>X<SPAN class="keyword"><:</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">=<:</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">>:</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">>=:</SPAN>Y</CODE></P></TD><TD><P>none</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">::</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">:::</SPAN>Y</CODE></P></TD><TD><P>none</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">|</SPAN>Y</CODE></P></TD><TD><P>right</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">#</SPAN>Y</CODE></P></TD><TD><P>mixfix</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">+</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">-</SPAN>Y</CODE></P></TD><TD><P>left</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">*</SPAN>Y</CODE> <CODE>X<SPAN class="keyword">/</SPAN>Y</CODE> <CODE>X <SPAN class="keyword">div</SPAN> Y</CODE> <CODE>X <SPAN class="keyword">mod</SPAN> Y</CODE></P></TD><TD><P>left</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">,</SPAN>Y</CODE></P></TD><TD><P>right</P></TD></TR><TR valign="top"><TD><P><CODE><SPAN class="keyword">~</SPAN>X</CODE></P></TD><TD><P>prefix</P></TD></TR><TR valign="top"><TD><P><CODE>X<SPAN class="keyword">.</SPAN>Y</CODE> <CODE>X^Y</CODE></P></TD><TD><P>left</P></TD></TR><TR valign="top"><TD><P><CODE><SPAN class="keyword">@</SPAN>X</CODE> <CODE><SPAN class="keyword">!!</SPAN>X</CODE></P></TD><TD><P>prefix</P></TD></TR></TABLE><P> ``Having higher precedence'' means ``binding tighter''; e. g., the expression <CODE>c<SPAN class="keyword">#</SPAN>X<SPAN class="keyword">.</SPAN>g = Y</CODE> is parsed as <CODE>(c<SPAN class="keyword">#</SPAN>(X<SPAN class="keyword">.</SPAN>g)) = Y</CODE>. </P><P> Attempts to exploit associativity of non-associative operators (without using parentheses to make the intention clear), as in <CODE>X <SPAN class="keyword"><</SPAN> Y <SPAN class="keyword"><</SPAN> Z</CODE>, are considered erroneous. </P></DIV></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node2.html#chapter.lexical"><< Prev</A></TD><TD><A href="index.html">- Up -</A></TD><TD><A href="node4.html#chapter.core">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.iscs.nus.edu.sg/~henz">Martin Henz</A> and <A href="http://www.ps.uni-sb.de/~kornstae/">Leif Kornstaedt</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|