From b58b03c22d637fe8f7200edb6953325bf359544d Mon Sep 17 00:00:00 2001 From: Nathan Perry Date: Wed, 7 Aug 2024 07:39:16 -0400 Subject: split calc into separate subcrate --- src/commands/calc.pest | 79 -------------------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 src/commands/calc.pest (limited to 'src/commands/calc.pest') diff --git a/src/commands/calc.pest b/src/commands/calc.pest deleted file mode 100644 index 07eeddb..0000000 --- a/src/commands/calc.pest +++ /dev/null @@ -1,79 +0,0 @@ -num = { - hex - | oct - | binary - | float -} - -float = @{ int ~ ( "." ~ ASCII_DIGIT*)? ~ (^"e" ~ int)? } - int = { "-"? ~ ASCII_DIGIT+ } - -hex = @{ "0x" ~ ASCII_HEX_DIGIT+ } -oct = @{ "0o" ~ ASCII_OCT_DIGIT+ } -binary = @{ "0b" ~ ASCII_BIN_DIGIT+ } - -infix = _{ add | sub | mul | div | modulo } - add = { "+" } - sub = { "-" } - modulo = { "%" | "mod" } - mul = { "*" } - div = { "/" } - -tight_infix = _{ dice | pow } - dice = { "d" } - pow = { "^" } - -trig = _{ sin | cos | tan | asin | acos | atan } - sin = { "sin" } - cos = { "cos" } - tan = { "tan" } - asin = { "asin" } - acos = { "acos" } - atan = { "atan" } - -htrig = _{ sinh | cosh | tanh | asinh | acosh | atanh } - sinh = { "sinh" } - cosh = { "cosh" } - tanh = { "tanh" } - asinh = { "asinh" } - acosh = { "acosh" } - atanh = { "atanh" } - -unary_prefix = _{ log | sqrt | sgn | htrig | trig | exp | abs | ceil | floor | round } - log = { "log" | "ln" } - sqrt = { "sqrt" } - sgn = { "sgn" } - exp = { "exp" } - abs = { "abs" } - ceil = { "ceil" } - floor = { "floor" } - round = { "round" } - -binary_prefix = _{ min | max | atan2 } - min = { "min" } - max = { "max" } - atan2 = { "atan2" } - -suffix = _{ factorial } - factorial = { "!" } - -term = _{ num | "(" ~ expr ~ ")" } - -suffix_expr = { term ~ suffix } -unary_expr = ${ unary_prefix ~ ws+ ~ outfix_expr } -binary_expr = ${ binary_prefix ~ ws+ ~ outfix_expr ~ ws+ ~ outfix_expr } - -tight = _{ (suffix_expr | term) ~ (tight_infix ~ tight)* } - -expr = { outfix_expr ~ (infix ~ outfix_expr)* } - -outfix_expr = _{ - tight | - binary_expr | - unary_expr -} - -calc = _{ SOI ~ expr ~ EOI } - -ws = _{ " " | "\t" | "\n" } -WHITESPACE = _{ ws } -- cgit v1.3.1