Module:ColinTheCat/Expression/doc

From Resonite Wiki

This is the documentation page for Module:ColinTheCat/Expression

EBNF Grammar

What's EBNF?

For a graphical representation, take a look at this website.

Expr ::= Add
Add  ::= Mul (PlusMinus Add)?
Mul  ::= Exp (MulDiv Mul)?
Pow  ::= Call ('^' Call)?
Call ::= Var | Name ('(' Args ')')?
Var  ::= Name | Num | '(' Expr ')'

Args ::= Expr (',' Expr)?

PlusMinus ::= [+-]                           /* ws: explicit */
MulDiv    ::= [*/]                           /* ws: explicit */
Num       ::= ('0' | [1-9]+) ('.' [1-9]+)?   /* ws: explicit */
Name      ::= [a-z] [a-z0-9_]*               /* ws: explicit */

Example

{{#invoke:ColinTheCat/Expression|Eval
| 2 * (1 + min(10, x))
| {"x": 2}
}}

2 * (1 + min(10, x)) (x=2) evaluates to 6