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 20:28:51 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-07-22 20:28:51 -0700
commit050a93aca8840087b702dbd5b39565f56da00569 (patch)
tree1f4aa7d346f3af1ae7cc8df0b705ce859875d99c /067stream.mu
parentae6d8f0335360886d79e6b0581e90bd0e0b2397d (diff)
downloadmu-050a93aca8840087b702dbd5b39565f56da00569.tar.gz
3131
Reorganize parser to make room for parsing pairs. But first test for
pairs is still failing.
Diffstat (limited to '067stream.mu')
-rw-r--r--067stream.mu14
1 files changed, 14 insertions, 0 deletions
diff --git a/067stream.mu b/067stream.mu
index e55d5986..585878bc 100644
--- a/067stream.mu
+++ b/067stream.mu
@@ -23,11 +23,25 @@ def read in:address:stream -> result:character, in:address:stream [
   load-ingredients
   idx:number <- get *in, index:offset
   s:address:array:character <- get *in, data:offset
+  len:number <- length *s
+  at-end?:boolean <- greater-or-equal idx len
+  reply-if at-end?, 0/nul, in
   result <- index *s, idx
   idx <- add idx, 1
   *in <- put *in, index:offset, idx
 ]
 
+def peek in:address:stream -> result:character [
+  local-scope
+  load-ingredients
+  idx:number <- get *in, index:offset
+  s:address:array:character <- get *in, data:offset
+  len:number <- length *s
+  at-end?:boolean <- greater-or-equal idx len
+  reply-if at-end?, 0/nul
+  result <- index *s, idx
+]
+
 def read-line in:address:stream -> result:address:array:character, in:address:stream [
   local-scope
   load-ingredients