|
Production |
|
expression: |
assignment |
|
expression , assignment
|
|
assignment: |
conditional |
|
assignment = assignment
|
|
assignment += assignment
|
|
assignment -= assignment
|
|
assignment *= assignment
|
|
assignment /= assignment
|
|
assignment %= assignment
|
|
assignment &= assignment
|
|
assignment ^= assignment
|
|
assignment |= assignment
|
|
assignment <<= assignment
|
|
assignment >>= assignment
|
|
assignment >>>= assignment
|
|
conditional: |
binary |
|
binary ? expression : conditional |
|
binary: |
unary |
|
binary * binary
|
|
binary / binary
|
|
binary % binary
|
|
binary + binary
|
|
binary - binary
|
|
binary << binary
|
|
binary >> binary
|
|
binary >>> binary
|
|
binary .. binary
|
|
binary == binary
|
|
binary != binary
|
|
binary === binary
|
|
binary !== binary
|
|
binary < binary
|
|
binary > binary
|
|
binary >= binary
|
|
binary <= binary
|
|
binary <> binary
|
|
binary <>= binary
|
|
binary !> binary
|
|
binary !< binary
|
|
binary !>= binary
|
|
binary !<= binary
|
|
binary !<> binary
|
|
binary !<>= binary
|
|
binary & binary
|
|
binary ^ binary
|
|
binary | binary
|
|
binary && binary
|
|
binary || binary
|
|
binary new [ placement ] binary
|
|
binary delete binary
|
|
unary: |
term |
|
reduction |
|
+ unary
|
|
- unary
|
|
~ unary
|
|
& unary
|
|
! unary
|
|
++ unary
|
|
--unary
|
|
new [ placement ] unary
|
|
delete unary
|
|
placement: |
( expression )
|
|
reduction: |
+= unary
|
Binary operators obey precedence that is not expressed in the above grammar.
The following table includes each binary operator.
Operators that appear in the same row have the same precedence.
All operators on the same row have the specified associativity.
For operators that are not found in C, special notes provide some indication of what the operators mean.
| Operator(s) |
Associativity |
Special Notes |
|
* / %
|
left |
|
|
+ -
|
left |
|
|
<< >> >>>
|
left |
The >>> operator is an unsigned right shift, regardless of the type of the left hand operand. |
| .. |
left |
The result of the dot-dot operator is an vector of integers in the specified interval. Operands must have integral type. |
|
< > >= <= !> !< !>= !<= <> <>= !<> !<>=
|
left |
The ! (not) variants of each operator means the opposite of the corresponding operator without the exclamation. If either operand is a floating-point NaN, the positive operators report false. If either operand of the not operators is a NaN, then the operator reports true. |
|
== != === !==
|
left |
The === is identity, for pointer types to distinguish between a class-defined equality and an actual pointer compare. The !== operator is not identical. |
| & |
left |
|
| ^ |
left |
|
| | |
left |
|
| && |
left |
|
| || |
left |
|
|
new delete
|
left |
Binary new and delete operators take a type expression and possible constructor as a unary new and delete would, but take a left-hand argument that is a memory allocator. |
|
= += -= *= /= %= &= ^= |= <<= >>= >>>=
|
right |
The >>>= operator is a shift-assignment in which the left-hand operand does an unsigned right shift in-place, even if the integral type on the left is signed. |
For an explanation of how types are assigned to expressions, see:
Types in Expressions
|
Production |
|
term: |
atom |
|
term ++
|
|
term --
|
|
term ( [ expression [ , expression ] ... ] )
|
|
term [ [ expression ] ]
|
|
term [ expression : [ expression ] ]
|
|
term ...
|
|
term . identifier
|
|
term . bytes
|
|
Production |
|
atom: |
identifier |
|
integer |
|
character |
|
string |
|
floating_point |
|
this |
|
super |
|
true |
|
false |
|
null |
|
( expression )
|
|
[ [ value_initializer [ , value_initializer ] ... [ , ] ] ]
|
|
{ [ value_initializer [ , value_initializer ] ... [ , ] ] }
|
|
class class_body
|
|
function term [ block ] |
|
value_initializer: |
[ assignment : ] assignment
|
|
integer: |
nonzero [ digit ] ... |
|
0 [ octal ] ... |
|
0x hex_digit [ hex_digit ] ... |
|
nonzero: |
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
digit: |
nonzero |
|
0 |
|
octal: |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
|
|
hex_digit: |
digit |
|
a | b | c | d | e | f | A | B | C | D | E | F
|
|
character: |
' any_character '
|
|
' escape '
|
|
string: |
" [ any_character | escape ] ... "
|
|
escape: |
\a |
|
\b |
|
\f |
|
\n |
|
\r |
|
\t |
|
\v |
|
\0 octal
|
|
\x hex_digit [ hex_digit ] ... |
|
\X hex_digit [ hex_digit ] ... |
|
\u hex_digit [ hex_digit ] ... |
|
\U hex_digit [ hex_digit ] ... |