comparison interp.rhope @ 174:0c7c5671fcd3

Start work on interpreter
author Mike Pavone <pavone@retrodev.com>
date Thu, 19 May 2011 23:30:07 -0700
parents
children
comparison
equal deleted inserted replaced
173:e769b2e0facc 174:0c7c5671fcd3
1
2 Import interplookup.rhope
3
4 _Get Line[string:out]
5 {
6 char <- Get Char[]
7 If[[char]=["\n"]]
8 {
9 out <- string
10 }{
11 out <- _Get Line[[string]Append[char]]
12 }
13 }
14
15 Get Line[:out]
16 {
17 out <- _Get Line[""]
18 }
19
20 Do Set Input[worker,val,num:out]
21 {
22 out <- [worker]Set Input[num, val]
23 }
24
25 Interp Loop[lookup:out]
26 {
27 [Get Line[]]Split[" "]
28 {
29 fname <- [~]Index[0]
30 args <- Map[Tail[~, 1], Int32[?]]
31 }
32
33 [lookup]Index[fname]
34 { worker <- Fold[Do Set Input[?], ~, args] }
35 { continue <- Print[["Could not find "]Append[fname]] }
36
37 continue <- Print[worker[]]
38
39 Val[continue]
40 { out <- Interp Loop[lookup] }
41 }
42
43 Main[:out]
44 {
45 out <- Interp Loop[Func Lookup[]]
46 }