about summary refs log tree commit diff stats
path: root/apps
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2020-06-15 23:26:13 -0700
committerKartik Agaram <vc@akkartik.com>2020-06-15 23:26:13 -0700
commit076f837af60371aa3b7b11ebb2a9613cd93c8bb0 (patch)
tree7cd509f19d38c6fc61e71ee1b29a8743d351c50f /apps
parent525c3986368b3609c964b2bcfc69c246477cd46c (diff)
downloadmu-076f837af60371aa3b7b11ebb2a9613cd93c8bb0.tar.gz
6541 - arith: start on bracket support
Diffstat (limited to 'apps')
-rw-r--r--apps/arith.mu10
1 files changed, 8 insertions, 2 deletions
diff --git a/apps/arith.mu b/apps/arith.mu
index 743480de..53566ed5 100644
--- a/apps/arith.mu
+++ b/apps/arith.mu
@@ -64,7 +64,7 @@ fn simplify -> result/eax: int, look/esi: byte {
 fn term _look: byte -> result/eax: int, look/esi: byte {
   look <- copy _look  # should be a no-op
   look <- skip-spaces look
-  result, look <- num look
+  result, look <- factor look
   $term:loop: {
     # operator
     var op/ecx: byte <- copy 0
@@ -84,7 +84,7 @@ fn term _look: byte -> result/eax: int, look/esi: byte {
     look <- skip-spaces look
     {
       var tmp/eax: int <- copy 0
-      tmp, look <- num look
+      tmp, look <- factor look
       second <- copy tmp
     }
     # perform op
@@ -106,6 +106,12 @@ fn term _look: byte -> result/eax: int, look/esi: byte {
   }
 }
 
+fn factor _look: byte -> result/eax: int, look/esi: byte {
+  look <- copy _look  # should be a no-op
+  look <- skip-spaces look
+  result, look <- num look
+}
+
 fn is-mul-or-div? c: byte -> result/eax: bool {
 $is-mul-or-div?:body: {
   compare c, 0x2a