Simple operator precidence chart (and associativity)?
Timon Gehr
timon.gehr at gmx.ch
Tue Mar 13 16:14:14 PDT 2012
On 03/13/2012 11:29 PM, Nick Sabalausky wrote:
> I'm reading through D's grammar spec, and maybe it's just not enough sleep
> or some such, but my brain is turning to mud:
>
> Is there a simple operator precidence chart somewhere?
I don't think there is, but I think I can create one:
! // 1 template instantiation
=> // 2 goesto, binds weaker to the right
. ++ -- ( [ // 3 postfix operators
^^ // 4 power (right-associative)
& ++ -- * - + ! ~ // 5 prefix operators
* / % // 6 multiplicative operators
+ - ~ // 7 additive operators
>> << >>> // 8 shift operators
== != > < >= <= \ // 9 relational operators
!> !< !>= !<= <>\
!<> <>= !<>= in \
!in is !is
& // 10 bitwise AND (ambiguous with 9)
^ // 11 bitwise XOR (ambiguous with 9)
| // 12 bitwise OR (ambiguous with 9)
&& // 13 logical AND
|| // 14 logical OR
?: // 15 conditional operator
/= &= |= -= += \ // 16 assignment operators (right-associative)
<<= >>= >>>= = \
*= %= ^= ^^= ~=
=> // 17 goesto, binds stronger to the left
, // 18 comma operator
.. // range (not actually an operator)
> (Also, for
> associativity: Assign and OpAssign are right-associative and everything else
> is left-associative, correct?)
>
>
Power is right-associative too.
More information about the Digitalmars-d-learn
mailing list