diff options
Diffstat (limited to '')
-rw-r--r-- | vendor/pest_derive/examples/calc.pest | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/vendor/pest_derive/examples/calc.pest b/vendor/pest_derive/examples/calc.pest new file mode 100644 index 000000000..9f2cc3b74 --- /dev/null +++ b/vendor/pest_derive/examples/calc.pest @@ -0,0 +1,16 @@ +WHITESPACE = _{ " " | "\t" | NEWLINE } + + program = { SOI ~ expr ~ EOI } + expr = { prefix* ~ primary ~ postfix* ~ (infix ~ prefix* ~ primary ~ postfix* )* } + infix = _{ add | sub | mul | div | pow } + add = { "+" } // Addition + sub = { "-" } // Subtraction + mul = { "*" } // Multiplication + div = { "/" } // Division + pow = { "^" } // Exponentiation + prefix = _{ neg } + neg = { "-" } // Negation + postfix = _{ fac } + fac = { "!" } // Factorial + primary = _{ int | "(" ~ expr ~ ")" } + int = @{ (ASCII_NONZERO_DIGIT ~ ASCII_DIGIT+ | ASCII_DIGIT) }
\ No newline at end of file |