-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patholdtest.soup
44 lines (39 loc) · 1.51 KB
/
oldtest.soup
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
37
38
39
40
41
42
43
44
(run (set! pexp (cons
(apply (lambda (var m)
(lambda (s c) (apply (lambda (s1 c1)
(if (starts-with s1 m)
(do
(log-parser "'parse-str" s1)
(apply c1 var (drop (length m) s1)))
(list)))
(eval s) (eval c))))
(gen-var "parse-str") "parse-str")
pexp)))
(run (set! parse-str (lambda (m s c) (apply (lambda (m1 s1 c1)
(if (starts-with s1 m1)
(apply c1 m1 (drop (length m1) s1))
(list)))
(eval m) (eval s) (eval c)))))
(run (set! pexp (cons
(apply
(lambda (var) (lambda (s c)
(parse-str "define-var" (eval s) (lambda (_ s1) (apply (lambda (c2 s2) (do
(log-parser "'define-var" s2)
(apply c2 var s2))) (eval c) (eval s1))))))
(gen-var "define-var"))
pexp)))
(run (set! define-var (lambda (name val) (apply (lambda (name1) (apply (lambda (var) (do
(set! pexp (cons
(lambda (s c)
(parse-str (eval name1) (eval s) (lambda (_ s1) (apply (lambda (c2 s2) (do
(log-parser (cat "'" name1) s2)
(apply c2 var s2))) (eval c) (eval s1)))))
pexp))
(apply set! var val))) (gen-var name1))) name))))
(run (define-var "prepend!" (lambda (l x)
(apply set! l (cons x (eval l))))))
(run (define-var "parse-while" (lambda (pred s c) (apply (lambda (l)
(if (empty-str (head l))
(list)
(apply (eval c) (head l) (head (tail l)))))
(span (eval pred) (eval s))))))