Simple operator precidence chart (and associativity)?

Nick Sabalausky a at a.a
Tue Mar 13 17:20:34 PDT 2012


"Timon Gehr" <timon.gehr at gmx.ch> wrote in message 
news:jjokc7$t3j$1 at digitalmars.com...
> 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:
>

Thanks!

> == != > < >= <= \ // 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)

Ah, see, that's what I was tripping up on. I thought there seemed to be 
something slightly odd going on with those (and then from there I started 
second-guessing everything). It seemed almost like these had both ordered 
priorities *and* the same priority.

So how exactly does this part work then?

>
>> (Also, for
>> associativity: Assign and OpAssign are right-associative and everything 
>> else
>> is left-associative, correct?)
>>
>>
>
> Power is right-associative too.

Oh that's right. I keep forgetting we have that now.




More information about the Digitalmars-d-learn mailing list