aboutsummaryrefslogtreecommitdiff
path: root/src/elixir_math_parser.yrl
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2025-11-09 13:23:05 +0100
committerWilliam Hergès <william@herges.fr>2025-11-09 13:23:05 +0100
commit3b0cc79dee76244da55d2326cc4244a384d85e44 (patch)
tree7a2819f658fe987f942633ad82997a75850e16ef /src/elixir_math_parser.yrl
parent8f9730d89e66ab1cbf08cbc0dea2a429d135e0da (diff)
feat(calc)): supports factorial
Diffstat (limited to 'src/elixir_math_parser.yrl')
-rw-r--r--src/elixir_math_parser.yrl4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/elixir_math_parser.yrl b/src/elixir_math_parser.yrl
index 86b36c8..0808683 100644
--- a/src/elixir_math_parser.yrl
+++ b/src/elixir_math_parser.yrl
@@ -10,7 +10,7 @@ Terminals
int
var
break
- '+' '-' '*' '/'
+ '+' '-' '*' '/' '!'
'='
'(' ')'
.
@@ -24,6 +24,7 @@ Left 300 '+'.
Left 300 '-'.
Left 400 '*'.
Left 400 '/'.
+Right 500 '!'.
Left 600 '('.
root -> statements : '$1'.
@@ -46,6 +47,7 @@ expr -> exprs '-' exprs : {sub_op, '$1', '$3'}.
expr -> exprs '*' exprs : {mul_op, '$1', '$3'}.
expr -> exprs '/' exprs : {div_op, '$1', '$3'}.
expr -> '(' exprs ')' : '$2'.
+expr -> expr '!' : {factor_op, '$1'}.
Erlang code.