about summary refs log tree commit diff stats
path: root/baremetal/shell/read.mu
diff options
context:
space:
mode:
Diffstat (limited to 'baremetal/shell/read.mu')
-rw-r--r--baremetal/shell/read.mu38
1 files changed, 21 insertions, 17 deletions
diff --git a/baremetal/shell/read.mu b/baremetal/shell/read.mu
index 0c959d78..9078f7c5 100644
--- a/baremetal/shell/read.mu
+++ b/baremetal/shell/read.mu
@@ -1,10 +1,28 @@
 # out is not allocated
 fn read-cell in: (addr gap-buffer), _out: (addr handle cell), trace: (addr trace) {
+  var tokens-storage: (stream cell 0x100)
+  var tokens/ecx: (addr stream cell) <- address tokens-storage
+  tokenize in, tokens, trace
+  # TODO: insert parens
+  # TODO: transform infix
+  # TODO: parse. For now we just convert first token into a symbol and return it.
+  var empty?/eax: boolean <- stream-empty? tokens
+  compare empty?, 0/false
+  {
+    break-if-!=
+    var out/eax: (addr handle cell) <- copy _out
+    allocate out
+    var out-addr/eax: (addr cell) <- lookup *out
+    read-from-stream tokens, out-addr
+    var type/ecx: (addr int) <- get out-addr, type
+    copy-to *type, 2/symbol
+  }
+}
+
+fn tokenize in: (addr gap-buffer), out: (addr stream cell), trace: (addr trace) {
   trace-text trace, "read", "tokenize"
   trace-lower trace
   rewind-gap-buffer in
-  var tokens-storage: (stream cell 0x100)
-  var tokens/ecx: (addr stream cell) <- address tokens-storage
   var token-storage: cell
   var token/edx: (addr cell) <- address token-storage
   # initialize token
@@ -22,23 +40,9 @@ fn read-cell in: (addr gap-buffer), _out: (addr handle cell), trace: (addr trace
       break-if-=
       return
     }
-    write-to-stream tokens, token
+    write-to-stream out, token
     loop
   }
-  # TODO: insert parens
-  # TODO: transform infix
-  # TODO: parse. For now we just convert first token into a symbol and return it.
-  var empty?/eax: boolean <- stream-empty? tokens
-  compare empty?, 0/false
-  {
-    break-if-!=
-    var out/eax: (addr handle cell) <- copy _out
-    allocate out
-    var out-addr/eax: (addr cell) <- lookup *out
-    read-from-stream tokens, out-addr
-    var type/ecx: (addr int) <- get out-addr, type
-    copy-to *type, 2/symbol
-  }
   trace-higher trace
 }
 
an class='oid'>71fd06f ^
95766d6 ^
1076f2b
95766d6 ^
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
             
             


                                    

                   




                               
                   
                                     
                                       
 
       
                                             


                                                       
 




                                                
                     
       
          
# dwm version
VERSION = 2.9

# Customize below to fit your system

# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man

X11INC = /usr/X11R6/include
X11LIB = /usr/X11R6/lib

# includes and libs
INCS = -I. -I/usr/include -I${X11INC}
LIBS = -L/usr/lib -lc -L${X11LIB} -lX11

# flags
CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
LDFLAGS = ${LIBS}
#CFLAGS = -g -Wall -O2 ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = -g ${LIBS}

# Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = ${LIBS}
#CFLAGS += -xtarget=ultra

# compiler and linker
CC = cc
LD = ${CC}