chiark / gitweb /
src/method-{proto,impl}.lisp: Introduce `effective-method-live-p' protocol.
[sod] / src / sod-module.5
1 .\" -*-nroff-*-
2 .\"
3 .\" The Sod module syntax
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 .\" Highlight using terminal escapes, rather than overstriking.
27 .\"\X'tty: sgr 1'
28 .
29 .\" String definitions and font selection.
30 .ie t \{\
31 .  ds o \(bu
32 .  if \n(.g .fam P
33 .\}
34 .el \{\
35 .  ds o o
36 .\}
37 .
38 .\" .hP TEXT -- start an indented paragraph with TEXT hanging off to the left
39 .de hP
40 .IP
41 \h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
42 ..
43 .
44 .\" An epsilon, or e.
45 .ie t \{\
46 .  ds e \(*e
47 .  ds ^ \v'-.3m'\s'\\n(.s*7/10'
48 .  ds ^e \s0\v'.3m'
49 .  ds _ \v'.3m'\s'\\n(.s*7/10'
50 .  ds _e \s0\v'-.3m'
51 .\}
52 .el \{
53 .  ds e \fIe\fR
54 .  ds ^ ^
55 .  ds ^e
56 .  ds _ _
57 .  ds _e
58 .\}
59 .ds * \*^\(**\*(^e
60 .ds + \*^+\*(^e
61 .
62 .de |
63 .br
64 \h'4n'|
65 ..
66 .ie t \{\
67 .  de <
68 ..
69 .\}
70 .el
71 .  de <
72 .    br
73 \h'4n'
74 ..
75 .\}
76 .
77 .\"--------------------------------------------------------------------------
78 .TH sod 5 "11 October 2015" "Straylight/Edgeware" "Sensible Object Design"
79 .
80 .SH NAME
81 sod-module \- Sensible Object Design module syntax
82 .
83 .\"--------------------------------------------------------------------------
84 .SH DESCRIPTION
85 This manual page provides a highly compressed description of the
86 Sod module syntax.
87 For full details, consult the main manual.
88 .PP
89 .SS Notation
90 Anywhere a simple nonterminal name
91 .I x
92 may appear in the grammar,
93 an
94 .I indexed
95 nonterminal
96 .IR x [ a \*_1\*(_e,
97 \&...,
98 .IR a \*_ n \*(_e]
99 may also appear.
100 On the left-hand side of a production rule,
101 the indices
102 .IR a \*_1\*(_e,
103 \&...,
104 .IR a \*_ n \*(_e
105 are variables which vary over all nonterminal and terminal symbols,
106 and the variables may also appear on the right-hand side
107 in place of a nonterminal.
108 Such a rule stands for a family of rules,
109 in each variable is replaced by
110 each possible simple nonterminal or terminal symbol.
111 .PP
112 The letter \*e denotes the empty nonterminal
113 .IP
114 .I \*e
115 ::=
116 .PP
117 The following indexed productions are used throughout the grammar, some often
118 enough that they deserve special notation.
119 .hP \*o
120 .RI [ x ]
121 abbreviates
122 .IR optional [ x ],
123 denoting an optional occurrence of
124 .IR x :
125 .RS
126 .IP
127 .RI [ x ]
128 ::=
129 .IR optional [ x ]
130 ::=
131 \*e
132 |
133 .I x
134 .RE
135 .hP \*o
136 .IR x \**
137 abbreviates
138 .IR zero-or-more [ x ],
139 denoting a sequence of zero or more occurrences of
140 .IR x :
141 .RS
142 .IP
143 .IR x \**
144 ::=
145 .IR zero-or-more [ x ]
146 ::=
147 \*e
148 |
149 .I x
150 .IR x \**
151 .RE
152 .hP \*o
153 .IR x \*+
154 abbreviates
155 .IR one-or-more [ x ]
156 denoting a sequence of one or more occurrences of
157 .IR x :
158 .RS
159 .IP
160 .IR x \*+
161 ::=
162 .IR one-or-more [ x ]
163 ::=
164 .I x
165 .IR x \**
166 .RE
167 .hP \*o
168 .IR list [ x ]
169 denotes a sequence of one or more occurrences of
170 .I x
171 separated by commas:
172 .RS
173 .IP
174 .IR list [ x ]
175 ::=
176 .I x
177 |
178 .IR list [ x ]
179 .B ,
180 .I x
181 .RE
182 .
183 .SS Special nonterminals
184 .I s-expression
185 ::=
186 an S-expression, as parsed by the Lisp reader
187 .br
188 .I c-fragment
189 ::=
190 a sequence of C tokens, with matching brackets
191 .
192 .\"--------------------------------------------------------------------------
193 .SH LEXICAL SYNTAX
194 .
195 .SS Tokens
196 .I token
197 ::=
198 .I identifier
199 .|
200 .I string-literal
201 .|
202 .I char-literal
203 .|
204 .I integer-literal
205 .|
206 .I punctuation
207 .
208 .SS Identifiers
209 .I identifier
210 ::=
211 .I id-start-char
212 .IR id-body-char \**
213 .br
214 .I id-start-char
215 ::=
216 .I alpha-char
217 |
218 .B _
219 .br
220 .I id-body-char
221 ::=
222 .I id-start-char
223 |
224 .I digit-char
225 .br
226 .I alpha-char
227 ::=
228 .B A
229 |
230 .B B
231 | ... |
232 .B Z
233 .|
234 .B a
235 |
236 .B b
237 | ... |
238 .B z
239 .|
240 .I extended-alpha-char
241 .br
242 .I digit-char
243 ::=
244 .B 0
245 |
246 .I nonzero-digit-char
247 .br
248 .I nonzero-digit-char
249 ::=
250 .B 1
251 |
252 .B 2
253 | ... |
254 .B 9
255 .PP
256 The characters matched by
257 .I extended-alpha-char
258 depend on the locale and the host Lisp system.
259 .
260 .SS String and character literals
261 .I string-literal
262 ::=
263 .B """"
264 .IR string-literal-char \**
265 .B """"
266 .br
267 .I char-literal
268 ::=
269 .B '
270 .IR char-literal-char \**
271 .B '
272 .br
273 .I string-literal-char
274 ::=
275 any character other than
276 .B \e
277 or
278 .B """"
279 .|
280 .B \e
281 .I char
282 .br
283 .I char-literal-char
284 ::=
285 any character other than
286 .B \e
287 or
288 .B '
289 .|
290 .B \e
291 .I char
292 .
293 .SS Integer literals
294 .I integer-literal
295 ::=
296 .I decimal-integer
297 .|
298 .I binary-integer
299 .|
300 .I octal-integer
301 .|
302 .I hex-integer
303 .br
304 .I decimal-integer
305 ::=
306 .B 0
307 |
308 .I nonzero-digit-char
309 .IR digit-char \**
310 .br
311 .I binary-integer
312 ::=
313 .B 0
314 .RB ( b | B )
315 .IR binary-digit-char \*+
316 .br
317 .I binary-digit-char
318 ::=
319 .B 0
320 |
321 .B 1
322 .br
323 .I octal-integer
324 ::=
325 .B 0
326 .RB [ o | O ]
327 .IR octal-digit-char \*+
328 .br
329 .I octal-digit-char
330 ::=
331 .B 0
332 |
333 .B 1
334 | ... |
335 .B 7
336 .br
337 .I hex-integer
338 ::=
339 .B 0
340 .RB ( x | X )
341 .IR hex-digit-char \*+
342 .br
343 .I hex-digit-char
344 ::=
345 .I digit-char
346 .|
347 .B A
348 |
349 .B B
350 |
351 .B C
352 |
353 .B D
354 |
355 .B E
356 |
357 .B F
358 .|
359 .B a
360 |
361 .B b
362 |
363 .B c
364 |
365 .B d
366 |
367 .B e
368 |
369 .B f
370 .
371 .SS Punctuation
372 .I punctuation
373 ::=
374 any non-alphanumeric character
375 other than
376 .BR _ ,
377 .BR """" ,
378 or
379 .B '
380 .
381 .SS Comments
382 .I comment
383 ::=
384 .I block-comment
385 .|
386 .I line-comment
387 .br
388 .I block-comment
389 ::=
390 .<
391 .B /*
392 .IR not-star \**
393 .RI ( star \*+
394 .I not-star-or-slash
395 .IR not-star \**)\**
396 .IR star \**
397 .B */
398 .br
399 .I star
400 ::=
401 .B *
402 .br
403 .I not-star
404 ::=
405 any character other than
406 .B *
407 .br
408 .I not-star-or-slash
409 ::=
410 any character other than
411 .B *
412 or
413 .B /
414 .br
415 .I line-comment
416 ::=
417 .B //
418 .IR not-newline \**
419 .I newline
420 .br
421 .I newline
422 ::=
423 a newline character
424 .br
425 .I not-newline
426 ::=
427 any character other than newline
428 .
429 .\"--------------------------------------------------------------------------
430 .SH MODULE SYNTAX
431 .
432 .I module
433 ::=
434 .IR definition \**
435 .br
436 .I definition
437 ::=
438 .I import-definition
439 .|
440 .I load-definition
441 .|
442 .I lisp-definition
443 .|
444 .I typename-definition
445 .|
446 .I code-definition
447 .|
448 .I class-definition
449 .
450 .SS Simple definitions
451 .I import-definition
452 ::=
453 .B import
454 .I string-literal
455 .B ;
456 .br
457 .I load-definition
458 ::=
459 .B load
460 .I string-literal
461 .B ;
462 .br
463 .I lisp-definition
464 ::=
465 .B lisp
466 .I s-expression
467 .B ;
468 .br
469 .I typename-definition
470 ::=
471 .B typename
472 .IR list [ identifier ]
473 .B ;
474 .
475 .SS Literal code fragments
476 .br
477 .I code-definition
478 ::=
479 .<
480 .B code
481 .I identifier
482 .B
483 .I item-name
484 .RI [ constraints ]
485 .B {
486 .I c-fragment
487 .B }
488 .br
489 .I constraints
490 ::=
491 .B [
492 .IR list [ constraint ]
493 .B ]
494 .br
495 .I constraint
496 ::=
497 .IR item-name \*+
498 .br
499 .I item-name
500 ::=
501 .I identifier
502 |
503 .B (
504 .IR identifier \*+
505 .B )
506 .
507 .SS Class definitions
508 .I
509 class-definition
510 ::=
511 .I class-forward-declaration
512 .|
513 .I full-class-definition
514 .br
515 .I class-forward-declaration
516 ::=
517 .B class
518 .I identifier
519 .B ;
520 .br
521 .I full-class-definition
522 ::=
523 .RI [ properties ]
524 .<
525 .B class
526 .I identifier
527 .B :
528 .IR list [ identifier ]
529 .<
530 .B {
531 .IR properties-class-item \**
532 .B }
533 .br
534 .I properties-class-item
535 ::=
536 .RI [ properties ]
537 .I class-item
538 .br
539 .I class-item
540 ::=
541 .I slot-item
542 .|
543 .I initializer-item
544 .|
545 .I message-item
546 .|
547 .I method-item
548 .br
549 .I slot-item
550 ::=
551 .<
552 .IR declaration-specifier \*+
553 .IR list [ init-declarator ]
554 .B ;
555 .br
556 .I init-declarator
557 ::=
558 .I simple-declarator
559 .RB [ =
560 .IR initializer ]
561 .br
562 .I initializer-item
563 ::=
564 .RB [ class ]
565 .IR list [ slot-initializer ]
566 .B ;
567 .br
568 .I slot-initializer
569 ::=
570 .I dotted-name
571 .B =
572 .I initializer
573 .br
574 .I initializer
575 ::=
576 .I c-fragment
577 .br
578 .I message-item
579 ::=
580 .<
581 .IR declaration-specifier \*+
582 .IR keyword-declarator [ identifier ]
583 .<
584 .RI [ method-body ]
585 .br
586 .I method-item
587 ::=
588 .<
589 .IR declaration-specifier \*+
590 .IR keyword-declarator [ dotted-name ]
591 .<
592 .I method-body
593 .br
594 .I method-body
595 ::=
596 .B {
597 .I c-fragment
598 .B }
599 |
600 .B extern
601 .B ;
602 .
603 .SS Property sets
604 .I properties
605 ::=
606 .B [
607 .IR list [ property ]
608 .B ]
609 .br
610 .I property
611 ::=
612 .I identifier
613 .B =
614 .I expression
615 .br
616 .I expression
617 ::=
618 .I term
619 |
620 .I expression
621 .B +
622 .I term
623 |
624 .I expression
625 .B \-
626 .I term
627 .br
628 .I term
629 ::=
630 .I factor
631 |
632 .I term
633 .B *
634 .I factor
635 |
636 .I term
637 .B /
638 .I factor
639 .br
640 .I factor
641 ::=
642 .I primary
643 |
644 .B +
645 .I factor
646 |
647 .B \-
648 .B factor
649 .br
650 .I primary
651 ::=
652 .I integer-literal
653 |
654 .I string-literal
655 .ie t |
656 .el .|
657 .I char-literal
658 |
659 .I identifier
660 .|
661 .B ?
662 .I s-expression
663 .|
664 .B (
665 .I expression
666 .B )
667 .
668 .SS C types
669 .I declaration-specifier
670 ::=
671 .I type-name
672 .|
673 .B struct
674 .I identifier
675 |
676 .B union
677 .I identifier
678 |
679 .B enum
680 .I identifier
681 .|
682 .B void
683 |
684 .B char
685 |
686 .B int
687 |
688 .B float
689 |
690 .B double
691 .|
692 .B short
693 |
694 .B long
695 .|
696 .B signed
697 |
698 .B unsigned
699 .|
700 .B bool
701 |
702 .B _Bool
703 .|
704 .B imaginary
705 |
706 .B _Imaginary
707 |
708 .B complex
709 |
710 .B _Complex
711 .|
712 .I qualifier
713 .br
714 .I qualifier
715 ::=
716 .B const
717 |
718 .B volatile
719 |
720 .B restrict
721 .br
722 .I type-name
723 ::=
724 .I identifier
725 .PP
726 The following
727 .IR type-name s
728 are defined in the built-in module.
729 .hP \*o
730 .B va_list
731 .hP \*o
732 .B size_t
733 .hP \*o
734 .B ptrdiff_t
735 .hP \*o
736 .B wchar_t
737 .PP
738 Declaration specifiers may appear in any order.
739 However, not all combinations are permitted.
740 A declaration specifier must consist of 
741 zero or more
742 .IR qualifier s,
743 and one of the following, up to reordering.
744 .hP \*o
745 .I type-name
746 .hP \*o
747 .B struct
748 .IR identifier ,
749 .B union
750 .IR identifier ,
751 .B enum
752 .I identifier
753 .hP \*o
754 .B void
755 .hP \*o
756 .BR char ,
757 .BR "unsigned char" ,
758 .B "signed char"
759 .hP \*o
760 .BR short ,
761 .BR "unsigned short" ,
762 .B "signed short"
763 .hP \*o
764 .BR "short int" ,
765 .BR "unsigned short int" ,
766 .B "signed short int"
767 .hP \*o
768 .BR int ,
769 .BR "unsigned int" ,
770 .BR "signed int" ,
771 .BR unsigned ,
772 .B signed
773 .hP \*o
774 .BR long ,
775 .BR "unsigned long" ,
776 .B "signed long"
777 .hP \*o
778 .BR "long int" ,
779 .BR "unsigned long int" ,
780 .B "signed long int"
781 .hP \*o
782 .BR "long long" ,
783 .BR "unsigned long long" ,
784 .B "signed long long"
785 .hP \*o
786 .BR "long long int" ,
787 .BR "unsigned long long int" ,
788 .B "signed long long int"
789 .hP \*o
790 .BR float ,
791 .BR double ,
792 .B long double
793 .hP \*o
794 .BR "float _Imaginary" ,
795 .BR "double _Imaginary" ,
796 .B "long double _Imaginary"
797 .hP \*o
798 .BR "float imaginary" ,
799 .BR "double imaginary" ,
800 .B "long double imaginary"
801 .hP \*o
802 .BR "float _Complex" ,
803 .BR "double _Complex" ,
804 .B "long double _Complex"
805 .hP \*o
806 .BR "float complex" ,
807 .BR "double complex" ,
808 .B "long double complex"
809 .PP
810 .IR declarator [ k ", " a ]
811 ::=
812 .IR pointer \**
813 .IR primary-declarator [ k ", " a ]
814 .br
815 .IR primary-declarator [ k ", " a ]
816 ::=
817 .I k
818 .|
819 .B (
820 .IR primary-declarator [ k ", " a ]
821 .B )
822 .|
823 .IR primary-declarator [ k ", " a ]
824 .IR declarator-suffix [ a ]
825 .br
826 .I pointer
827 ::=
828 .B *
829 .IR qualifier \**
830 .br
831 .IR declarator-suffix [ a ]
832 ::=
833 .B [
834 .I c-fragment
835 .B ]
836 .|
837 .B (
838 .I a
839 .B )
840 .br
841 .I argument-list
842 ::=
843 \*e |
844 .B ...
845 .|
846 .IR list [ argument ]
847 .RB [ ,
848 .BR ... ]
849 .br
850 .I argument
851 ::=
852 .IR declaration-specifier \*+
853 .I argument-declarator
854 .br
855 .I argument-declarator
856 ::=
857 .IR declarator [ identifier " | \*e, " argument-list ]
858 .br
859 .I simple-declarator
860 ::=
861 .IR declarator [ identifier ", " argument-list ]
862 .br
863 .I keyword-argument
864 ::=
865 .I argument
866 .RB [ =
867 .IR c-fragment ]
868 .br
869 .I keyword-argument-list
870 ::=
871 .I argument-list
872 .B ?\&
873 .I keyword-argument-list
874 .br
875 .I method-argument-list
876 ::=
877 .I argument-list
878 |
879 .I keyword-argument-list
880 .br
881 .I dotted-name
882 ::=
883 .I identifier
884 .B .\&
885 .I identifier
886 .br
887 .IR keyword-declarator [ k ]
888 ::=
889 .IR declarator [ k ", " method-argument-list ]
890 .
891 .\"--------------------------------------------------------------------------
892 .SH SEE ALSO
893 .BR sod (1),
894 .BR sod (3),
895 .BR sod-structs (3).
896 .
897 .\"--------------------------------------------------------------------------
898 .SH AUTHOR
899 Mark Wooding, <mdw@distorted.org.uk>
900 .
901 .\"----- That's all, folks --------------------------------------------------