forth: Add step 6, clean up comment parsing
[jackhill/mal.git] / forth / step1_read_print.fs
1 require reader.fs
2 require printer.fs
3
4 : read read-str ;
5 : eval ;
6 : print pr-str ;
7
8 : rep
9 read
10 eval
11 print ;
12
13 create buff 128 allot
14
15 : read-lines
16 begin
17 ." user> "
18 buff 128 stdin read-line throw
19 while
20 buff swap
21 ['] rep
22 \ execute safe-type
23 catch 0= if safe-type endif
24 cr
25 repeat ;
26
27 \ s" 1 (42 1 (2 12 8)) 35" swap 1+ swap .s read-str .s
28 \ s" 7" .s read-str .s
29 \ cr
30 \ pr-str safe-type cr
31 \ new-str s" hello" str-append char ! str-append-char safe-type
32 \ s\" he\nllo" MalString. pr-str safe-type cr
33
34 read-lines
35 cr
36 bye