aboutsummaryrefslogtreecommitdiff
path: root/forth/step1_read_print.fs
blob: 02783bf351d623cc1de843af7e1f1f3a7cbe4a6e (plain)
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
require reader.fs
require printer.fs

: read read-str ;
: eval ;
: print pr-str ;

: rep
    read
    eval
    print ;

create buff 128 allot

: read-lines
    begin
      ." user> "
      buff 128 stdin read-line throw
    while
      buff swap
      ['] rep
      \ execute safe-type
      catch 0= if safe-type endif
      cr
    repeat ;

\ s" 1   (42 1 (2 12 8)) 35" swap 1+ swap .s read-str .s
\ s" 7" .s read-str .s
\ cr
\ pr-str safe-type cr
\ new-str s" hello" str-append char ! str-append-char safe-type
\ s\" he\nllo" MalString. pr-str safe-type cr

read-lines
cr
bye