From 076f837af60371aa3b7b11ebb2a9613cd93c8bb0 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Mon, 15 Jun 2020 23:26:13 -0700 Subject: 6541 - arith: start on bracket support --- apps/arith.mu | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apps') 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 -- cgit 1.4.1-2-gfad0