| 1 |
<html><head><title>XLISP :nmacro</title> |
| 2 |
|
| 3 |
<link rel="stylesheet" type="text/css" href="reference.css"> |
| 4 |
|
| 5 |
</head> |
| 6 |
|
| 7 |
<body> |
| 8 |
|
| 9 |
<a href="../start.htm">Nyquist / XLISP 2.0</a> - |
| 10 |
<a href="../manual/contents.htm">Contents</a> | |
| 11 |
<a href="../tutorials/tutorials.htm">Tutorials</a> | |
| 12 |
<a href="../examples/examples.htm">Examples</a> | |
| 13 |
<a href="reference-index.htm">Reference</a> |
| 14 |
|
| 15 |
<hr> |
| 16 |
|
| 17 |
<h1>:nmacro</h1> |
| 18 |
|
| 19 |
<hr> |
| 20 |
|
| 21 |
<p><table cellpadding="0" cellspacing="0" style="margin-left:10px"><tbody> |
| 22 |
<tr valign="top"> |
| 23 |
<td><nobr>Type:</nobr></td> |
| 24 |
<td><nobr> - </nobr></td> |
| 25 |
<td width="100%"><nobr>keyword</nobr></td> |
| 26 |
</tr> |
| 27 |
<tr valign="top"> |
| 28 |
<td><nobr>Source:</nobr></td> |
| 29 |
<td><nobr> - </nobr></td> |
| 30 |
<td width="100%"><nobr>xlread.c</nobr></td> |
| 31 |
</tr> |
| 32 |
</tbody></table></p> |
| 33 |
|
| 34 |
<h2>Syntax</h2> |
| 35 |
|
| 36 |
<dl> |
| 37 |
<dt>(:nmacro . <i>function</i>)</dt> |
| 38 |
<dd><i>function</i> - a function</dd> |
| 39 |
</dl> |
| 40 |
|
| 41 |
<h2>Description</h2> |
| 42 |
|
| 43 |
<p>':nmacro' is an entry that is used in the |
| 44 |
<a href="global-readtable.htm">*readtable*</a> system variable that contains |
| 45 |
XLISP's data structures relating to the processing of characters from the |
| 46 |
user [or files] and read-macro expansions. The existance of the ':nmacro' |
| 47 |
keyword means that the specified character is the start of a non-terminal |
| 48 |
read macro. For ':nmacro', the form of the |
| 49 |
<a href="global-readtable.htm">*readtable*</a> entry is a dotted pair |
| 50 |
like:</p> |
| 51 |
|
| 52 |
<pre class="example"> |
| 53 |
(:nmacro . <font color="#008844"><i>function</i></font>) |
| 54 |
</pre> |
| 55 |
|
| 56 |
<p>The 'function' can be a built-in read-macro function or a user defined |
| 57 |
lambda expression. The 'function' takes two parameters, an input stream |
| 58 |
specification, and an integer that is the character value. The 'function' |
| 59 |
should return <a href="nil.htm">NIL</a> if the character is |
| 60 |
'white-space' or a value <a href="cons.htm">cons</a>ed with |
| 61 |
<a href="nil.htm">NIL</a> to return the value. The 'function' |
| 62 |
will probably read additional characters from the input stream.</p> |
| 63 |
|
| 64 |
<h2>Examples</h2> |
| 65 |
|
| 66 |
<pre class="example"> |
| 67 |
(defun look-at (table) <font color="#008844">; define a function to</font> |
| 68 |
(dotimes (ch 127) <font color="#008844">; look in a table</font> |
| 69 |
(prog ((entry (aref table ch))) <font color="#008844">; and print out any</font> |
| 70 |
(if (and (consp entry) <font color="#008844">; :NMACRO entries</font> |
| 71 |
(equal (car entry) |
| 72 |
':nmacro)) |
| 73 |
(princ (int-char ch))))) |
| 74 |
(terpri)) |
| 75 |
(look-at *readtable*) <font color="#008844">; prints #</font> |
| 76 |
</pre> |
| 77 |
|
| 78 |
<p><b>Note:</b> The system defines that the hash [#] character is a |
| 79 |
non-terminal. This is because the hash is used for a variety of 'read macro |
| 80 |
expansions' including <a href="function.htm">function</a>, an |
| 81 |
<a href="../misc/ascii-table.htm">ASCII</a> code, and hexadecimal |
| 82 |
numbers.</p> |
| 83 |
|
| 84 |
<p><b>Caution:</b> If you experiment with |
| 85 |
<nobr><a href="global-readtable.htm">*readtable*</a> ,</nobr> it is useful |
| 86 |
to save the old value in a variable, so that you can restore the system |
| 87 |
state.</p> |
| 88 |
|
| 89 |
<p>See the |
| 90 |
<a href="../manual/manual/xlisp-man-008.htm#nmacro">:nmacro</a> |
| 91 |
keyword in the <nobr>XLISP 2.0</nobr> manual.</p> |
| 92 |
|
| 93 |
<p><nobr> <a href="#top">Back to Top</nobr></a></p> |
| 94 |
|
| 95 |
<hr> |
| 96 |
|
| 97 |
<a href="../start.htm">Nyquist / XLISP 2.0</a> - |
| 98 |
<a href="../manual/contents.htm">Contents</a> | |
| 99 |
<a href="../tutorials/tutorials.htm">Tutorials</a> | |
| 100 |
<a href="../examples/examples.htm">Examples</a> | |
| 101 |
<a href="reference-index.htm">Reference</a> |
| 102 |
|
| 103 |
</body></html> |