Debian Codegraph @

other-libs/interp.ss

raw
1
2
3 (library interp
4 (export ee)
5 (import match r6rs)
6 (define (constant? x)
7 (or (number? x) (char? x) (string? x) (boolean? x)))
8 (define (ee x)
9 (define (ee x env)
10 (match x
11 (,c (guard (constant? c)) c)
12 (,x (guard (symbol? x))
13 (cond
14 ((assq x env) => cdr)
15 (else (error 'ee "unbound ~s" x))))
16 ((let ((,x ,v)) ,b)
17 (ee b (cons (cons x (ee v env)) env)))
18 ((+ ,(x) ,(y)) (+ x y))
19 (,others (error 'ee "invalid expr ~s" others))))
20 (ee x '())))
21