2
;; Tue Dec 23 14:49:11 2003 macros that expands a term with a list of
6
(defun expand-mylet*-2-l (binding term-l)
7
(declare (xargs :verify-guards nil
8
:measure (acl2-count term-l)))
10
(cons (expand-mylet*-2 binding (car term-l))
11
(expand-mylet*-2-l binding (cdr term-l)))))
13
(defun expand-mylet*-2 (binding term)
14
(declare (xargs :verify-guards nil
15
:measure (acl2-count term)))
16
(let ((key (car binding))
17
(value (cdr binding)))
25
(expand-mylet*-2-l binding (cdr term)))
29
; (expand-mylet*-2 '(x . (f (+ x y)))
32
(defun expand-mylet*-1 (binding alist)
33
(declare (xargs :verify-guards nil))
35
(cons (cons (caar alist)
36
(expand-mylet*-2 binding (cdar alist)))
37
(expand-mylet*-1 binding (cdr alist)))))
40
(defun expand-mylet* (bindings topTerm)
41
(declare (xargs :verify-guards nil
42
:measure (len bindings)))
45
(expand-mylet* (expand-mylet*-1 (car bindings) (cdr bindings))
46
(expand-mylet*-2 (car bindings) topTerm))))
48
;; this is a flaky substitution implementation.
49
;; Only used by myself. It is ok.
51
; (expand-mylet* '((x . (f x))
52
; (y . (f x (f (+ x y)))))
53
; '(G (f (+ x y) (y y x))))
55
(defun extract-bindings (assignments)
56
(declare (xargs :verify-guards nil))
57
(if (endp assignments) nil
58
(cons (cons (caar assignments) (cadar assignments))
59
(extract-bindings (cdr assignments)))))
62
; '((cid (current-thread s))
63
; (tt (thread-table s))
64
; (thread (thread-by-id cid tt))
65
; (callstack (thread-call-stack thread))
66
; (topframe (top callstack))))
69
(defmacro mylet* (assignments theTerm)
70
(let ((expanded (expand-mylet* (extract-bindings assignments) theTerm)))
b'\\ No newline at end of file'