]> git.proxmox.com Git - rustc.git/blob - vendor/pest_derive/examples/calc.pest
New upstream version 1.68.2+dfsg1
[rustc.git] / vendor / pest_derive / examples / calc.pest
1 WHITESPACE = _{ " " | "\t" | NEWLINE }
2
3 program = { SOI ~ expr ~ EOI }
4 expr = { prefix* ~ primary ~ postfix* ~ (infix ~ prefix* ~ primary ~ postfix* )* }
5 infix = _{ add | sub | mul | div | pow }
6 add = { "+" } // Addition
7 sub = { "-" } // Subtraction
8 mul = { "*" } // Multiplication
9 div = { "/" } // Division
10 pow = { "^" } // Exponentiation
11 prefix = _{ neg }
12 neg = { "-" } // Negation
13 postfix = _{ fac }
14 fac = { "!" } // Factorial
15 primary = _{ int | "(" ~ expr ~ ")" }
16 int = @{ (ASCII_NONZERO_DIGIT ~ ASCII_DIGIT+ | ASCII_DIGIT) }