No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
<pre> | <pre> | ||
Expr ::= Add | Expr ::= Add | ||
Add | Add ::= Mod (PlusMinus Add)? | ||
Mul | Mod ::= Mul ('%' Mul)? | ||
Pow | Mul ::= Pow (MulDiv Mul)? | ||
Call ::= Var | Name ('(' Args ')')? | Pow ::= Minus ('^' Minus)? | ||
Var | Minus ::= '-'? Call | ||
Call ::= Var | Name ('(' Args ')')? | |||
Var ::= Name | Num | '(' Expr ')' | |||
Args ::= Expr (',' Expr)? | Args ::= Expr (',' Expr)? |
Revision as of 13:51, 11 February 2024
EBNF Grammar
For a graphical representation, take a look at this website.
Expr ::= Add Add ::= Mod (PlusMinus Add)? Mod ::= Mul ('%' Mul)? Mul ::= Pow (MulDiv Mul)? Pow ::= Minus ('^' Minus)? Minus ::= '-'? 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