Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For each feature in this and subsequent interpreter assignments, the syntax and semantics should be the same as Scheme's unless the assignment documents specify otherwise.
For each feature in this and subsequent interpreter assignments, the syntax and semantics should be the same as Scheme's unless the assignment documents specify otherwise.
Add the Boolean constants #t and #f to the interpreted language, along with quoted data, such as lists and vectors. Also add string literals such as "abcd". You do not need to add any stringmanipulation procedures yet, but it will be nice to at least be able to use strings for output messages. Add vector literals as with strings, Scheme will do the "real" parsing; your parseexp simply needs to call vector? to see if an expression is a vector
Add if expressions to the interpreted language. Most of the code is in the textbook, but you will have to adapt it to recognize and use Boolean and other literal values in addition to the numeric values. In the book's interpreted language, the authors represent true and false by numbers. In Scheme and thus in your interpreter any nonfalse value should be treated as true. The number is a true value in Scheme and in your interpreted language but is the false value in the textbook's language
Note: Classic ie not Racket if has two forms, with and without an "else" expression. Your interpreter must eventually support both, but for this assignment only the "with" version ietwoarmed if is required for this assignment.
Add several primitive procedures including add sub zero?, not, and and the other numeric comparison operators and also cons, car, cdr list, null?, assq, eq equal?, atom?, length, listvector, list?, pair?, procedure?, vectorlist, vector, makevector, vectorref, vector?, number?, symbol?, vectorset!, display newline to your interpreter. Add the cr and cr procedures where each stands for an a or d Note: You may use builtin Scheme procedures in your implementation of most of the primitive procedures, as I do in the starting code that is provided for you. At least one of the above procedures has a much simpler implementation, and at least one cannot be implemented by using the corresponding Scheme procedure. You may want to enhance the primproc mechanism from the provided code so that a primproc knows how many arguments it is allowed to take, and it reports an error if the interpreted code attempts to apply it with an incorrect number of arguments. Otherwise, this incorrect code will default to a Scheme error message such as "Exception in cadr", which will make no sense to the author of the interpreted code. However, the official test cases should only test code that has no errors.
Add let not "namedlet" yet expressions to the interpreted language, with the standard Scheme syntax: let var exp body body The in this description is basically the same thing as the Kleene like the notation we used in definesyntax; it means "zero or more occurrences of the previous item". Every let expression must have at least one body. The parser work should have been done in a previous assignment It is okay for you to interpret namedlet as well, but this is not required until a later assignment, and will be easier after we discuss letrec implementation in class. Add code that is similar to that in EoPL allowing let expressions to be directly interpreted. Recall that after the extended environment is created, the bodies are executed in order, and the value of the last body is returned. We suggest that you test this code and understand it thoroughly before you go on to implement lambda.
Add lambda expressions of the form lambda var body body See the description of rep short for "readevalprint" below for a description of what to print if a closure or primitive procedure is part of the final value of an expression entered interactively in the interpreter. Section of EoPL may be helpful.
In later assignments, you'll add many syntactic and semantic forms, including define, let letrec, cond, and set!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started