-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmufcomp.html
More file actions
150 lines (123 loc) · 4.93 KB
/
Copy pathmufcomp.html
File metadata and controls
150 lines (123 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<html>
<head>
<title>The MUCK Manual: MUF Compiler Directives</title>
</head>
<body bgcolor="#FFFFFF">
<center>
<a href="mufmacs.html">prev</a>|
<a href="toc.html">toc</a>|
<a href="mufref.html">next</a>
</center>
<table>
<tr>
<td width="20%"> </tc>
<td>
<!-- BODY CONTENT HERE -->
<p><b>3.2.4 MUF Compiler Directives</b></p>
<p>Compiler directives — additional instructions that the server
executes before or while compiling your code — were introduced in
the <a href="muf12.html">MUF Overview</a>. Below is a more complete
reference of the available compiler directives.</p>
<hr>
<p><code>$define <definition name> <definition> $enddef</code></p>
<p>This redefines <code><definition name></code> such that all
instances of it will be replaced with <code><definition></code>
when the program is compiled.</p><hr>
<p><code>$undef <defname></code></p>
<p>This undefines <code><defname></code>, making it an undefined
value for the compiler. Its primary use is to allow compiler directives
to be included in the source code without their being invoked by the
compiler. For example, you might have a program that should be compiled
differently if running at Mucker Level 3 rather than Mucker Level 2. You
could include the following lines in your code...
<p><code>
====================================<br>
$define MLev2 (* Undefine this if the program is set M3 *)<br>
$undef MLev3 (* Define this if the program is set M2 *) <br>
====================================
</code></p>
<p>This way, the person compiling the program would have an example of
each valid form, even though only one is being invoked.</p><hr>
<p><code>$echo <string></code></p>
This outputs <string> to the person compiling the program, at
compile time. Example:
<p><code>
====================================<br>
$echo Compiling multi-guest.muf... <br>
$echo See header comment for configuration instructions.<br>
====================================
</code></p><hr>
<p><code>__version</code></p>
This is a pre-defined macro that is replaced at compile time with the
current server version. It would be useful for tests to ensure that the
server version can support all the primitives used in your program. The
replacement string will be the same as that returned by the
<code>VERSION</code> primitive.</p><hr>
<p><code>$ifdef <condition> <br>
<compile-if-true> <br>
$else <br>
<compile-if-false> <br>
$endif<br>
<br>
$ifndef <condition> <br>
<compile-if-true> <br>
$else <br>
<compile-if-false> <br>
$endif<br></code>
<p>These cause conditional compilation of blocks of code, based on
<code><condition></code>. <code><Condition></code> can be a
<code>$defined name</code>, or a test that consists of a comparator such
as =, <, or > and a test value, all in one word, without
whitespace. The else clause is optional. Comiler directives are
nestable. Example:</p>
<p><code>
====================================<br>
$ifndef __version>Muck2.2fb3.5 <br>
$define envprop .envprop $enddef <br>
$endif<br>
<br>
$define ploc <br>
<br>
$ifdef proplocs .proploc $else $endif $enddef<br>
====================================
</code></p><hr>
<p><code>$include <program></code></p>
<p>This creates <code>$defines</code> based on the <code>_defs/</code>
propdir of <code><program>.</code> For example, if object
<code>#345</code> had the following properties...</p>
<p><code>
====================================<br>
/_defs/desc: "_/de" getpropstr<br>
/_defs/setpropstr: dup if 0 addprop else pop remove_prop then<br>
/_defs/setpropval: dup if "" swap addprop else pop remove_prop then<br>
/_defs/setprop: dup int? if setpropval else setpropstr then<br>
====================================
</code></p>
<p>... then a program that contains the line <code>$include #345</code>
would be compiled such that all instances of <code>desc,</code>
<code>setpropstr,</code> <code>setpropval,</code> and
<code>setprop</code> would be preplaced with their respective
definitions on <code>#345</code>.</p><hr>
<p>Escaped statements will be read literally, rather than interpreted and
expanded by the compiler, which allows primitives and macros to be
included in <code>$defines</code>. Example:
<p><code>
====================================<br>
$define addprop over over or if \addprop else pop pop remove_prop<br>
$enddef <br>
====================================
</code></p>
<p>In this case, <code>ADDPROP</code> will be expanded in the program
itself, but the compiler will not recursively expand it... it will call
the actual, in-server <code>ADDPROP</code>.</p>
<center>
<a href="mufmacs.html">prev</a>|
<a href="toc.html">toc</a>|
<a href="#top">top</a>|
<a href="mufref.html">next</a>
</center>
</td>
<td width="20%"> </tc>
</table>
</body>
</html>