Expression Operator Precedence

< Previous | Contents | Manuals Home | Boris FX | Next >

Expression Operator Precedence

Sizzle uses a simplified operator precedence, especially compared to C++. The precedences have been adjusted to make embedding script in boilerplate easy. The operators are listed from highest to lowest.


Terms (expr), [index], ob.attr, function calls, #ob,

$indirection

Autoincrements ++x, --x, x++, x—

Powers x**2

Negations -x, ~x

Multiplications x*y, x/y, x%y, x&y, x^y, x<<y, x>>y

Additions x+y, x-y, x|y

Selection (q ? x : y)

Relations x<y, x>y, x==y, x!=y, x<=y, x>=y

Boolean Negate !(x==3)

Boolean And x>y && y>z

Boolean Or x==5 || y>3

Assignments x=y, x+= y, x -= y, x *= y, x /= y, x &= y, x |= y, x ^= y

Concatenation “a” x=”b” 2+3 x produces “a5b”


All numbers are 64-bit floating point, but hexadecimal constants, logical shifts, and booleans are treated as 32-bit integers.

Note that the assignment operators do not produce output to the file, as in the concatenation example above. The mini-script @[x=”Hi” “there”]@ writes “there” (without the quotes) to the output file, assigning “Hi” to the variable x. This is because concatenation is lower in the precedence table than assignment, so the assignment “=” binds only to “Hi”. If you wanted x to be “Hi There”, you would write [@x=(“Hi” “There”)]@, which would output nothing. Though this means you need parentheses for this example, the precedence above eliminates the need to end each line with a semicolon or end of line.

©2024 Boris FX, Inc. — UNOFFICIAL — Converted from original PDF.