Expression Syntax#
The WorldEdit expression parser is supposed to work like Java and related languages, with a few subtle differences:
Final semicolons can be omitted in most cases.
The last value in a sequence is always returned, even without a return statement.
The binary infix
^operator is a power operator instead of an xor operator and has an according priority as well.There is a postfix factorial operator (
!).There is a binary infix near operator (
~=).No objects :)
Operators#
The expression parser uses Java’s precedence rules, with the following exceptions and additions:
The binary power operator (
^) is between priority 2 and 3The postfix factorial operator (
!) has a priority of 2The near operator (
~=) has a priority of 7
Binary infix#
These operators are put between their two operands.
Prefix#
These operators precede the expression they apply to.
|
(negation) |
|
Bitwise complement (see bitwise binary operators) |
|
Logical complement (see logical binary operators) |
|
Pre-increment |
|
Pre-decrement |
Postfix#
These operators succeed the expression they apply to.
|
Factorial |
|
Post-increment |
|
Post-decrement |
Ternary infix#
The ternary operator is used to represent a conditional expression in a compact way:
<condition> ? <true-branch> : <false-branch>
It works exactly like the if/else statement, except that the branches can only be single expressions.
Functions#
Constants#
The following constants are always available, and cannot be assigned.
|
2.7182818284590452354 |
The base of the natural logarithm |
|
3.14159265358979323846 |
The ratio between circumference and diameter of a circle |
|
1 |
for boolean operations |
|
0 |
for boolean operations |
Block Statements#
Block statements are groups of statements enclosed in braces:
{ x=5; y=6; }
They are mostly used in conjunction with control structures.
Control Structures#
Loops#
Loops can at most loop 256 times.