1 WHITESPACE = _{ " " | "\t" | NEWLINE }
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
12 neg = { "-" } // Negation
14 fac = { "!" } // Factorial
15 primary = _{ int | "(" ~ expr ~ ")" }
16 int = @{ (ASCII_NONZERO_DIGIT ~ ASCII_DIGIT+ | ASCII_DIGIT) }