Commit | Line | Data |
---|---|---|
59038a10 C |
1 | require reader.fs |
2 | require printer.fs | |
3 | ||
4 | : read read-str ; | |
5 | : eval ; | |
45c1894b C |
6 | |
7 | \ ." Type: " dup mal-type @ type-name safe-type cr | |
8 | pr-str ; | |
59038a10 | 9 | |
45c1894b | 10 | : rep ( str-addr str-len -- str-addr str-len ) |
59038a10 C |
11 | read |
12 | eval | |
13 | print ; | |
14 | ||
15 | create buff 128 allot | |
45c1894b | 16 | 77777777777 constant stack-leak-detect |
59038a10 C |
17 | |
18 | : read-lines | |
19 | begin | |
20 | ." user> " | |
45c1894b | 21 | stack-leak-detect |
59038a10 | 22 | buff 128 stdin read-line throw |
45c1894b C |
23 | while ( num-bytes-read ) |
24 | buff swap ( str-addr str-len ) | |
168fb5dc C |
25 | ['] rep |
26 | \ execute safe-type | |
45c1894b | 27 | catch ?dup 0= if safe-type else ." Caught error " . endif |
168fb5dc | 28 | cr |
45c1894b | 29 | stack-leak-detect <> if ." --stack leak--" cr endif |
59038a10 C |
30 | repeat ; |
31 | ||
59038a10 C |
32 | read-lines |
33 | cr | |
34 | bye |