The 6.001 Meta-Circular Evaluator The Core Evaluator ((variable? exp)(lookup-variable-value exp env)) tion exp)) signment exp en ((definition? exp)(eval-definition exp env)) ((if? exp)(eval-if exp env)) ((lambda? exp) (make-procedure (lambda-parameters exp)(lambda-body exp) env)) ((begin? exp)(eval-sequence (begin-actions exp)env) ((cond? exp)(m-eval (cond->if exp) env)) ((application? exp) (m-apply (m-eval (operator exp)env) (else (error "Unknown expression type -- EVAL "exp)))) (define (m-apply procedure arguments cond ((primitive-procedure? procedure) (apply-primitive-procedure procedure arguments)) ((compound-procedure? procedure) (procedure-body procedure) (extend-environment (procedure-parameters procedure) arguments (procedure-environment procedure)))) lse (error "Unknown procedure type --APPly"procedure)))) (define (list-of-values exps env) 8? exps)'() (else(cons (m-eval (first-operand exps)en (list-of-values (rest-operands exps) env))))) (define (eval-if exp env) (if (m-eval (if-predicate exp) env) (m-eval (if-consequent exp) env) (m-eval (if-alternative exp)env))) (define (eval-sequence exps env) (cond ((last-exp? exps)(m-eval (first-exp exps) env)) (else (m-eval (first-exp exps) env) (eval-sequence (rest-exps exps)env)))) (define (eval-assignment exp env) (set-variable-value! (assignment-variable exp) (m-eval (define (eval-definition exp env) (define-variable! (definition-variable exp) (m-eval (definition-value exp) env)The 6.001 Meta-Circular Evaluator The Core Evaluator (define (m-eval exp env) (cond ((self-evaluating? exp) exp) ((variable? exp) (lookup-variable-value exp env)) ((quoted? exp) (text-of-quotation exp)) ((assignment? exp) (eval-assignment exp env)) ((definition? exp) (eval-definition exp env)) ((if? exp) (eval-if exp env)) ((lambda? exp) (make-procedure (lambda-parameters exp) (lambda-body exp) env)) ((begin? exp) (eval-sequence (begin-actions exp) env)) ((cond? exp) (m-eval (cond->if exp) env)) ((application? exp) (m-apply (m-eval (operator exp) env) (list-of-values (operands exp) env))) (else (error "Unknown expression type -- EVAL" exp)))) (define (m-apply procedure arguments) (cond ((primitive-procedure? procedure) (apply-primitive-procedure procedure arguments)) ((compound-procedure? procedure) (eval-sequence (procedure-body procedure) (extend-environment (procedure-parameters procedure) arguments (procedure-environment procedure)))) (else (error "Unknown procedure type -- APPLY" procedure)))) (define (list-of-values exps env) (cond ((no-operands? exps) ’()) (else (cons (m-eval (first-operand exps) env) (list-of-values (rest-operands exps) env))))) (define (eval-if exp env) (if (m-eval (if-predicate exp) env) (m-eval (if-consequent exp) env) (m-eval (if-alternative exp) env))) (define (eval-sequence exps env) (cond ((last-exp? exps) (m-eval (first-exp exps) env)) (else (m-eval (first-exp exps) env) (eval-sequence (rest-exps exps) env)))) (define (eval-assignment exp env) (set-variable-value! (assignment-variable exp) (m-eval (assignment-value exp) env) env)) (define (eval-definition exp env) (define-variable! (definition-variable exp) (m-eval (definition-value exp) env) env)) 1