From Jason Turner

[cpp.pre]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpskr_9kjs/{from.md → to.md} +221 -0
tmp/tmpskr_9kjs/{from.md → to.md} RENAMED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Preamble <a id="cpp.pre">[[cpp.pre]]</a>
2
+
3
+ ``` bnf
4
+ preprocessing-file:
5
+ groupₒₚₜ
6
+ module-file
7
+ ```
8
+
9
+ ``` bnf
10
+ module-file:
11
+ pp-global-module-fragmentₒₚₜ pp-module groupₒₚₜ pp-private-module-fragmentₒₚₜ
12
+ ```
13
+
14
+ ``` bnf
15
+ pp-global-module-fragment:
16
+ module ';' new-line groupₒₚₜ
17
+ ```
18
+
19
+ ``` bnf
20
+ pp-private-module-fragment:
21
+ module ':' private ';' new-line groupₒₚₜ
22
+ ```
23
+
24
+ ``` bnf
25
+ group:
26
+ group-part
27
+ group group-part
28
+ ```
29
+
30
+ ``` bnf
31
+ group-part:
32
+ control-line
33
+ if-section
34
+ text-line
35
+ '#' conditionally-supported-directive
36
+ ```
37
+
38
+ ``` bnf
39
+ control-line:
40
+ '# include' pp-tokens new-line
41
+ pp-import
42
+ '# define ' identifier replacement-list new-line
43
+ '# define ' identifier lparen identifier-listₒₚₜ ')' replacement-list new-line
44
+ '# define ' identifier lparen '... )' replacement-list new-line
45
+ '# define ' identifier lparen identifier-list ', ... )' replacement-list new-line
46
+ '# undef ' identifier new-line
47
+ '# line ' pp-tokens new-line
48
+ '# error ' pp-tokensₒₚₜ new-line
49
+ '# pragma ' pp-tokensₒₚₜ new-line
50
+ '# 'new-line
51
+ ```
52
+
53
+ ``` bnf
54
+ if-section:
55
+ if-group elif-groupsₒₚₜ else-groupₒₚₜ endif-line
56
+ ```
57
+
58
+ ``` bnf
59
+ if-group:
60
+ '# if ' constant-expression new-line groupₒₚₜ
61
+ '# ifdef ' identifier new-line groupₒₚₜ
62
+ '# ifndef ' identifier new-line groupₒₚₜ
63
+ ```
64
+
65
+ ``` bnf
66
+ elif-groups:
67
+ elif-group
68
+ elif-groups elif-group
69
+ ```
70
+
71
+ ``` bnf
72
+ elif-group:
73
+ '# elif ' constant-expression new-line groupₒₚₜ
74
+ ```
75
+
76
+ ``` bnf
77
+ else-group:
78
+ '# else ' new-line groupₒₚₜ
79
+ ```
80
+
81
+ ``` bnf
82
+ endif-line:
83
+ '# endif ' new-line
84
+ ```
85
+
86
+ ``` bnf
87
+ text-line:
88
+ pp-tokensₒₚₜ new-line
89
+ ```
90
+
91
+ ``` bnf
92
+ conditionally-supported-directive:
93
+ pp-tokens new-line
94
+ ```
95
+
96
+ ``` bnf
97
+ lparen:
98
+ a '(' character not immediately preceded by white-space
99
+ ```
100
+
101
+ ``` bnf
102
+ identifier-list:
103
+ identifier
104
+ identifier-list ',' identifier
105
+ ```
106
+
107
+ ``` bnf
108
+ replacement-list:
109
+ pp-tokensₒₚₜ
110
+ ```
111
+
112
+ ``` bnf
113
+ pp-tokens:
114
+ preprocessing-token
115
+ pp-tokens preprocessing-token
116
+ ```
117
+
118
+ ``` bnf
119
+ new-line:
120
+ the new-line character
121
+ ```
122
+
123
+ A *preprocessing directive* consists of a sequence of preprocessing
124
+ tokens that satisfies the following constraints: At the start of
125
+ translation phase 4, the first token in the sequence, referred to as a
126
+ *directive-introducing token*, begins with the first character in the
127
+ source file (optionally after white space containing no new-line
128
+ characters) or follows white space containing at least one new-line
129
+ character, and is
130
+
131
+ - a `#` preprocessing token, or
132
+ - an `import` preprocessing token immediately followed on the same
133
+ logical line by a *header-name*, `<`, *identifier*, *string-literal*,
134
+ or `:` preprocessing token, or
135
+ - a `module` preprocessing token immediately followed on the same
136
+ logical line by an *identifier*, `:`, or `;` preprocessing token, or
137
+ - an `export` preprocessing token immediately followed on the same
138
+ logical line by one of the two preceding forms.
139
+
140
+ The last token in the sequence is the first token within the sequence
141
+ that is immediately followed by whitespace containing a new-line
142
+ character. [^1]
143
+
144
+ [*Note 1*: A new-line character ends the preprocessing directive even
145
+ if it occurs within what would otherwise be an invocation of a
146
+ function-like macro. — *end note*]
147
+
148
+ [*Example 1*:
149
+
150
+ ``` cpp
151
+ # // preprocessing directive
152
+ module ; // preprocessing directive
153
+ export module leftpad; // preprocessing directive
154
+ import <string>; // preprocessing directive
155
+ export import "squee"; // preprocessing directive
156
+ import rightpad; // preprocessing directive
157
+ import :part; // preprocessing directive
158
+
159
+ module // not a preprocessing directive
160
+ ; // not a preprocessing directive
161
+
162
+ export // not a preprocessing directive
163
+ import // not a preprocessing directive
164
+ foo; // not a preprocessing directive
165
+
166
+ export // not a preprocessing directive
167
+ import foo; // preprocessing directive (ill-formed at phase 7)
168
+
169
+ import :: // not a preprocessing directive
170
+ import -> // not a preprocessing directive
171
+ ```
172
+
173
+ — *end example*]
174
+
175
+ A sequence of preprocessing tokens is only a *text-line* if it does not
176
+ begin with a directive-introducing token. A sequence of preprocessing
177
+ tokens is only a *conditionally-supported-directive* if it does not
178
+ begin with any of the directive names appearing after a `#` in the
179
+ syntax. A *conditionally-supported-directive* is conditionally-supported
180
+ with *implementation-defined* semantics.
181
+
182
+ At the start of phase 4 of translation, the *group* of a
183
+ *pp-global-module-fragment* shall contain neither a *text-line* nor a
184
+ *pp-import*.
185
+
186
+ When in a group that is skipped [[cpp.cond]], the directive syntax is
187
+ relaxed to allow any sequence of preprocessing tokens to occur between
188
+ the directive name and the following new-line character.
189
+
190
+ The only white-space characters that shall appear between preprocessing
191
+ tokens within a preprocessing directive (from just after the
192
+ directive-introducing token through just before the terminating new-line
193
+ character) are space and horizontal-tab (including spaces that have
194
+ replaced comments or possibly other white-space characters in
195
+ translation phase 3).
196
+
197
+ The implementation can process and skip sections of source files
198
+ conditionally, include other source files, import macros from header
199
+ units, and replace macros. These capabilities are called
200
+ *preprocessing*, because conceptually they occur before translation of
201
+ the resulting translation unit.
202
+
203
+ The preprocessing tokens within a preprocessing directive are not
204
+ subject to macro expansion unless otherwise stated.
205
+
206
+ [*Example 2*:
207
+
208
+ In:
209
+
210
+ ``` cpp
211
+ #define EMPTY
212
+ EMPTY # include <file.h>
213
+ ```
214
+
215
+ the sequence of preprocessing tokens on the second line is *not* a
216
+ preprocessing directive, because it does not begin with a `#` at the
217
+ start of translation phase 4, even though it will do so after the macro
218
+ `EMPTY` has been replaced.
219
+
220
+ — *end example*]
221
+