about summary refs log tree commit diff stats
path: root/baremetal/shell/sandbox.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-02-21 21:36:33 -0800
committerKartik K. Agaram <vc@akkartik.com>2021-02-21 21:36:33 -0800
commit668bec391ccd7fa1f79eef554240fe4251d4dc76 (patch)
treeeb5177ab20a10bdb8e903cb9e955ea35eb952861 /baremetal/shell/sandbox.mu
parent70def3209b7fb0e07c14edf514f04287c11169b6 (diff)
downloadmu-668bec391ccd7fa1f79eef554240fe4251d4dc76.tar.gz
7775
Diffstat (limited to 'baremetal/shell/sandbox.mu')
-rw-r--r--baremetal/shell/sandbox.mu18
1 files changed, 18 insertions, 0 deletions
diff --git a/baremetal/shell/sandbox.mu b/baremetal/shell/sandbox.mu
index f6d0c6cb..dd153a9f 100644
--- a/baremetal/shell/sandbox.mu
+++ b/baremetal/shell/sandbox.mu
@@ -90,3 +90,21 @@ fn edit-sandbox _self: (addr sandbox), key: byte {
   }
   add-grapheme-to-sandbox self, g
 }
+
+fn run in: (addr gap-buffer), out: (addr stream byte) {
+  # tokenize
+  # insert parens
+  # transform infix
+  # token tree
+  # syntax tree
+  rewind-gap-buffer in
+  clear-stream out
+  {
+    var done?/eax: boolean <- gap-buffer-scan-done? in
+    compare done?, 0/false
+    break-if-!=
+    var g/eax: grapheme <- read-from-gap-buffer in
+    write-grapheme out, g
+    loop
+  }
+}