chiark / gitweb /
src/c-types-{impl,parse}.lisp: Support C11 `_Atomic'.
[sod] / src / sod-module.5
CommitLineData
9ed8eb2a
MW
1.\" -*-nroff-*-
2.\"
3.\" The Sod module syntax
4.\"
5.\" (c) 2015 Straylight/Edgeware
6.\"
7.
8.\"----- Licensing notice ---------------------------------------------------
9.\"
e0808c47 10.\" This file is part of the Sensible Object Design, an object system for C.
9ed8eb2a
MW
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
81sod-module \- Sensible Object Design module syntax
82.
83.\"--------------------------------------------------------------------------
84.SH DESCRIPTION
85This manual page provides a highly compressed description of the
86Sod module syntax.
87For full details, consult the main manual.
88.PP
89.SS Notation
90Anywhere a simple nonterminal name
91.I x
92may appear in the grammar,
93an
94.I indexed
95nonterminal
96.IR x [ a \*_1\*(_e,
97\&...,
98.IR a \*_ n \*(_e]
99may also appear.
100On the left-hand side of a production rule,
101the indices
102.IR a \*_1\*(_e,
103\&...,
104.IR a \*_ n \*(_e
105are variables which vary over all nonterminal and terminal symbols,
106and the variables may also appear on the right-hand side
107in place of a nonterminal.
108Such a rule stands for a family of rules,
109in each variable is replaced by
110each possible simple nonterminal or terminal symbol.
111.PP
112The letter \*e denotes the empty nonterminal
113.IP
114.I \*e
115::=
116.PP
117The following indexed productions are used throughout the grammar, some often
118enough that they deserve special notation.
119.hP \*o
120.RI [ x ]
121abbreviates
122.IR optional [ x ],
123denoting 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 \**
137abbreviates
138.IR zero-or-more [ x ],
139denoting 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 \*+
154abbreviates
155.IR one-or-more [ x ]
156denoting 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 ]
169denotes a sequence of one or more occurrences of
170.I x
171separated 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::=
186an S-expression, as parsed by the Lisp reader
187.br
188.I c-fragment
189::=
190a 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
256The characters matched by
257.I extended-alpha-char
258depend 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::=
275any character other than
276.B \e
277or
278.B """"
279.|
280.B \e
281.I char
282.br
283.I char-literal-char
284::=
285any character other than
286.B \e
287or
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::=
374any non-alphanumeric character
375other than
376.BR _ ,
377.BR """" ,
378or
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::=
405any character other than
406.B *
407.br
408.I not-star-or-slash
409::=
410any character other than
411.B *
412or
413.B /
414.br
415.I line-comment
416::=
417.B //
418.IR not-newline \**
419.I newline
420.br
421.I newline
422::=
423a newline character
424.br
425.I not-newline
426::=
427any 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
4fc52153 483.I item-name
9ed8eb2a
MW
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::=
4fc52153
MW
497.IR item-name \*+
498.br
499.I item-name
500::=
501.I identifier
502|
503.B (
9ed8eb2a 504.IR identifier \*+
4fc52153 505.B )
9ed8eb2a
MW
506.
507.SS Class definitions
508.I
509class-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 {
391c5a34 531.IR properties-class-item \**
9ed8eb2a
MW
532.B }
533.br
391c5a34
MW
534.I properties-class-item
535::=
536.RI [ properties ]
537.I class-item
538.br
9ed8eb2a
MW
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.<
9ed8eb2a
MW
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::=
9ed8eb2a
MW
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::=
9ed8eb2a
MW
584.<
585.IR declaration-specifier \*+
586.I simple-declarator
9ed8eb2a
MW
587.RI [ method-body ]
588.br
589.I method-item
391c5a34 590::=
9ed8eb2a
MW
591.<
592.IR declaration-specifier \*+
391c5a34 593.IR declarator [ dotted-name ]
9ed8eb2a
MW
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.|
2e01fd8b
MW
702.B bool
703|
704.B _Bool
705.|
706.B imaginary
707|
708.B _Imaginary
709|
710.B complex
711|
712.B _Complex
713.|
9ed8eb2a 714.I qualifier
ae0f15ee
MW
715.|
716.I atomic-type
9ed8eb2a
MW
717.br
718.I qualifier
719::=
ae0f15ee
MW
720.I atomic
721|
9ed8eb2a
MW
722.B const
723|
724.B volatile
725|
726.B restrict
727.br
ae0f15ee
MW
728.I atomic-type
729::=
730.I
731atomic
732.B (
733.IR declaration-specifier \*+
734.I abstract-declarator
735.B )
736.br
737.I atomic
738::=
739.B atomic
740|
741.B _Atomic
742.br
9ed8eb2a
MW
743.I type-name
744::=
745.I identifier
746.PP
2e01fd8b
MW
747The following
748.IR type-name s
749are defined in the built-in module.
750.hP \*o
751.B va_list
752.hP \*o
753.B size_t
754.hP \*o
755.B ptrdiff_t
756.hP \*o
757.B wchar_t
758.PP
9ed8eb2a
MW
759Declaration specifiers may appear in any order.
760However, not all combinations are permitted.
761A declaration specifier must consist of
c32aa709
MW
762zero or more
763.IR qualifier s,
9ed8eb2a
MW
764and one of the following, up to reordering.
765.hP \*o
766.I type-name
767.hP \*o
768.B struct
769.IR identifier ,
770.B union
771.IR identifier ,
772.B enum
773.I identifier
774.hP \*o
775.B void
776.hP \*o
777.BR char ,
778.BR "unsigned char" ,
779.B "signed char"
780.hP \*o
781.BR short ,
782.BR "unsigned short" ,
783.B "signed short"
784.hP \*o
785.BR "short int" ,
786.BR "unsigned short int" ,
787.B "signed short int"
788.hP \*o
789.BR int ,
790.BR "unsigned int" ,
791.BR "signed int" ,
792.BR unsigned ,
793.B signed
794.hP \*o
795.BR long ,
796.BR "unsigned long" ,
797.B "signed long"
798.hP \*o
799.BR "long int" ,
800.BR "unsigned long int" ,
801.B "signed long int"
802.hP \*o
803.BR "long long" ,
804.BR "unsigned long long" ,
805.B "signed long long"
806.hP \*o
807.BR "long long int" ,
808.BR "unsigned long long int" ,
809.B "signed long long int"
810.hP \*o
811.BR float ,
812.BR double ,
813.B long double
2e01fd8b
MW
814.hP \*o
815.BR "float _Imaginary" ,
816.BR "double _Imaginary" ,
817.B "long double _Imaginary"
818.hP \*o
819.BR "float imaginary" ,
820.BR "double imaginary" ,
821.B "long double imaginary"
822.hP \*o
823.BR "float _Complex" ,
824.BR "double _Complex" ,
825.B "long double _Complex"
826.hP \*o
827.BR "float complex" ,
828.BR "double complex" ,
829.B "long double complex"
9ed8eb2a
MW
830.PP
831.IR declarator [ k ]
832::=
833.IR pointer \**
834.IR primary-declarator [ k ]
835.br
836.IR primary-declarator [ k ]
837::=
838.I k
839.|
840.B (
841.IR primary-declarator [ k ]
842.B )
843.|
844.IR primary-declarator [ k ]
845.IR declarator-suffix
846.br
847.I pointer
848::=
849.B *
850.IR qualifier \**
851.br
852.I declarator-suffix
853::=
854.B [
855.I c-fragment
856.B ]
857.|
858.B (
ea08dc56 859.I argument-list
9ed8eb2a
MW
860.B )
861.br
ea08dc56 862.I argument-list
9ed8eb2a
MW
863::=
864\*e |
865.B ...
866.|
867.IR list [ argument ]
868.RB [ ,
869.BR ... ]
870.br
871.I argument
872::=
873.IR declaration-specifier \*+
874.I argument-declarator
875.br
ae0f15ee
MW
876.I abstract-declarator
877::=
878.IR declarator [\*e]
879.br
9ed8eb2a
MW
880.I argument-declarator
881::=
882.IR declarator [ identifier " | \*e]"
883.br
884.I simple-declarator
885::=
886.IR declarator [ identifier ]
887.br
888.I dotted-name
889::=
890.I identifier
891.B .\&
892.I identifier
391c5a34 893.
9ed8eb2a
MW
894.\"--------------------------------------------------------------------------
895.SH SEE ALSO
896.BR sod (1),
897.BR sod (3),
898.BR sod-structs (3).
899.
900.\"--------------------------------------------------------------------------
901.SH AUTHOR
902Mark Wooding, <mdw@distorted.org.uk>
903.
904.\"----- That's all, folks --------------------------------------------------