Refactoring exprs

This commit is contained in:
2023-07-08 22:31:53 -05:00
parent bc3a1ad88f
commit f682a234c7
4 changed files with 111 additions and 129 deletions
+8 -4
View File
@@ -20,10 +20,14 @@ assignment = { lvalue ~ "=" ~ rvalue }
lvalue = { arrayref | name }
rvalue = { expr | string }
sign = { "+" | "-" }
term_op = { "*" | "/" | "%" }
expr = { term ~ (sign ~ term)* }
term = { val ~ (term_op ~ val)* }
add = { "+" }
sub = { "-" }
mul = { "*" }
div = { "/" }
modulus = { "%" }
operator = _{ add | sub | mul | div | modulus }
expr = { val ~ (operator ~ val)* }
val = { // These are what get evaluated and left on the stack:
number | // Literal numbers
("(" ~ expr ~ ")") | // Nested parenthesized exprs