Search code examples
d

D Operator Precedence levels (version 1.0)


Does anyone know where the listing for levels of operator precedence for D version 1.0 are located on line?


Solution

  • In the page http://www.digitalmars.com/d/1.0/expression.html, the stuff appear higher have lower precedence in general. To get the specific precedence, follow the parser rules.

    15.   typeof() typeid() is()
          assert() import() mixin()
          function delegate
          T.x x!y
          variables
          (...) [...]       //(Primary expressions)
          "x" "y"           //(Concatenation between string literals)
    14.   . x++ x--
          x() x[]           //(Postfix operators)
    13.   & ++x --x * 
          +x -x ! ~ (T).
          new delete
          cast              //(Prefix operators)
    12½.  ^^                //(Power. D2 only)
    12.   * / %            ///(Multiplicative operators)
    11.   + - ~             //(Additive operators)
    10.   >> << >>>         //(Bitwise shift)
     9.   == != is !is
          > < >= <=
          !> !< !>= !<=
          <> !<> <>= !<>=
          in !in            //(Comparison operators)
     8.   &                 //(Bitwise AND)
     7.   ^                 //(Bitwise XOR)
     6.   |                 //(Bitwise OR)
     5.   &&                //(Logical AND)
     4.   ||                //(Logical OR)
     3.   ?:                //(Conditional operator)
     2.   op=               //(Assignment operator)
     1⅔.  =>                //(Lambda. D2 only. Not really an operator)
     1⅓.  ..                //(Slicing. Not really an operator)
     1.   ,                 //(Comma operator)