about summary refs log tree commit diff stats
path: root/067stream.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-07-22 19:56:18 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-07-22 19:56:18 -0700
commit9acf5c0fc91d7e348c794c8b8181d4e56f393925 (patch)
tree97bf8a15ec6c4803d661e13c868e8f288fc977aa /067stream.mu
parent1cb09d70d068304f5330330c5708b806ab693589 (diff)
downloadmu-9acf5c0fc91d7e348c794c8b8181d4e56f393925.tar.gz
3129
Degenerate 'parser' that handles just atoms of one character.
Diffstat (limited to '067stream.mu')
-rw-r--r--067stream.mu10
1 files changed, 10 insertions, 0 deletions
diff --git a/067stream.mu b/067stream.mu
index db7c189a..e55d5986 100644
--- a/067stream.mu
+++ b/067stream.mu
@@ -18,6 +18,16 @@ def rewind-stream in:address:stream -> in:address:stream [
   *in <- put *in, index:offset, 0
 ]
 
+def read in:address:stream -> result:character, in:address:stream [
+  local-scope
+  load-ingredients
+  idx:number <- get *in, index:offset
+  s:address:array:character <- get *in, data:offset
+  result <- index *s, idx
+  idx <- add idx, 1
+  *in <- put *in, index:offset, idx
+]
+
 def read-line in:address:stream -> result:address:array:character, in:address:stream [
   local-scope
   load-ingredients