Question: The Metacircular Evaluator ( Racket Language ) Add the following primitives: + , * * , - , , , , = , , >

The Metacircular Evaluator (Racket Language)
Add the following primitives: +,**,-,,,,=,,>, and error to mceval. rkt .
Your error primitive should take no arguments and abort the interpreter with the message "Metacircular Interpreter Aborted" (without the quotes). You
should use Racket's error function to raise an exception like this:
(error "Metacircular Interpreter Aborted")
(define (mceval 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)(mceval (cond->if exp) env))
((application? exp)
(mcapply (mceval (operator exp) env)
(list-of-values (operands exp) env)))
(else
(error "Unknown expression type -- EVAL" exp))))
(define (mcapply 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)
(if (no-operands? exps)
'()
(cons (mceval (first-operand exps) env)
(list-of-values (rest-operands exps) env))))
(define (eval-if exp env)
(if (true?(mceval (if-predicate exp) env))
(mceval (if-consequent exp) env)
(mceval (if-alternative exp) env)))
(define (eval-sequence exps env)
(cond ((last-exp? exps)(mceval (first-exp exps) env))
(else (mceval (first-exp exps) env)
(eval-sequence (rest-exps exps) env))))
(define (eval-assignment exp env)
(set-variable-value! (assignment-variable exp)
(mceval (assignment-value exp) env)
env)
'ok)
(define (eval-definition exp env)
(define-variable! (definition-variable exp)
(mceval (definition-value exp) env)
env)
'ok)
 The Metacircular Evaluator (Racket Language) Add the following primitives: +,**,-,,,,=,,>, and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!