From Jason Turner

[cpp.pre]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgfjokd6e/{from.md → to.md} +95 -31
tmp/tmpgfjokd6e/{from.md → to.md} RENAMED
@@ -37,10 +37,11 @@ group-part:
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
@@ -63,12 +64,11 @@ if-group:
63
  '# ifndef ' identifier new-line groupₒₚₜ
64
  ```
65
 
66
  ``` bnf
67
  elif-groups:
68
- elif-group
69
- elif-groups elif-group
70
  ```
71
 
72
  ``` bnf
73
  elif-group:
74
  '# elif ' constant-expression new-line groupₒₚₜ
@@ -112,39 +112,86 @@ replacement-list:
112
  pp-tokensₒₚₜ
113
  ```
114
 
115
  ``` bnf
116
  pp-tokens:
117
- preprocessing-token
118
- pp-tokens preprocessing-token
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  ```
120
 
121
  ``` bnf
122
  new-line:
123
  the new-line character
124
  ```
125
 
 
 
 
 
 
 
126
  A *preprocessing directive* consists of a sequence of preprocessing
127
  tokens that satisfies the following constraints: At the start of
128
- translation phase 4, the first token in the sequence, referred to as a
129
- *directive-introducing token*, begins with the first character in the
130
- source file (optionally after whitespace containing no new-line
131
- characters) or follows whitespace containing at least one new-line
132
- character, and is
133
 
134
  - a `#` preprocessing token, or
135
  - an `import` preprocessing token immediately followed on the same
136
- logical line by a *header-name*, `<`, *identifier*, *string-literal*,
137
- or `:` preprocessing token, or
138
  - a `module` preprocessing token immediately followed on the same
139
- logical line by an *identifier*, `:`, or `;` preprocessing token, or
 
140
  - an `export` preprocessing token immediately followed on the same
141
- logical line by one of the two preceding forms.
142
 
143
- The last token in the sequence is the first token within the sequence
144
- that is immediately followed by whitespace containing a new-line
145
- character.[^1]
146
 
147
  [*Note 1*: A new-line character ends the preprocessing directive even
148
  if it occurs within what would otherwise be an invocation of a
149
  function-like macro. — *end note*]
150
 
@@ -174,15 +221,38 @@ import -> // not a preprocessing directive
174
  ```
175
 
176
  — *end example*]
177
 
178
  A sequence of preprocessing tokens is only a *text-line* if it does not
179
- begin with a directive-introducing token. A sequence of preprocessing
180
- tokens is only a *conditionally-supported-directive* if it does not
181
- begin with any of the directive names appearing after a `#` in the
182
- syntax. A *conditionally-supported-directive* is conditionally-supported
183
- with *implementation-defined* semantics.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
  At the start of phase 4 of translation, the *group* of a
186
  *pp-global-module-fragment* shall contain neither a *text-line* nor a
187
  *pp-import*.
188
 
@@ -191,24 +261,18 @@ relaxed to allow any sequence of preprocessing tokens to occur between
191
  the directive name and the following new-line character.
192
 
193
  The only whitespace characters that shall appear between preprocessing
194
  tokens within a preprocessing directive (from just after the
195
  directive-introducing token through just before the terminating new-line
196
- character) are space and horizontal-tab (including spaces that have
197
- replaced comments or possibly other whitespace characters in translation
198
- phase 3).
199
-
200
- The implementation can process and skip sections of source files
201
- conditionally, include other source files, import macros from header
202
- units, and replace macros. These capabilities are called
203
- *preprocessing*, because conceptually they occur before translation of
204
- the resulting translation unit.
205
 
206
  The preprocessing tokens within a preprocessing directive are not
207
  subject to macro expansion unless otherwise stated.
208
 
