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.
Postfix#
These operators succeed the expression they apply to.
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#
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.