chiark / gitweb /
21a9feeeae0e621d5203bfb05d62e93655f44ad2
[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 .B {
577 .I c-fragment
578 .B }
579 |
580 .I c-fragment
581 .br
582 .I message-item
583 ::=
584 .<
585 .IR declaration-specifier \*+
586 .I simple-declarator
587 .RI [ method-body ]
588 .br
589 .I method-item
590 ::=
591 .<
592 .IR declaration-specifier \*+
593 .IR declarator [ dotted-name ]
594 .I method-body
595 .br
596 .I method-body
597 ::=
598 .B {
599 .I c-fragment
600 .B }
601 |
602 .B extern
603 .B ;
604 .
605 .SS Property sets
606 .I properties
607 ::=
608 .B [
609 .IR list [ property ]
610 .B ]
611 .br
612 .I property
613 ::=
614 .I identifier
615 .B =
616 .I expression
617 .br
618 .I expression
619 ::=
620 .I term
621 |
622 .I expression
623 .B +
624 .I term
625 |
626 .I expression
627 .B \-
628 .I term
629 .br
630 .I term
631 ::=
632 .I factor
633 |
634 .I term
635 .B *
636 .I factor
637 |
638 .I term
639 .B /
640 .I factor
641 .br
642 .I factor
643 ::=
644 .I primary
645 |
646 .B +
647 .I factor
648 |
649 .B \-
650 .B factor
651 .br
652 .I primary
653 ::=
654 .I integer-literal
655 |
656 .I string-literal
657 .ie t |
658 .el .|
659 .I char-literal
660 |
661 .I identifier
662 .|
663 .B ?
664 .I s-expression
665 .|
666 .B (
667 .I expression
668 .B )
669 .
670 .SS C types
671 .I declaration-specifier
672 ::=
673 .I type-name
674 .|
675 .B struct
676 .I identifier
677 |
678 .B union
679 .I identifier
680 |
681 .B enum
682 .I identifier
683 .|
684 .B void
685 |
686 .B char
687 |
688 .B int
689 |
690 .B float
691 |
692 .B double
693 .|
694 .B short
695 |
696 .B long
697 .|
698 .B signed
699 |
700 .B unsigned
701 .|
702 .B bool
703 |
704 .B _Bool
705 .|
706 .B imaginary
707 |
708 .B _Imaginary
709 |
710 .B complex
711 |
712 .B _Complex
713 .|
714 .I qualifier
715 .br
716 .I qualifier
717 ::=
718 .B const
719 |
720 .B volatile
721 |
722 .B restrict
723 .br
724 .I type-name
725 ::=
726 .I identifier
727 .PP
728 The following
729 .IR type-name s
730 are defined in the built-in module.
731 .hP \*o
732 .B va_list
733 .hP \*o
734 .B size_t
735 .hP \*o
736 .B ptrdiff_t
737 .hP \*o
738 .B wchar_t
739 .PP
740 Declaration specifiers may appear in any order.
741 However, not all combinations are permitted.
742 A declaration specifier must consist of 
743 zero or more
744 .IR qualifier s,
745 and one of the following, up to reordering.
746 .hP \*o
747 .I type-name
748 .hP \*o
749 .B struct
750 .IR identifier ,
751 .B union
752 .IR identifier ,
753 .B enum
754 .I identifier
755 .hP \*o
756 .B void
757 .hP \*o
758 .BR char ,
759 .BR "unsigned char" ,
760 .B "signed char"
761 .hP \*o
762 .BR short ,
763 .BR "unsigned short" ,
764 .B "signed short"
765 .hP \*o
766 .BR "short int" ,
767 .BR "unsigned short int" ,
768 .B "signed short int"
769 .hP \*o
770 .BR int ,
771 .BR "unsigned int" ,
772 .BR "signed int" ,
773 .BR unsigned ,
774 .B signed
775 .hP \*o
776 .BR long ,
777 .BR "unsigned long" ,
778 .B "signed long"
779 .hP \*o
780 .BR "long int" ,
781 .BR "unsigned long int" ,
782 .B "signed long int"
783 .hP \*o
784 .BR "long long" ,
785 .BR "unsigned long long" ,
786 .B "signed long long"
787 .hP \*o
788 .BR "long long int" ,
789 .BR "unsigned long long int" ,
790 .B "signed long long int"
791 .hP \*o
792 .BR float ,
793 .BR double ,
794 .B long double
795 .hP \*o
796 .BR "float _Imaginary" ,
797 .BR "double _Imaginary" ,
798 .B "long double _Imaginary"
799 .hP \*o
800 .BR "float imaginary" ,
801 .BR "double imaginary" ,
802 .B "long double imaginary"
803 .hP \*o
804 .BR "float _Complex" ,
805 .BR "double _Complex" ,
806 .B "long double _Complex"
807 .hP \*o
808 .BR "float complex" ,
809 .BR "double complex" ,
810 .B "long double complex"
811 .PP
812 .IR declarator [ k ]
813 ::=
814 .IR pointer \**
815 .IR primary-declarator [ k ]
816 .br
817 .IR primary-declarator [ k ]
818 ::=
819 .I k
820 .|
821 .B (
822 .IR primary-declarator [ k ]
823 .B )
824 .|
825 .IR primary-declarator [ k ]
826 .IR declarator-suffix
827 .br
828 .I pointer
829 ::=
830 .B *
831 .IR qualifier \**
832 .br
833 .I declarator-suffix
834 ::=
835 .B [
836 .I c-fragment
837 .B ]
838 .|
839 .B (
840 .I argument-list
841 .B )
842 .br
843 .I argument-list
844 ::=
845 \*e |
846 .B ...
847 .|
848 .IR list [ argument ]
849 .RB [ ,
850 .BR ... ]
851 .br
852 .I argument
853 ::=
854 .IR declaration-specifier \*+
855 .I argument-declarator
856 .br
857 .I argument-declarator
858 ::=
859 .IR declarator [ identifier " | \*e]"
860 .br
861 .I simple-declarator
862 ::=
863 .IR declarator [ identifier ]
864 .br
865 .I dotted-name
866 ::=
867 .I identifier
868 .B .\&
869 .I identifier
870 .
871 .\"--------------------------------------------------------------------------
872 .SH SEE ALSO
873 .BR sod (1),
874 .BR sod (3),
875 .BR sod-structs (3).
876 .
877 .\"--------------------------------------------------------------------------
878 .SH AUTHOR
879 Mark Wooding, <mdw@distorted.org.uk>
880 .
881 .\"----- That's all, folks --------------------------------------------------