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 selfevaluating? exp exp
variable explookupvariablevalue exp env
quoted exptextofquotation exp
assignment expevalassignment exp env
definition expevaldefinition exp env
if expevalif exp env
lambda exp
makeprocedure lambdaparameters exp
lambdabody exp
env
begin exp
evalsequence beginactions exp env
cond expmceval condif exp env
application exp
mcapply mceval operator exp env
listofvalues operands exp env
else
error "Unknown expression type EVAL" exp
define mcapply procedure arguments
cond primitiveprocedure? procedure
applyprimitiveprocedure procedure arguments
compoundprocedure? procedure
evalsequence
procedurebody procedure
extendenvironment
procedureparameters procedure
arguments
procedureenvironment procedure
else
error
"Unknown procedure type APPLY" procedure
define listofvalues exps env
if nooperands? exps
cons mceval firstoperand exps env
listofvalues restoperands exps env
define evalif exp env
if truemceval ifpredicate exp env
mceval ifconsequent exp env
mceval ifalternative exp env
define evalsequence exps env
cond lastexp? expsmceval firstexp exps env
else mceval firstexp exps env
evalsequence restexps exps env
define evalassignment exp env
setvariablevalue! assignmentvariable exp
mceval assignmentvalue exp env
env
ok
define evaldefinition exp env
definevariable! definitionvariable exp
mceval definitionvalue exp env
env
ok
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
