Implement till 5.29 and separate regular and lazy eceval
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
;(load "ch5-syntax.scm"); ;section 4.1.2 syntax procedures
|
||||
(load "misc/sicp-eceval-syntax.scm") ;section 4.1.2 syntax procedures
|
||||
(load "misc/sicp-leval.scm") ; for lazy evaluation in eceval
|
||||
|
||||
;;;SECTION 4.1.3
|
||||
;;; operations used by compiled code and eceval except as noted
|
||||
@@ -63,12 +64,15 @@
|
||||
(car vals))
|
||||
(else (scan (cdr vars) (cdr vals)))))
|
||||
(if (eq? env the-empty-environment)
|
||||
(error "Unbound variable" var)
|
||||
'unbound-variable-error
|
||||
(let ((frame (first-frame env)))
|
||||
(scan (frame-variables frame)
|
||||
(frame-values frame)))))
|
||||
(env-loop env))
|
||||
|
||||
(define (unbound-variable? var)
|
||||
(eq? var 'unbound-variable-error))
|
||||
|
||||
(define (set-variable-value! var val env)
|
||||
(define (env-loop env)
|
||||
(define (scan vars vals)
|
||||
@@ -230,3 +234,83 @@
|
||||
(define (compiled-procedure-entry c-proc) (cadr c-proc))
|
||||
(define (compiled-procedure-env c-proc) (caddr c-proc))
|
||||
|
||||
(define eceval-operations
|
||||
(list
|
||||
;;primitive Scheme operations
|
||||
(list 'display display)
|
||||
(list 'newline newline)
|
||||
(list 'read read)
|
||||
|
||||
;;operations in syntax.scm
|
||||
(list 'application? application?)
|
||||
(list 'assignment-value assignment-value)
|
||||
(list 'assignment-variable assignment-variable)
|
||||
(list 'assignment? assignment?)
|
||||
(list 'begin-actions begin-actions)
|
||||
(list 'begin? begin?)
|
||||
(list 'definition-value definition-value)
|
||||
(list 'definition-variable definition-variable)
|
||||
(list 'definition? definition?)
|
||||
(list 'first-exp first-exp)
|
||||
(list 'first-operand first-operand)
|
||||
(list 'if-alternative if-alternative)
|
||||
(list 'if-consequent if-consequent)
|
||||
(list 'if-predicate if-predicate)
|
||||
(list 'if? if?)
|
||||
(list 'lambda-body lambda-body)
|
||||
(list 'lambda-parameters lambda-parameters)
|
||||
(list 'lambda? lambda?)
|
||||
(list 'last-exp? last-exp?)
|
||||
(list 'no-operands? no-operands?)
|
||||
(list 'operands operands)
|
||||
(list 'operator operator)
|
||||
(list 'quoted? quoted?)
|
||||
(list 'rest-exps rest-exps)
|
||||
(list 'rest-operands rest-operands)
|
||||
(list 'self-evaluating? self-evaluating?)
|
||||
(list 'text-of-quotation text-of-quotation)
|
||||
(list 'variable? variable?)
|
||||
|
||||
;;operations in eceval-support.scm
|
||||
(list 'adjoin-arg adjoin-arg)
|
||||
(list 'announce-output announce-output)
|
||||
(list 'apply-primitive-procedure apply-primitive-procedure)
|
||||
(list 'compound-procedure? compound-procedure?)
|
||||
(list 'define-variable! define-variable!)
|
||||
(list 'empty-arglist empty-arglist)
|
||||
(list 'extend-environment extend-environment)
|
||||
(list 'get-global-environment get-global-environment)
|
||||
(list 'last-operand? last-operand?)
|
||||
(list 'lookup-variable-value lookup-variable-value)
|
||||
(list 'make-procedure make-procedure)
|
||||
(list 'no-more-exps? no-more-exps?) ;for non-tail-recursive machine
|
||||
(list 'primitive-procedure? primitive-procedure?)
|
||||
(list 'procedure-body procedure-body)
|
||||
(list 'procedure-environment procedure-environment)
|
||||
(list 'procedure-parameters procedure-parameters)
|
||||
(list 'prompt-for-input prompt-for-input)
|
||||
(list 'set-variable-value! set-variable-value!)
|
||||
(list 'true? true?)
|
||||
(list 'user-print user-print)
|
||||
|
||||
;;5.23
|
||||
(list 'cond->if cond->if)
|
||||
(list 'cond-actions cond-actions)
|
||||
(list 'cond-clauses cond-clauses)
|
||||
(list 'cond-else-clause? cond-else-clause?)
|
||||
(list 'cond-first-clause cond-first-clause)
|
||||
(list 'cond-predicate cond-predicate)
|
||||
(list 'cond? cond?)
|
||||
(list 'let->combination let->combination)
|
||||
(list 'let? let?)
|
||||
|
||||
;;5.25
|
||||
(list 'delay-it delay-it)
|
||||
(list 'thunk? thunk?)
|
||||
(list 'thunk-exp thunk-exp)
|
||||
(list 'thunk-env thunk-env)
|
||||
|
||||
;;5.30
|
||||
(list 'unbound-variable? unbound-variable?)
|
||||
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user