summary refs log tree commit diff stats
ModeNameSize
-rw-r--r--.gitignore23log stats plain blame
-rw-r--r--CHANGELOG8014log stats plain blame
-rw-r--r--COPYING35147log stats plain blame
-rw-r--r--Makefile2926log stats plain blame
-rw-r--r--README3483log stats plain blame
d---------doc309log stats plain
d---------examples591log stats plain
-rwxr-xr-xranger.py1416log stats plain blame
d---------ranger334log stats plain
d---------scripts67log stats plain
-rwxr-xr-xsetup.py1127log stats plain blame
K. Agaram <vc@akkartik.com> 2016-04-16 11:47:41 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2016-04-16 11:47:41 -0700 2842 - purge get-address until layer 80' href='/akkartik/mu/commit/077stream.mu?h=main&id=748b6865fc333d517905aba6cdd17d920a2ba53c'>748b6865 ^
8fb0e672 ^

b0bf5321 ^
77d5b5d6 ^
104854ca ^
748b6865 ^
b0bf5321 ^
748b6865 ^




8fb0e672 ^

b0bf5321 ^
77d5b5d6 ^
104854ca ^
5fdd8e96 ^
b0bf5321 ^
502d2ea5 ^
104854ca ^
8fb0e672 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
                                                                  

                  
                              

 
                                                                   
             

                           

                                         

 
                                                          
             
                  
                                 

 
                                                                                      
             
                  
                                     
                                                   




                                                 

 
                                                        
             
                  
                                     
                                                   
                         
                                     
 
# new type to help incrementally read texts (arrays of characters)
container stream [
  index:number
  data:address:array:character
]

def new-stream s:address:array:character -> result:address:stream [
  local-scope
  load-ingredients
  result <- new stream:type
  *result <- put *result, index:offset, 0
  *result <- put *result, data:offset, s
]

def rewind-stream in:address:stream -> in:address:stream [
  local-scope
  load-ingredients
  *in <- put *in, index:offset, 0
]

def read-line in:address:stream -> result:address:array:character, in:address:stream [
  local-scope
  load-ingredients
  idx:number <- get *in, index:offset
  s:address:array:character <- get *in, data:offset
  next-idx:number <- find-next s, 10/newline, idx
  result <- copy-range s, idx, next-idx
  idx <- add next-idx, 1  # skip newline
  # write back
  *in <- put *in, index:offset, idx
]

def end-of-stream? in:address:stream -> result:boolean [
  local-scope
  load-ingredients
  idx:number <- get *in, index:offset
  s:address:array:character <- get *in, data:offset
  len:number <- length *s
  result <- greater-or-equal idx, len
]