209
- [*Example 2*:
210
 
211
  In:
212
 
213
  ``` cpp
214
  #define EMPTY
 
37
 
38
  ``` bnf
39
  control-line:
40
  '# include' pp-tokens new-line
41
  pp-import
42
+ '# embed ' pp-tokens new-line
43
  '# define ' identifier replacement-list new-line
44
  '# define ' identifier lparen identifier-listₒₚₜ ')' replacement-list new-line
45
  '# define ' identifier lparen '... )' replacement-list new-line
46
  '# define ' identifier lparen identifier-list ', ... )' replacement-list new-line
47
  '# undef ' identifier new-line
 
64
  '# ifndef ' identifier new-line groupₒₚₜ
65
  ```
66
 
67
  ``` bnf
68
  elif-groups:
69
+ elif-group elif-groupsₒₚₜ
 
70
  ```
71
 
72
  ``` bnf
73
  elif-group:
74
  '# elif ' constant-expression new-line groupₒₚₜ
 
112
  pp-tokensₒₚₜ
113
  ```
114
 
115
  ``` bnf
116
  pp-tokens:
117
+ preprocessing-token pp-tokensₒₚₜ
118
+ ```
119
+
120
+ ``` bnf
121
+ embed-parameter-seq:
122
+ embed-parameter embed-parameter-seqₒₚₜ
123
+ ```
124
+
125
+ ``` bnf
126
+ embed-parameter:
127
+ embed-standard-parameter
128
+ embed-prefixed-parameter
129
+ ```
130
+
131
+ ``` bnf
132
+ embed-standard-parameter:
133
+ 'limit' '(' pp-balanced-token-seq ')'
134
+ 'prefix' '(' pp-balanced-token-seqₒₚₜ ')'
135
+ 'suffix' '(' pp-balanced-token-seqₒₚₜ ')'
136
+ 'if_empty' '(' pp-balanced-token-seqₒₚₜ ')'
137
+ ```
138
+
139
+ ``` bnf
140
+ embed-prefixed-parameter:
141
+ identifier :: identifier
142
+ identifier :: identifier '(' pp-balanced-token-seqₒₚₜ ')'
143
+ ```
144
+
145
+ ``` bnf
146
+ pp-balanced-token-seq:
147
+ pp-balanced-token pp-balanced-token-seqₒₚₜ
148
+ ```
149
+
150
+ ``` bnf
151
+ pp-balanced-token:
152
+ '(' pp-balanced-token-seqₒₚₜ ')'
153
+ '[' pp-balanced-token-seqₒₚₜ ']'
154
+ '{' pp-balanced-token-seqₒₚₜ '}'
155
+ any pp-token except:
156
+ parenthesis (U+0028 (left parenthesis) and U+0029 (right parenthesis)),
157
+ bracket (U+005b (left square bracket) and U+005d (right square bracket)), or
158
+ brace (U+007b (left curly bracket) and U+007d (right curly bracket)).
159
  ```
160
 
161
  ``` bnf
162
  new-line:
163
  the new-line character
164
  ```
165
 
166
+ The implementation can process and skip sections of source files
167
+ conditionally, include other source files, import macros from header
168
+ units, and replace macros. These capabilities are called
169
+ *preprocessing*, because conceptually they occur before translation of
170
+ the resulting translation unit.
171
+
172
  A *preprocessing directive* consists of a sequence of preprocessing
173
  tokens that satisfies the following constraints: At the start of
174
+ translation phase 4, the first preprocessing token in the sequence,
175
+ referred to as a *directive-introducing token*, begins with the first
176
+ character in the source file (optionally after whitespace containing no
177
+ new-line characters) or follows whitespace containing at least one
178
+ new-line character, and is
179
 
180
  - a `#` preprocessing token, or
181
  - an `import` preprocessing token immediately followed on the same
182
+ logical source line by a *header-name*, `<`, *identifier*,
183
+ *string-literal*, or `:` preprocessing token, or
184
  - a `module` preprocessing token immediately followed on the same
185
+ logical source line by an *identifier*, `:`, or `;` preprocessing
186
+ token, or
187
  - an `export` preprocessing token immediately followed on the same
188
+ logical source line by one of the two preceding forms.
189
 
190
+ The last preprocessing token in the sequence is the first preprocessing
191
+ token within the sequence that is immediately followed by whitespace
192
+ containing a new-line character.[^1]
193
 
194
  [*Note 1*: A new-line character ends the preprocessing directive even
195
  if it occurs within what would otherwise be an invocation of a
196
  function-like macro. — *end note*]
197
 
 
221
  ```
222
 
223
  — *end example*]
224
 
225
  A sequence of preprocessing tokens is only a *text-line* if it does not
226
+ begin with a directive-introducing token.
227
+
228
+ [*Example 2*:
229
+
230
+ ``` cpp
231
+ using module = int;
232
+ module i; // not a text-line and not a control-line
233
+ int foo() {
234
+ return i;
235
+ }
236
+ ```
237
+
238
+ The example is not a valid *preprocessing-file*.
239
+
240
+ — *end example*]
241
+
242
+ A sequence of preprocessing tokens is only a
243
+ *conditionally-supported-directive* if it does not begin with any of the
244
+ directive names appearing after a `#` in the syntax. A
245
+ *conditionally-supported-directive* is conditionally-supported with
246
+ *implementation-defined* semantics.
247
+
248
+ If one of the *pp-tokens* of a `#embed` directive (before macro
249
+ replacement) is the *identifier* `limit`, `prefix`, `suffix`, or
250
+ `if_empty` and that *identifier* is defined as a macro
251
+ [[cpp.replace.general]], the program is ill-formed. Any
252
+ *embed-prefixed-parameter* is conditionally-supported, with
253
+ *implementation-defined* semantics.
254
 
255
  At the start of phase 4 of translation, the *group* of a
256
  *pp-global-module-fragment* shall contain neither a *text-line* nor a
257
  *pp-import*.
258
 
 
261
  the directive name and the following new-line character.
262
 
263
  The only whitespace characters that shall appear between preprocessing
264
  tokens within a preprocessing directive (from just after the
265
  directive-introducing token through just before the terminating new-line
266
+ character) are U+0020 (space) and U+0009 (character tabulation)
267
+ (including spaces that have replaced comments or possibly other
268
+ whitespace characters in translation phase 3).
 
 
 
 
 
 
269
 
270
  The preprocessing tokens within a preprocessing directive are not
271
  subject to macro expansion unless otherwise stated.
272
 
273
+ [*Example 3*:
274
 
275
  In:
276
 
277
  ``` cpp
278
  #define EMPTY