You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a note from a discussion with Richard, for future consideration. We have a few places in which we spell out in prose how to form a balanced preprocessor token sequence. This could be simplified if we defined a new piece of grammar. The idea, as described by @zygoloid, might look like this:
pp-balanced-token:
any preprocessor-token other than ( or )
( pp-balanced-token-seq[opt] )
pp-balanced-token-seq:
pp-balanced-token
pp-balanced-token-seq pp-balanced-token
va-opt-replacement:
__VA_OPT__ ( pp-balanced-token-seq[opt] )
Then:
"""
delete [cpp.replace.general]p5 (it's misplaced anyway; this belongs in p12).
I
n p12, delete "Each subsequent [...rest of paragraph 12 and paragraph 13...]".
Add new paragraph after p12, combining parts of p5, p12, p13:
"Each instance of a function-like macro name followed by a ( as the next preprocessing token shall be a function-like macro invocation of the form:
identifier ( pp-balanced-token-seq[opt] )
Within the sequence of preprocessing tokens making up an invocation of a function-like macro, new-line is considered a normal whitespace character. The arguments of the macro invocation are the sequences of pp-balanced-tokens separated by comma preprocessing tokens. If the identifier-list in the macro definition does not end with an ellipsis, the number of arguments (including those arguments consisting of no pp-balanced-tokens) shall equal the number of parameters in the macro definition. Otherwise, there shall be at least as many arguments in the invocation as there are parameters in the macro definition (excluding the ...). If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives,[Footnote] the behavior is undefined."
Then include p15 ("If there is a ... immediately preceding the )").
Then a new paragraph defining the semantics:
"Each function-like macro invocation is replaced by the replacement list in the macro definition, after performing argument substitution as described in [cpp.subst]."
Then finally p14 (the example).
I might also want to split out an "object-like macro" and a "function-like macro" section from [cpp.replace.general]
"""
The text was updated successfully, but these errors were encountered:
jensmaurer
changed the title
Consider introducing a new grammar pp-balanced-token-seq
Consider introducing a new grammar _pp-balanced-token-seq_
Oct 23, 2021
jensmaurer
changed the title
Consider introducing a new grammar _pp-balanced-token-seq_
Consider introducing a new grammar /pp-balanced-token-seq/
Oct 23, 2021
jensmaurer
changed the title
Consider introducing a new grammar /pp-balanced-token-seq/
Consider introducing a new grammar pp-balanced-token-seqOct 23, 2021
Introducing this as a grammar token is likely to make life a lot easier and I would probably introduce this change in coordination with __VA_OPT__ getting into C23!
Just a note from a discussion with Richard, for future consideration. We have a few places in which we spell out in prose how to form a balanced preprocessor token sequence. This could be simplified if we defined a new piece of grammar. The idea, as described by @zygoloid, might look like this:
Then:
"""
delete [cpp.replace.general]p5 (it's misplaced anyway; this belongs in p12).
I
n p12, delete "Each subsequent [...rest of paragraph 12 and paragraph 13...]".
Add new paragraph after p12, combining parts of p5, p12, p13:
"Each instance of a function-like macro name followed by a ( as the next preprocessing token shall be a function-like macro invocation of the form:
Within the sequence of preprocessing tokens making up an invocation of a function-like macro, new-line is considered a normal whitespace character. The arguments of the macro invocation are the sequences of pp-balanced-tokens separated by comma preprocessing tokens. If the identifier-list in the macro definition does not end with an ellipsis, the number of arguments (including those arguments consisting of no pp-balanced-tokens) shall equal the number of parameters in the macro definition. Otherwise, there shall be at least as many arguments in the invocation as there are parameters in the macro definition (excluding the ...). If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives,[Footnote] the behavior is undefined."
Then include p15 ("If there is a ... immediately preceding the )").
Then a new paragraph defining the semantics:
"Each function-like macro invocation is replaced by the replacement list in the macro definition, after performing argument substitution as described in [cpp.subst]."
Then finally p14 (the example).
I might also want to split out an "object-like macro" and a "function-like macro" section from [cpp.replace.general]
"""
The text was updated successfully, but these errors were encountered: