This documentation contains the C++ subset syntax that can be used in the semantic actions of a parser and in the rules and actions of a lexer.
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 | char8_t | char16_t | char32_t | 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 cpp‑identifier = qualified‑cpp‑id ; |
using‑declaration | → | using qualified‑cpp‑id ; |
using‑directive | → | using namespace qualified‑cpp‑id ; |
init‑declarator‑list | → | init‑declarator ( , init‑declarator )* |
init‑declarator | → | declarator initializer? |
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‑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 )* |
expression | → | assignment‑expression ( , assignment‑expression )* |
constant‑expression | → | expression |
assignment‑expression | → | logical‑or‑expression asssignment‑op assignment‑expression | conditional‑expression | throw‑expression |
assignment‑op | → | = | *= | /= | %= | += | -= | <<= | >>= | &= | ^= | |= |
conditional‑expression | → | logical‑or‑expression ( ? expression : 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 ( eq‑op relational‑expression )* |
eq‑op | → | == | != |
relational‑expression | → | shift‑expression ( rel‑op shift‑expression )* |
rel‑op | → | < | > | <= | >= |
shift‑expression | → | additive‑expression ( shift‑op additive‑expression )* |
shift‑op | → | << | >> |
additive‑expression | → | multiplicative‑expression ( add‑op multiplicative‑expression )* |
add‑op | → | + | - |
multiplicative‑expression | → | pm‑expression ( mul‑op pm‑expression )* |
mul‑op | → | * | / | % |
pm‑expression | → | cast‑expression ( pm‑op cast‑expression )* |
pm‑op | → | .* | ‑>* | |
cast‑expression | → | ( ( type‑id ) cast‑expression ) | unary‑expression |
unary‑expression | → | postfix‑expression | postcast‑expression | ++ unary‑expression | -- unary‑expression | unary‑op cast‑expression | sizeof ( type‑id ) | sizeof unary‑expression | new‑expression | delete‑expression |
unary‑op | → | * | & | + | - | ! | ~ |
postfix‑expression | → | primary‑expression ( [ expression ] | ( expression‑list ) | . id‑expression | ‑> id‑expression | ++ | -- )* |
postcast‑expression | → | ( static_cast | dynamic_cast | const_cast | reinterpret_cast ) < type‑id > ( expression ) | typeid ( 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 |
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 |
cpp‑identifier | → | identifier |
qualified‑cpp‑id | → | ::? cpp‑identifier ( :: cpp‑identifier )* |
literal | → | integer‑literal | floating‑literal | char‑literal | string‑literal | true | false | nullptr |