chiark / gitweb /
doc/parsing.tex: Document missing `:ignore-unconsumed' flag to `error'.
[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.|
b2983f35
MW
545.I initarg-item
546.|
a42893dd
MW
547.I fragment-item
548.|
9ed8eb2a
MW
549.I message-item
550.|
551.I method-item
552.br
553.I slot-item
554::=
555.<
9ed8eb2a
MW
556.IR declaration-specifier \*+
557.IR list [ init-declarator ]
558.B ;
559.br
560.I init-declarator
561::=
562.I simple-declarator
563.RB [ =
564.IR initializer ]
565.br
566.I initializer-item
567::=
9ed8eb2a
MW
568.RB [ class ]
569.IR list [ slot-initializer ]
570.B ;
571.br
572.I slot-initializer
573::=
574.I dotted-name
b2983f35
MW
575.RB [ =
576.IR initializer ]
9ed8eb2a
MW
577.br
578.I initializer
579::=
9ed8eb2a
MW
580.I c-fragment
581.br
b2983f35
MW
582.I initarg-item
583::=
584.<
585.B initarg
586.IR declaration-specifier \*+
587.IR list [ init-declarator ]
588.B ;
589.br
a42893dd
MW
590.I fragment-item
591::=
592.I fragment-kind
593.B {
594.I c-fragment
595.B }
596.br
597.I fragment-kind
598::=
599.B init
600|
601.B teardown
602.br
9ed8eb2a
MW
603.I message-item
604::=
9ed8eb2a
MW
605.<
606.IR declaration-specifier \*+
43073476
MW
607.IR keyword-declarator [ identifier ]
608.<
9ed8eb2a
MW
609.RI [ method-body ]
610.br
611.I method-item
391c5a34 612::=
9ed8eb2a
MW
613.<
614.IR declaration-specifier \*+
43073476
MW
615.IR keyword-declarator [ dotted-name ]
616.<
9ed8eb2a
MW
617.I method-body
618.br
619.I method-body
620::=
621.B {
622.I c-fragment
623.B }
624|
625.B extern
626.B ;
627.
628.SS Property sets
629.I properties
630::=
631.B [
632.IR list [ property ]
633.B ]
634.br
635.I property
636::=
637.I identifier
638.B =
639.I expression
640.br
641.I expression
642::=
643.I term
644|
645.I expression
646.B +
647.I term
648|
649.I expression
650.B \-
651.I term
652.br
653.I term
654::=
655.I factor
656|
657.I term
658.B *
659.I factor
660|
661.I term
662.B /
663.I factor
664.br
665.I factor
666::=
667.I primary
668|
669.B +
670.I factor
671|
672.B \-
673.B factor
674.br
675.I primary
676::=
677.I integer-literal
678|
679.I string-literal
680.ie t |
681.el .|
682.I char-literal
683|
684.I identifier
685.|
686.B ?
687.I s-expression
688.|
689.B (
690.I expression
691.B )
692.
693.SS C types
694.I declaration-specifier
695::=
696.I type-name
697.|
698.B struct
699.I identifier
700|
701.B union
702.I identifier
703|
704.B enum
705.I identifier
706.|
707.B void
708|
709.B char
710|
711.B int
712|
713.B float
714|
715.B double
716.|
717.B short
718|
719.B long
720.|
721.B signed
722|
723.B unsigned
724.|
2e01fd8b
MW
725.B bool
726|
727.B _Bool
728.|
729.B imaginary
730|
731.B _Imaginary
732|
733.B complex
734|
735.B _Complex
736.|
9ed8eb2a 737.I qualifier
ae0f15ee 738.|
db56b1d3
MW
739.I storage-specifier
740.|
ae0f15ee 741.I atomic-type
9ed8eb2a
MW
742.br
743.I qualifier
744::=
ae0f15ee
MW
745.I atomic
746|
9ed8eb2a
MW
747.B const
748|
749.B volatile
750|
751.B restrict
752.br
ae0f15ee
MW
753.I atomic-type
754::=
755.I
756atomic
757.B (
758.IR declaration-specifier \*+
759.I abstract-declarator
760.B )
761.br
762.I atomic
763::=
764.B atomic
765|
766.B _Atomic
767.br
db56b1d3
MW
768.I storage-specifier
769::=
770.I alignas
771.B (
772.I c-fragment
773.B )
774.br
775.I alignas
776::=
777.B alignas
778|
779.B _Alignas
780.br
9ed8eb2a
MW
781.I type-name
782::=
783.I identifier
784.PP
2e01fd8b
MW
785The following
786.IR type-name s
787are defined in the built-in module.
788.hP \*o
789.B va_list
790.hP \*o
791.B size_t
792.hP \*o
793.B ptrdiff_t
794.hP \*o
795.B wchar_t
796.PP
9ed8eb2a
MW
797Declaration specifiers may appear in any order.
798However, not all combinations are permitted.
799A declaration specifier must consist of
c32aa709
MW
800zero or more
801.IR qualifier s,
db56b1d3
MW
802zero or more
803.IR storage-specifier s,
9ed8eb2a
MW
804and one of the following, up to reordering.
805.hP \*o
806.I type-name
807.hP \*o
808.B struct
809.IR identifier ,
810.B union
811.IR identifier ,
812.B enum
813.I identifier
814.hP \*o
815.B void
816.hP \*o
817.BR char ,
818.BR "unsigned char" ,
819.B "signed char"
820.hP \*o
821.BR short ,
822.BR "unsigned short" ,
823.B "signed short"
824.hP \*o
825.BR "short int" ,
826.BR "unsigned short int" ,
827.B "signed short int"
828.hP \*o
829.BR int ,
830.BR "unsigned int" ,
831.BR "signed int" ,
832.BR unsigned ,
833.B signed
834.hP \*o
835.BR long ,
836.BR "unsigned long" ,
837.B "signed long"
838.hP \*o
839.BR "long int" ,
840.BR "unsigned long int" ,
841.B "signed long int"
842.hP \*o
843.BR "long long" ,
844.BR "unsigned long long" ,
845.B "signed long long"
846.hP \*o
847.BR "long long int" ,
848.BR "unsigned long long int" ,
849.B "signed long long int"
850.hP \*o
851.BR float ,
852.BR double ,
853.B long double
2e01fd8b
MW
854.hP \*o
855.BR "float _Imaginary" ,
856.BR "double _Imaginary" ,
857.B "long double _Imaginary"
858.hP \*o
859.BR "float imaginary" ,
860.BR "double imaginary" ,
861.B "long double imaginary"
862.hP \*o
863.BR "float _Complex" ,
864.BR "double _Complex" ,
865.B "long double _Complex"
866.hP \*o
867.BR "float complex" ,
868.BR "double complex" ,
869.B "long double complex"
9ed8eb2a 870.PP
43073476 871.IR declarator [ k ", " a ]
9ed8eb2a
MW
872::=
873.IR pointer \**
43073476 874.IR primary-declarator [ k ", " a ]
9ed8eb2a 875.br
43073476 876.IR primary-declarator [ k ", " a ]
9ed8eb2a
MW
877::=
878.I k
879.|
880.B (
43073476 881.IR primary-declarator [ k ", " a ]
9ed8eb2a
MW
882.B )
883.|
43073476
MW
884.IR primary-declarator [ k ", " a ]
885.IR declarator-suffix [ a ]
9ed8eb2a
MW
886.br
887.I pointer
888::=
889.B *
890.IR qualifier \**
891.br
43073476 892.IR declarator-suffix [ a ]
9ed8eb2a
MW
893::=
894.B [
895.I c-fragment
896.B ]
897.|
898.B (
43073476 899.I a
9ed8eb2a
MW
900.B )
901.br
ea08dc56 902.I argument-list
9ed8eb2a
MW
903::=
904\*e |
905.B ...
906.|
907.IR list [ argument ]
908.RB [ ,
909.BR ... ]
910.br
911.I argument
912::=
913.IR declaration-specifier \*+
914.I argument-declarator
915.br
ae0f15ee
MW
916.I abstract-declarator
917::=
f64eb323 918.IR declarator "[\*e, " argument-list ]
ae0f15ee 919.br
9ed8eb2a
MW
920.I argument-declarator
921::=
43073476 922.IR declarator [ identifier " | \*e, " argument-list ]
9ed8eb2a
MW
923.br
924.I simple-declarator
925::=
43073476
MW
926.IR declarator [ identifier ", " argument-list ]
927.br
928.I keyword-argument
929::=
930.I argument
931.RB [ =
932.IR c-fragment ]
933.br
934.I keyword-argument-list
935::=
936.I argument-list
937.B ?\&
938.I keyword-argument-list
939.br
940.I method-argument-list
941::=
942.I argument-list
943|
944.I keyword-argument-list
9ed8eb2a
MW
945.br
946.I dotted-name
947::=
948.I identifier
949.B .\&
950.I identifier
43073476
MW
951.br
952.IR keyword-declarator [ k ]
953::=
954.IR declarator [ k ", " method-argument-list ]
391c5a34 955.
9ed8eb2a
MW
956.\"--------------------------------------------------------------------------
957.SH SEE ALSO
958.BR sod (1),
959.BR sod (3),
960.BR sod-structs (3).
961.
962.\"--------------------------------------------------------------------------
963.SH AUTHOR
964Mark Wooding, <mdw@distorted.org.uk>
965.
966.\"----- That's all, folks --------------------------------------------------