No edit summary |
|||
(One intermediate revision by the same user not shown) | |||
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 | Str | '(' Expr ')' | |||
Args ::= Expr (',' Expr)? | Args ::= Expr (',' Expr)? | ||
Line 17: | Line 19: | ||
PlusMinus ::= [+-] /* ws: explicit */ | PlusMinus ::= [+-] /* ws: explicit */ | ||
MulDiv ::= [*/] /* ws: explicit */ | MulDiv ::= [*/] /* ws: explicit */ | ||
Num ::= ('0' | [1-9]+) ('.' [ | Num ::= ('0' | [1-9]+) ('.' [0-9]+)? /* ws: explicit */ | ||
Str ::= '"' [^"]* '"' /* ws: explicit */ | |||
Name ::= [a-z] [a-z0-9_]* /* ws: explicit */ | Name ::= [a-z] [a-z0-9_]* /* ws: explicit */ | ||
</pre> | </pre> |
Latest revision as of 20:05, 12 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 | Str | '(' Expr ')' Args ::= Expr (',' Expr)? PlusMinus ::= [+-] /* ws: explicit */ MulDiv ::= [*/] /* ws: explicit */ Num ::= ('0' | [1-9]+) ('.' [0-9]+)? /* ws: explicit */ Str ::= '"' [^"]* '"' /* 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