src/final.lisp: Add function for interactively testing type parsing.
[sod] / doc / misc.tex
1 %%% -*-latex-*-
2 %%%
3 %%% Miscellaneous functionality
4 %%%
5 %%% (c) 2015 Straylight/Edgeware
6 %%%
7
8 %%%----- Licensing notice ---------------------------------------------------
9 %%%
10 %%% This file is part of the Sensible Object Design, an object system for C.
11 %%%
12 %%% SOD is free software; you can redistribute it and/or modify
13 %%% it under the terms of the GNU General Public License as published by
14 %%% the Free Software Foundation; either version 2 of the License, or
15 %%% (at your option) any later version.
16 %%%
17 %%% SOD is distributed in the hope that it will be useful,
18 %%% but WITHOUT ANY WARRANTY; without even the implied warranty of
19 %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 %%% GNU General Public License for more details.
21 %%%
22 %%% You should have received a copy of the GNU General Public License
23 %%% along with SOD; if not, write to the Free Software Foundation,
24 %%% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26 \chapter{Miscellaneous functionality} \label{ch:misc}
27
28 %%%--------------------------------------------------------------------------
29 \section{Utilities} \label{sec:misc.utilities}
30
31 These symbols are defined in the @|sod-utilities| package.
32
33 \begin{describe}{mac}
34 {with-gensyms (@{ @<var> @! (@<var> @[@<name>@]) @}^*) \\ \ind
35 @<declaration>^* \\
36 @<form>^*}
37 \end{describe}
38
39 \begin{describe}{mac}
40 {once-only (@[[ :environment @<env> @]]
41 @{ @<var> @! (@<var> @[@<value-form>@]) @}^*) \\ \ind
42 @<declaration>^* \\
43 @<form>^*}
44 \end{describe}
45
46 \begin{describe}{mac}
47 {parse-body @<body> \&key :docp :declp
48 @> @<doc-string> @<declarations> @<body-forms>}
49 \end{describe}
50
51 \begin{describe}{cls}{loc}
52 \end{describe}
53
54 \begin{describe}{fun}{locp @<object> @> @<generalized-boolean>}
55 \end{describe}
56
57 \begin{describe}{mac}{locf @<place> @> @<locative>}
58 \end{describe}
59
60 \begin{describe*}
61 {\dhead{fun}{ref @<locative> @> @<value>}
62 \dhead{fun}{setf (ref @<locative>) @<value>}}
63 \end{describe*}
64
65 \begin{describe}{mac}
66 {with-locatives
67 @{ @<var> @! (@{ @<var> @!
68 (@<var> @[@<locative>@]) @}^*) @} \\ \ind
69 @<declaration>^* \\
70 @<form>^*}
71 \end{describe}
72
73 \begin{describe}{sym}{it}
74 \end{describe}
75
76 \begin{describe}{mac}{aif @<condition> @<consequent> @[@<alt>@]}
77 \end{describe}
78
79 \begin{describe}{mac}{awhen @<condition> @<form>^*}
80 \end{describe}
81
82 \begin{describe}{mac}{acond @{ (@<condition> @<form>^*) @}^*}
83 \end{describe}
84
85 \begin{describe*}
86 {\dhead{mac}
87 {acase @<scrutinee> @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*}
88 \dhead{mac}
89 {aecase @<scrutinee> @{ (@{ @<case> @! (@<case>^*) @} @<form>^*) @}^*}
90 \dhead{mac}{atypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*}
91 \dhead{mac}{aetypecase @<scrutinee> @{ (@<type> @<form>^*) @}^*}}
92 \end{describe*}
93
94 \begin{describe}{mac}{asetf @{ @<place> @<value> @}^*}
95 \end{describe}
96
97 \begin{describe}{gf}{instance-initargs @<instance>}
98 \end{describe}
99
100 \begin{describe*}
101 {\dhead{fun}{copy-instance @<instance> \&rest @<initargs>}
102 \dhead{gf}{copy-instance-using-class @<class> @<instance>
103 \&rest @<initargs>}}
104 \end{describe*}
105
106 \begin{describe*}
107 {\dhead{gf}{generic-function-methods @<generic-function> @> @<list>}
108 \dhead{gf}{method-specializers @<method> @> @<list>}
109 \dhead{cls}{eql-specializer}
110 \dhead{gf}{eql-specializer-object @<specializer> @> @<value>}}
111 \end{describe*}
112
113 \begin{describe}{fun}{make-list-builder \&optional @<initial> @> @<builder>}
114 \end{describe}
115
116 \begin{describe}{fun}{lbuild-add @<builder> @<item> @> @<builder>}
117 \end{describe}
118
119 \begin{describe}{fun}{lbuild-add-list @<builder> @<list> @> @<builder>}
120 \end{describe}
121
122 \begin{describe}{fun}{lbuild-list @<builder> @> @<list>}
123 \end{describe}
124
125 \begin{describe}{fun}
126 {mappend @<function> @<list> \&rest @<more-lists> @> @<result-list>}
127 \end{describe}
128
129 \begin{describe}{cls}{inconsistent-merge-error (error) \&key :candidates}
130 \end{describe}
131
132 \begin{describe}{gf}{merge-error-candidates @<error> @> @<list>}
133 \end{describe}
134
135 \begin{describe}{fun}
136 {merge-lists @<lists> \&key :pick (:test \#'eql) @> @<list>}
137 \end{describe}
138
139 \begin{describe}{mac}
140 {categorize (\=@<item-var> @<items>
141 @[[ :bind (@{ @<var> @! (@<var> @[@<value>@]) @}^*) @]])
142 \\ \ind\ind
143 (@{ (@<cat-var> @<cat-predicate>) @}^*) \- \\
144 @<declaration>^* \\
145 @<body-form>^* \-
146 \nlret @<value>^*}
147 \end{describe}
148
149 \begin{describe}{fun}
150 {frob-identifier @<string> \&key :swap-case :swap-hyphen
151 @> @<frobbed-string>}
152 \end{describe}
153
154 \begin{describe}{fun}{whitespace-char-p @<character> @> @<generic-function>}
155 \end{describe}
156
157 \begin{describe}{fun}
158 {update-position @<character> @<line> @<column>
159 @> @<new-line> @<new-column>}
160 \end{describe}
161
162 \begin{describe}{fun}
163 {backtrack-position @<character> @<line> @<column>
164 @> @<old-line> @<old-column>}
165 \end{describe}
166
167 \begin{describe}{fun}
168 {compose @<function> \&rest @<more-functions> @> @<function>}
169 \end{describe}
170
171 \begin{describe}{fun}{symbolicate \&rest @<symbols> @> @<symbol>}
172 \end{describe}
173
174 \begin{describe}{mac}
175 {maybe-print-unreadable-object (@<object> @<stream>
176 @[[ :type @<type> @!
177 :identity @<identity> @]]) \\ \ind
178 @<declaration>^* \\
179 @<form>^*}
180 \end{describe}
181
182 \begin{describe}{fun}{print-ugly-stuff @<stream> @<func> @> @<value>^*}
183 \end{describe}
184
185 \begin{describe}{mac}
186 {dosequence (@<var> @<sequence>
187 @[[ :start @<start> @! :end @<end> @!
188 :indexvar @<var> @]]) \\ \ind
189 @<declaration>^* \\
190 @{ @<tag> @! @<statement> @}^*}
191 \end{describe}
192
193 \begin{describe}{mac}
194 {define-access-wrapper @<from> @<to>
195 @[[ :read-only @<read-only-flag> @]]}
196 \end{describe}
197
198 \begin{describe}{mac}
199 {default-slot (@<instance> @<slot> @[@<slot-names>@]) \\ \ind
200 @<form>^*}
201 \end{describe}
202
203 \begin{describe}{mac}
204 {define-on-demand-slot @<class> @<slot> (@<instance>) \\ \ind
205 @[[ @<declaration>^* @! @<doc-string> @]] \\
206 @<form>^*}
207 \end{describe}
208
209 %%%--------------------------------------------------------------------------
210 \section{Condition utilities} \label{sec:misc.condition}
211
212 These symbols are defined in the @|sod-parser| package.
213
214 \begin{describe}{cls}{enclosing-condition (condition) \&key :condition}
215 \end{describe}
216
217 \begin{describe}{gf}
218 {enclosed-condition @<enclosing-condition> @> @<condition>}
219 \end{describe}
220
221 \begin{describe}{fun}{cerror* @<datum> \&rest @<arguments>}
222 \end{describe}
223
224 %%%--------------------------------------------------------------------------
225 \section{Option parser} \label{sec:misc.optparse}
226
227 These symbols are defined in the @!optparse| package.
228
229 \begin{describe}{fun}{exit \&optional (@<code> 0) \&key :abrupt}
230 \end{describe}
231
232 \begin{describe}{var}{*program-name*}
233 \end{describe}
234
235 \begin{describe}{var}{*command-line*}
236 \end{describe}
237
238 \begin{describe}{fun}{set-command-line-arguments}
239 \end{describe}
240
241 \begin{describe}{fun}{moan @<format-string> \&rest @<format-args>}
242 \end{describe}
243
244 \begin{describe}{fun}{die @<format-string> \&rest @<format-args>}
245 \end{describe}
246
247 \begin{describe}{var}{*options*}
248 \end{describe}
249
250 \begin{describe}{cls}{option}
251 \end{describe}
252
253 \begin{describe}{fun}{optionp @<object> @> @<generalized-boolean>}
254 \end{describe}
255
256 \begin{describe}{fun}
257 {make-option \=@<long-name> @<short-name> \+ \\
258 \&optional @<arg-name> \\
259 \&key :tag :negated-tag :arg-optional-p :documentation \-
260 \nlret @<option>}
261 \end{describe}
262
263 \begin{describe*}
264 {\dhead{fun}{opt-short-name @<option> @> @<character-or-null>}
265 \dhead{fun}{setf (opt-short-name @<option>) @<character-or-null>}
266 \dhead{fun}{opt-long-name @<option> @> @<string-or-null>}
267 \dhead{fun}{setf (opt-long-name @<option>) @<string-or-null>}
268 \dhead{fun}{opt-tag @<option> @> @<tag>}
269 \dhead{fun}{setf (opt-tag @<option>) @<tag>}
270 \dhead{fun}{opt-negated-tag @<option> @> @<tag>}
271 \dhead{fun}{setf (opt-negated-tag @<option>) @<tag>}
272 \dhead{fun}{opt-arg-name @<option> @> @<string-or-null>}
273 \dhead{fun}{setf (opt-arg-name @<option>) @<string-or-null>}
274 \dhead{fun}{opt-optional-p @<option> @> @<generalized-boolean>}
275 \dhead{fun}{setf (opt-optional-p @<option>) @<generalized-boolean>}
276 \dhead{fun}{opt-documentation @<option> @> @<string-or-null>}
277 \dhead{fun}{setf (opt-documentation @<option>) @<string-or-null>}}
278 \end{describe*}
279
280 \begin{describe}{cls}{option-parser}
281 \end{describe}
282
283 \begin{describe}{fun}{option-parser-p @<object> @> @<generalized-boolean>}
284 \end{describe}
285
286 \begin{describe}{fun}
287 {make-option-parser \&key \=:args :options :non-option :numericp \+ \\
288 :negated-numeric-p long-only-p \-
289 \nlret @<option-parser>}
290 \end{describe}
291
292 \begin{describe*}
293 {\dhead{fun}{op-options @<option-parser> @> @<list>}
294 \dhead{fun}{setf (op-options @<option-parser>) @<list>}
295 \dhead{fun}{op-non-option @<option-parser> @> @<action>}
296 \dhead{fun}{setf (op-non-option @<option-parser>) @<action>}
297 \dhead{fun}{op-long-only-p @<option-parser> @> @<generalized-boolean>}
298 \dhead{fun}{setf (op-long-only-p @<option-parser>) @<generalized-boolean>}
299 \dhead{fun}{op-numeric-p @<option-parser> @> @<generalized-boolean>}
300 \dhead{fun}{setf (op-numeric-p @<option-parser>) @<generalized-boolean>}
301 \dhead{fun}{op-negated-numeric-p @<option-parser> @<generalized-boolean>}
302 \dhead{fun}{setf (op-negated-numeric-p @<option-parser>) @<generalized-boolean>}
303 \dhead{fun}{op-negated-p @<option-parser> @> @<generalized-boolean>}
304 \dhead{fun}{setf (op-negated-p @<option-parser>) @<generalized-boolean>}}
305 \end{describe*}
306
307 \begin{describe}{cls}
308 {option-parse-error (error simple-condition)
309 \&key :format-control :format-arguments}
310 \end{describe}
311
312 \begin{describe}{fun}{option-parse-remainder @<option-parser>}
313 \end{describe}
314
315 \begin{describe}{fun}{option-parse-return @<tag> \&optional @<argument>}
316 \end{describe}
317
318 \begin{describe}{fun}{option-parse-next @<option-parser>}
319 \end{describe}
320
321 \begin{describe}{mac}{option-parse-try @<form>^*}
322 \end{describe}
323
324 \begin{describe}{mac}{with-unix-error-reporting () @<form>^*}
325 \end{describe}
326
327 \begin{describe}{mac}
328 {defopthandler @<name> (@<var> @[@<arg>@]) @<lambda-list> \\ \ind
329 @[[ @<declaration>^* @! @<doc-string> @]] \\
330 @<form>^*}
331 \end{describe}
332
333 \begin{describe}{fun}
334 {invoke-option-handler @<handler> @<locative> @<arg> @<arguments>}
335 \end{describe}
336
337 \begin{describe}{opt}{set \&optional @<value>}
338 \end{describe}
339
340 \begin{describe}{opt}{clear \&optional @<value>}
341 \end{describe}
342
343 \begin{describe}{opt}{inc \&optional @<maximum> @<step>}
344 \end{describe}
345
346 \begin{describe}{opt}{dec \&optional <minimum> <step>}
347 \end{describe}
348
349 \begin{describe}{opt}{read}
350 \end{describe}
351
352 \begin{describe}{opt}{int \&key :radix :min :max}
353 \end{describe}
354
355 \begin{describe}{opt}{string}
356 \end{describe}
357
358 \begin{describe}{opt}{keyword \&optional @<valid>}
359 \end{describe}
360
361 \begin{describe}{opt}{list \&optional @<handler> \&rest @<handler-args>}
362 \end{describe}
363
364 \begin{describe}{mac}
365 {defoptmacro @<name> @<lambda-list> \\ \ind
366 @[[ @<declaration>^* @! @<doc-string> @]] \\
367 @<form>^*}
368 \end{describe}
369
370 \begin{describe}{fun}{parse-option-form @<form>}
371 \end{describe}
372
373 \begin{describe}{mac}
374 {options @{ \=@<string> @! \+ \\
375 @<option-macro> @! (@<option-macro> @<macro-arg>^*) @! \\
376 (@[[ \=@<character> @! (:short-name @<character>) @! \+ \\
377 @<string>^* @! @<symbol> @! @<rational> @!
378 (:long-name @<string>) @! \\
379 (@<string> @<format-arg>^+) @!
380 (:doc @<string> @<format-arg>^*) @! \\
381 (:arg @<arg-name>) @! (:opt-arg @<arg-name>) @! \\
382 @<keyword> @! (:tag @<tag>) @!
383 (:negated-tag @<tag>) @! \\
384 @{ (@<handler> @<var> @<handler-arg>^*) @}^*
385 @]]) @}^*}
386 \end{describe}
387
388 \begin{describe}{fun}
389 {simple-usage @<option-list> \&optional @<mandatory-args> @> @<list>}
390 \end{describe}
391
392 \begin{describe}{fun}{show-usage @<prog> @<usage> \&optional @<stream>}
393 \end{describe}
394
395 \begin{describe}{fun}
396 {show-help @<prog> @<usage> @<option-list> \&optional @<stream>}
397 \end{describe}
398
399 \begin{describe}{fun}{sanity-check-option-list @<option-list>}
400 \end{describe}
401
402 \begin{describe*}
403 {\dhead{var}{*help*}
404 \dhead{var}{*version*}
405 \dhead{var}{*usage*}}
406 \end{describe*}
407
408 \begin{describe}{fun}{do-usage \&optional @<stream>}
409 \end{describe}
410
411 \begin{describe}{fun}{die-usage}
412 \end{describe}
413
414 \begin{describe}{optmac}
415 {help-options \&key :short-help :short-version :short-usage}
416 \end{describe}
417
418 \begin{describe}{fun}
419 {define-program \&key \=:program-name \+ \\
420 :help :version :usage :full-usage \\
421 :options}
422 \end{describe}
423
424 \begin{describe}{mac}
425 {do-options (@[[ :parser @<option-parser> @]]) \\ \ind
426 @{ (@{ @<case> @! (@<case>^*)@} (@[@[@<opt-var>@] @<arg-var>@])
427 @<form>^*) @}^*}
428 \end{describe}
429
430 %%%--------------------------------------------------------------------------
431 \section{Property sets} \label{sec:misc.pset}
432
433 \begin{describe}{fun}{property-key @<name> @> @<keyword>}
434 \end{describe}
435
436 \begin{describe}{gf}{decode-property @<raw-value> @> @<type> @<value>}
437 \end{describe}
438
439 \begin{describe}{cls}{property}
440 \end{describe}
441
442 \begin{describe}{fun}{propertyp @<object> @> @<generalized-boolean>}
443 \end{describe}
444
445 \begin{describe}{fun}
446 {make-property @<name> @<raw-value> \&key :type :location :seenp}
447 \end{describe}
448
449 \begin{describe*}
450 {\dhead{fun}{p-name @<property> @> @<name>}
451 \dhead{fun}{p-value @<property> @> @<value>}
452 \dhead{fun}{p-type @<property> @> @<type>}
453 \dhead{fun}{p-key @<property> @> @<symbol>}
454 \dhead{fun}{p-seenp @<property> @> @<boolean>}
455 \dhead{fun}{setf (p-seenp @<property>) @<boolean>}}
456 \end{describe*}
457
458 \begin{describe}{gf}{decode-property @<raw-value> @> @<type> @<value>}
459 \end{describe}
460
461 \begin{describe}{gf}
462 {coerce-property-value @<value> @<type> @<wanted> @> @<coerced-value>}
463 \end{describe}
464
465 \begin{describe}{cls}{pset}
466 \end{describe}
467
468 \begin{describe}{fun}{psetp @<object> @> @<generalized-boolean>}
469 \end{describe}
470
471 \begin{describe}{fun}{make-pset @> @<pset>}
472 \end{describe}
473
474 \begin{describe}{fun}{pset-get @<pset> @<key> @> @<property-or-nil>}
475 \end{describe}
476
477 \begin{describe}{fun}{pset-store @<pset> @<property> @> @<property>}
478 \end{describe}
479
480 \begin{describe}{fun}{pset-map @<func> @<pset>}
481 \end{describe}
482
483 \begin{describe}{mac}
484 {with-pset-iterator (@<iter> @<pset>) @<declaration>^* @<form>^*}
485 \end{describe}
486
487 \begin{describe}{fun}
488 {store-property @<pset> @<name> @<value> \&key :type :location
489 @> @<property>}
490 \end{describe}
491
492 \begin{describe}{fun}
493 {get-property @<pset> @<name> @<type> \&optional @<default>
494 @> @<value> @<floc-or-nil>}
495 \end{describe}
496
497 \begin{describe}{fun}
498 {add-property @<pset> @<name> @<value> \&key :type :location
499 @> @<property>}
500 \end{describe}
501
502 \begin{describe}{fun}{make-property-set \&rest @<plist> @> @<pset>}
503 \end{describe}
504
505 \begin{describe}{gf}{property-set @<thing> @> @<pset>}
506 \end{describe}
507
508 \begin{describe}{fun}{check-unused-properties @<pset>}
509 \end{describe}
510
511 \begin{describe}{mac}
512 {default-slot-from-property
513 (@<instance> @<slot> @[@<slot-names>@]) \\ \ind\ind
514 (@<pset> @<property> @<type> @[@<prop-var> @<convert-form>^*@]) \- \\
515 @<declaration>^* \\
516 @<default-form>^*}
517 \end{describe}
518
519 \begin{describe}{fun}
520 {parse-property-set @<scanner>
521 @> @<result> @<success-flag> @<consumed-flag>}
522 \end{describe}
523
524 %%%--------------------------------------------------------------------------
525 \section{Miscellaneous translator features} \label{sec:misc.pset}
526
527 \begin{describe}{var}{*sod-version*}
528 \end{describe}
529
530 \begin{describe}{var}{*debugout-pathname*}
531 \end{describe}
532
533 \begin{describe}{fun}{test-module @<path> @<reason>}
534 \end{describe}
535
536 \begin{describe}{fun}
537 {test-parse-c-type @<string>
538 @> t @<c-type> @<kernel> @<string> @! nil @<indicator>}
539 \end{describe}
540
541 \begin{describe}{mac}
542 {test-parser (@<scanner>) @<parser> @<input>
543 @> @<success-flag> @<result> @<remainder>}
544 \end{describe}
545
546 \begin{describe}{fun}{exercise}
547 \end{describe}
548
549 \begin{describe}{fun}{sod-frontend:main}
550 \end{describe}
551
552 %%%----- That's all, folks --------------------------------------------------
553
554 %%% Local variables:
555 %%% mode: LaTeX
556 %%% TeX-master: "sod.tex"
557 %%% TeX-PDF-mode: t
558 %%% End: