Extension:Expressions

The Expressions extension enhances the wikitext parser with boolean algebra.

Usage
This extension introduces the parser function #expression. It evaluates an expression and returns one of two strings depending on the result:



The available operators are listed below, in order of precedence.

The extension makes use of type juggling when comparing two values. Therefore, non-empty strings are converted to, zero is converted to  , et cetera:


 * → 1
 * → 1
 * → 1
 * → 1
 * → 0

Two values can be compared before type juggling using the strict equality operator:


 * → 1
 * → 0

You can read more about type juggling here.

Associativity
All binary operators are left-associative. This means the left part of an expression is evaluated first if the operators have the same precedence (see below for the order of precedence):


 * →  →   → 1
 * →  →   → 0

This might not be what you expect at first, therefore it is important to keep it in mind.

Type operators
Some operators are strictly typed. This means they require their operand(s) to be of a certain type or else an error will occur. The table below lists all typed operators with their required type(s).

When something other than the required type is used, the evaluator will throw an exception.

Operators
The table below lists all operators, in order of precedence from highest to lowest.