User:Sunjammer/Operator (draft)

From Dragon Age Toolset Wiki
< User:Sunjammer
Revision as of 22:29, 13 April 2020 by Sunjammer (Talk | contribs) (Created)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

An operator is symbol that performs a prescribed operation on one or more operands.

The dascript compiler recognizes the following operators:

Operator Symbol
String operators
Concatenation +
Arithmetic operators
Arithmetic negation -
Increment ++
Decrement --
Addition +
Subtraction -
Multiplication *
Division /
Modulo  %
Bitwise operators
Bitwise complement ~
Bitwise AND &
Bitwise OR |
Bitwise XOR ^
Bitwise left shift <<
Bitwise arithmetic right shift >>
Bitwise logical right shift >>>
Logical operators
Logical negation  !
Conditional AND &&
Conditional OR ||
Relational operators
Equality ==
Inequality  !=
Less than <
Greater than >
Less than or equal to <=
Greater than or equal to >=
Assignment operators
Assignment =
Addition assignment +=
Subtraction assignment -=
Multiplication assignment *=
Division assignment \=
Modulo assignment  %=
Bitwise AND assignment &=
Bitwise OR assignment |=
Bitwise XOR assignment ^=
Concatenation assignment +=
Bitwise left shift assignment <<=
Bitwise arithmetic right shift assignment >>=
Bitwise logical right shift assignment >>>=
Member access operators
Dot .
Conditional operators
Conditional  ?:

Remarks

Operators may be categorised based on the number of operands:

  • Unary - one operand
  • Binary - two operands
  • Ternary - three operands

Operator precedence:

  • TODO

Operator associativity:

  • Left-associative operators are evaluated in order from left to right. Except for the assignment operators all binary operators are left-associative. For example, a + b - c is evaluated as (a + b) - c.
  • Right-associative operators are evaluated in order from right to left. The assignment operators, and the conditional operator are right-associative. For example, x = y = z is evaluated as x = (y = z).

See also