Files
2025-10-25 03:02:53 +03:00

94 lines
10 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[gram.stmt]
# Annex A (informative) Grammar summary [[gram]](./#gram)
## A.6 Statements [gram.stmt]
[statement:](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
[*labeled-statement*](stmt.label#nt:labeled-statement "8.2Label[stmt.label]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*expression-statement*](stmt.expr#nt:expression-statement "8.3Expression statement[stmt.expr]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*compound-statement*](stmt.block#nt:compound-statement "8.4Compound statement or block[stmt.block]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*selection-statement*](stmt.select.general#nt:selection-statement "8.5.1General[stmt.select.general]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*iteration-statement*](stmt.iter.general#nt:iteration-statement "8.6.1General[stmt.iter.general]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*expansion-statement*](stmt.expand#nt:expansion-statement "8.7Expansion statements[stmt.expand]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*jump-statement*](stmt.jump.general#nt:jump-statement "8.8.1General[stmt.jump.general]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*assertion-statement*](stmt.contract.assert#nt:assertion-statement "8.9Assertion statement[stmt.contract.assert]")
[*declaration-statement*](stmt.dcl#nt:declaration-statement "8.10Declaration statement[stmt.dcl]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*try-block*](except.pre#nt:try-block "14.1Preamble[except.pre]")
[init-statement:](stmt.pre#nt:init-statement "8.1Preamble[stmt.pre]")
[*expression-statement*](stmt.expr#nt:expression-statement "8.3Expression statement[stmt.expr]")
[*simple-declaration*](dcl.pre#nt:simple-declaration "9.1Preamble[dcl.pre]")
[*alias-declaration*](dcl.pre#nt:alias-declaration "9.1Preamble[dcl.pre]")
[condition:](stmt.pre#nt:condition "8.1Preamble[stmt.pre]")
[*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1General[dcl.spec.general]") [*declarator*](dcl.decl.general#nt:declarator "9.3.1General[dcl.decl.general]") [*brace-or-equal-initializer*](dcl.init.general#nt:brace-or-equal-initializer "9.5.1General[dcl.init.general]")
[*structured-binding-declaration*](dcl.pre#nt:structured-binding-declaration "9.1Preamble[dcl.pre]") [*initializer*](dcl.init.general#nt:initializer "9.5.1General[dcl.init.general]")
[for-range-declaration:](stmt.pre#nt:for-range-declaration "8.1Preamble[stmt.pre]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*decl-specifier-seq*](dcl.spec.general#nt:decl-specifier-seq "9.2.1General[dcl.spec.general]") [*declarator*](dcl.decl.general#nt:declarator "9.3.1General[dcl.decl.general]")
[*structured-binding-declaration*](dcl.pre#nt:structured-binding-declaration "9.1Preamble[dcl.pre]")
[for-range-initializer:](stmt.pre#nt:for-range-initializer "8.1Preamble[stmt.pre]")
[*expr-or-braced-init-list*](dcl.init.general#nt:expr-or-braced-init-list "9.5.1General[dcl.init.general]")
[label:](stmt.label#nt:label "8.2Label[stmt.label]")
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt [*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]") :
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt case [*constant-expression*](expr.const#nt:constant-expression "7.7Constant expressions[expr.const]") :
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt default :
[labeled-statement:](stmt.label#nt:labeled-statement "8.2Label[stmt.label]")
[*label*](stmt.label#nt:label "8.2Label[stmt.label]") [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
[expression-statement:](stmt.expr#nt:expression-statement "8.3Expression statement[stmt.expr]")
[*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]")opt ;
[compound-statement:](stmt.block#nt:compound-statement "8.4Compound statement or block[stmt.block]")
{ [*statement-seq*](stmt.block#nt:statement-seq "8.4Compound statement or block[stmt.block]")opt [*label-seq*](stmt.block#nt:label-seq "8.4Compound statement or block[stmt.block]")opt }
[statement-seq:](stmt.block#nt:statement-seq "8.4Compound statement or block[stmt.block]")
[*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]") [*statement-seq*](stmt.block#nt:statement-seq "8.4Compound statement or block[stmt.block]")opt
[label-seq:](stmt.block#nt:label-seq "8.4Compound statement or block[stmt.block]")
[*label*](stmt.label#nt:label "8.2Label[stmt.label]") [*label-seq*](stmt.block#nt:label-seq "8.4Compound statement or block[stmt.block]")opt
[selection-statement:](stmt.select.general#nt:selection-statement "8.5.1General[stmt.select.general]")
if constexpropt ( [*init-statement*](stmt.pre#nt:init-statement "8.1Preamble[stmt.pre]")opt [*condition*](stmt.pre#nt:condition "8.1Preamble[stmt.pre]") ) [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
if constexpropt ( [*init-statement*](stmt.pre#nt:init-statement "8.1Preamble[stmt.pre]")opt [*condition*](stmt.pre#nt:condition "8.1Preamble[stmt.pre]") ) [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]") else [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
if !opt consteval [*compound-statement*](stmt.block#nt:compound-statement "8.4Compound statement or block[stmt.block]")
if !opt consteval [*compound-statement*](stmt.block#nt:compound-statement "8.4Compound statement or block[stmt.block]") else [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
switch ( [*init-statement*](stmt.pre#nt:init-statement "8.1Preamble[stmt.pre]")opt [*condition*](stmt.pre#nt:condition "8.1Preamble[stmt.pre]") ) [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
[iteration-statement:](stmt.iter.general#nt:iteration-statement "8.6.1General[stmt.iter.general]")
while ( [*condition*](stmt.pre#nt:condition "8.1Preamble[stmt.pre]") ) [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
do [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]") while ( [*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]") ) ;
for ( [*init-statement*](stmt.pre#nt:init-statement "8.1Preamble[stmt.pre]") [*condition*](stmt.pre#nt:condition "8.1Preamble[stmt.pre]")opt ; [*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]")opt ) [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
for ( [*init-statement*](stmt.pre#nt:init-statement "8.1Preamble[stmt.pre]")opt [*for-range-declaration*](stmt.pre#nt:for-range-declaration "8.1Preamble[stmt.pre]") : [*for-range-initializer*](stmt.pre#nt:for-range-initializer "8.1Preamble[stmt.pre]") ) [*statement*](stmt.pre#nt:statement "8.1Preamble[stmt.pre]")
[expansion-statement:](stmt.expand#nt:expansion-statement "8.7Expansion statements[stmt.expand]")
template for ([*init-statement*](stmt.pre#nt:init-statement "8.1Preamble[stmt.pre]")opt [*for-range-declaration*](stmt.pre#nt:for-range-declaration "8.1Preamble[stmt.pre]") :[*expansion-initializer*](stmt.expand#nt:expansion-initializer "8.7Expansion statements[stmt.expand]") ) [*compound-statement*](stmt.block#nt:compound-statement "8.4Compound statement or block[stmt.block]")
[expansion-initializer:](stmt.expand#nt:expansion-initializer "8.7Expansion statements[stmt.expand]")
[*expression*](expr.comma#nt:expression "7.6.20Comma operator[expr.comma]")
[*expansion-init-list*](stmt.expand#nt:expansion-init-list "8.7Expansion statements[stmt.expand]")
[expansion-init-list:](stmt.expand#nt:expansion-init-list "8.7Expansion statements[stmt.expand]")
{ [*expression-list*](expr.post.general#nt:expression-list "7.6.1.1General[expr.post.general]")opt }
[jump-statement:](stmt.jump.general#nt:jump-statement "8.8.1General[stmt.jump.general]")
break ;
continue ;
return [*expr-or-braced-init-list*](dcl.init.general#nt:expr-or-braced-init-list "9.5.1General[dcl.init.general]")opt ;
[*coroutine-return-statement*](stmt.return.coroutine#nt:coroutine-return-statement "8.8.5The co_­return statement[stmt.return.coroutine]")
goto [*identifier*](lex.name#nt:identifier "5.11Identifiers[lex.name]") ;
[coroutine-return-statement:](stmt.return.coroutine#nt:coroutine-return-statement "8.8.5The co_­return statement[stmt.return.coroutine]")
co_return [*expr-or-braced-init-list*](dcl.init.general#nt:expr-or-braced-init-list "9.5.1General[dcl.init.general]")opt ;
[assertion-statement:](stmt.contract.assert#nt:assertion-statement "8.9Assertion statement[stmt.contract.assert]")
contract_assert [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]")opt ( [*conditional-expression*](expr.cond#nt:conditional-expression "7.6.16Conditional operator[expr.cond]") ) ;
[declaration-statement:](stmt.dcl#nt:declaration-statement "8.10Declaration statement[stmt.dcl]")
[*block-declaration*](dcl.pre#nt:block-declaration "9.1Preamble[dcl.pre]")