Appendix D C++ Subset Syntax

The notation used for representing the C++ syntax in this document is described here.

Keywords

cppkeyword auto | break | bool | case | catch | char | const | const_cast | continue | default | delete | do | double | dynamic_cast | else | extern | false | float | for | goto | if | int | long | mutable | namespace | new | nullptr | operator | register | reinterpret_cast | return | short | signed | sizeof | static | static_cast | switch | this | throw | true | try | typedef | typeid | unsigned | using | void | volatile | wchar_t | while

Statements

statement labeled‑statement | empty‑statement | compound‑statement | selection‑statement | iteration‑statement | jump‑statement | declaration‑statement | try‑statement | expression‑statement
labeled‑statement identifier : statement | case : statement | default : statement
empty‑statement ;
compound‑statement { statement* }
selection‑statement if‑statement | switch‑statement
if‑statement if ( condition | ) statement (else statement)?
switch‑statement switch ( condition | ) statement
iteration‑statement while‑statement | do‑statement | range‑for‑statement | for‑statement
while‑statement while ( condition | ) statement
do‑statement do statement while ( expression ) ;
range‑for‑statement for ( for‑range‑declaration : expression ) statement
for‑range‑declaration type‑specifier‑seq declarator
for‑statement for ( for‑init‑statement condition ; expression? ) statement
for‑init‑statement empty‑statement | expression‑statement | simple‑declaration
jump‑statement break‑statement | continue‑statement | return‑statement | goto‑statement
break‑statement break ;
continue‑statement continue ;
return‑statement return expression? ;
goto‑statement goto identifier ;
declaration‑statement block‑declaration
condition type‑id declarator = assignment‑expression | expression
try‑statement try compound‑statement handler‑seq
handler‑seq handler handler‑seq?
handler catch ( exception‑declaration ) compound‑statement
exception‑declaration type‑specifier‑seq ( declarator | abstract‑declarator )? | ...
expression‑statement expression ;

Expressions

expression assignment‑expression (, assignment‑expression)*
constant‑expression expression
assignment‑expression logical‑or‑expression assignment‑op assignment‑expression | conditional‑expression | throw‑expression
assignment‑op = | *= | /= | %= | += | -= | <<= | >>= | &= | ^= | |=
conditional‑expression logical‑or‑expression ? expression : assignment‑expression
throw‑expression throw assignment‑expression?
logical‑or‑expression logical‑and‑expression (|| logical‑and‑expression)*
logical‑and‑expression inclusive‑or‑expression (&& inclusive‑or‑expression)*
inclusive‑or‑expression exclusive‑or‑expression (| exclusive‑or‑expression)*
exclusive‑or‑expression and‑expression (^ and‑expression)*
and‑expression equality‑expression (& equality‑expression)*
equality‑expression relational‑expression ((== | !=) relational‑expression)*
relational‑expression shift‑expression ((< | > | <= | >=) shift‑expression)*
shift‑expression additive‑expression ((<< | >>) additive‑expression)*
additive‑expression multiplicative‑expression ((+ | -) multiplicative‑expression)*
multiplicative‑expression pm‑expression ((* | / | %) pm‑expression)*
pm‑expression cast‑expression ((.* | ->*) cast‑expression)*
cast‑expression ( type‑id ) cast‑expression | unary‑expression
unary‑expression postfix‑expression | postcast‑expression | ++ unary‑expression | -- unary‑expression | unary‑operator cast‑expression | sizeof ( type‑id ) | sizeof unary‑expression | new‑expression | delete‑expression
unary‑operator + | - | * | & | ! | ~
postfix‑expression primary‑expression
( [ expression ] | ( expression‑list ) | . id‑expression | -> id‑expression | ++ | -- )* | type‑specifier‑or‑type‑name ( expression‑list )
postcast‑expression ( dynamic_cast | static_cast | reinterpret_cast | const_cast ) < type‑id > ( expression ) | type‑id ( expression )
expression‑list assignment‑expression (, assignment‑expression)*
primary‑expression literal | this | ( expression ) | id‑expression
id‑expression qualified‑cpp‑id :: operator‑function‑id | ::? operator‑function‑id | qualified‑cpp‑id
type‑specifier‑or‑type‑name simple‑type‑specifier | type‑name
new‑expression ::? new new‑placement (new‑type‑id | ( type‑id )) new‑initializer?
new‑placement ( expression‑list )
new‑type‑id (type‑specifier‑seq | type‑name) new‑declarator
new‑declarator (ptr‑operator new‑declarator? | direct‑new‑declarator
new‑initializer ( expression‑list? )
direct‑new‑declarator [ expression ] ([ constant‑expression ] )*
delete‑expression ::? delete ([ ])? cast‑expression
operator‑function‑id operator operator
operator [ ] | ( ) | ->* | -> | , | -- | ++ | || | && | <= | >= | != | = | <<= | >>= | << | >> | |= | &= | ^= | %= | /= | *= | -= | += | < | > | = | ! | ~ | | | & | ^ | % | / | * | - | + | new [ ] | delete [ ] | new | delete

Identifiers

qualified‑cpp‑id ::? identifer (:: identifer)*

Literals

literal integer‑literal | floating‑literal | character‑literal | string‑literal | true | false | nullptr

Declarators

init‑declarator‑list init‑declarator (, init‑declarator)*
init‑declarator declarator initiazer?
declarator direct‑declarator | ptr‑operator declarator
direct‑declarator declarator‑id ( [ constant‑expression? ] | ( declarator ) )*
declarator‑id id‑expression | type‑name
type‑id (type‑specifier‑seq | type‑name) abstract‑declarator?
type type‑specifier+ | type‑name
type‑specifier‑seq type‑specifier+
abstract‑declarator ptr‑operator abstract‑declarator? | direct‑abstract‑declarator
direct‑abstract‑declarator [ constant‑expression? ] ( abstract‑declarator )
ptr‑operator * cv‑qualifier‑seq? | &
cv‑qualifier‑seq cv‑qualifier+
initializer = initializer‑clause | ( expression‑list )
initializer‑clause assignment‑expression | { initializer‑list } | { }
initializer‑list initializer‑clause (, initializer‑clause)*

Declarations

block‑declaration namespace‑alias‑definition | using‑directive | using‑declaration | simple‑declaration
simple‑declaration decl‑specifier‑seq? init‑declarator‑list? ;
decl‑specifier‑seq decl‑specifier+ | type‑name
decl‑specifier storage‑class‑specifier | type‑specifier | typedef
storage‑class‑specifier auto | register | static | extern | mutable
type‑specifier simple‑type‑specifier | cv‑qualifier
simple‑type‑specifier char | wchar_t | bool | short | int | long | signed | unsigned | float | double | void
type‑name qualified‑cpp‑id (< template‑argument‑list >)?
template‑argument‑list template‑argument (, template‑argument)*
template‑argument type‑id | assignment‑expression
typedef typedef
cv‑qualifier const | volatile
namespace‑alias‑definition namespace identifer = qualified‑cpp‑id ;
using‑declaration using qualified‑cpp‑id ;
using‑directive using namespace qualified‑cpp‑id ;