The full details of the experiment is available on a branch of my GitHub repository.
Summary:
- All binary operators and the conditional expression operator are left-associative.
- Conditional expressions (cond ? true_expr : false_expr) are more tightly binding than any other operator (parentheses notwithstanding). This is different from how most C/C++-based programming languages, which given them much lower priority.
- The true_expr does not accept "naked" binary operators. For example, 5 ? 2 + 3 : 7 is invalid syntax. To use binary operators in true_expr, you must surround them with parentheses like this: (5 ? (2 + 3) : 7).
- The true_expr and false_expr do not accept "naked" unary operators. For example, 2 ? -5 : -3 is invalid syntax. To use unary operators in true_expr or false_expr, you must surround them with parentheses like this: (2 ? (-5) : (-3)).
- There is no unary plus (+) operator. Diablo 2 simply does not support it.
- The unary minus (-) operator cannot be chained. For example, --3 and - -5 are both invalid. However, -(-7) works.
Group | Operator |
---|---|
Parenthesis | ( expr ) |
Conditional Expression | cond ? true_expr : false_expr |
Unary Operator | - |
Multiplication and Division | *, / |
Addition and Subtraction | +, - |
Comparisons | ==, !=, >, <, >=, <= |