Modifications to the interpreter

Assignment Help Basic Computer Science
Reference no: EM13860814

SUMMARY OF ASSIGNMENT.

In this assignment you will make some modifications to the interpreter for L3. The interpreter has already been modified slightly for convenience. In particular, the annoying need for "dummy" variables to assign to, in order to return a value from a procedure, has been removed. Many of the commands have a "block" as a component, and where a block used to have a list of commands, it now allows both commands and expressions. This cleans up a bunch of examples.L3 has been updated with syntax for some new commands and expressions:

"for" loops, mutable pairs, and a "fluid let" construct. These will be further explained in the questions. Your job is to write evaluator clauses for these additions.

You should start by carefully reading *all* the supplied code *except* for the parser. The new L3 data type clauses have been indicated with a comment, but a few other parts have been changed a bit for your convenience in doing this assignment.

There are 3 equally-weighted questions. Each question describes the L3 addition you need to update the evaluator for. To make sure you've done everything, check that there are no more occurrences of "undefined" in this file. Test data can be found at the end of this file.

QUESTION 1. Standard "for" loops. Example:

r=1 n=5:
for i=1,n by 1 do r := *(i,r) end;
print(r)

computes n factorial for n=5. The "by" part say how much to increment i by each time through the loop. The "by" can be omitted if it's 1 as in this example. Note: i can be assigned to in the body of the loop, but any such value should be ignored at the start of each iteration.

QUESTION 2. "Fluid let." This is a command of the form

flet x = e

in b

where e is an expression and b is a block (bindings + commands). It is very different from the familiar "let". The variable x must *already* have a binding. The body b of the flet is evaluated in the same environment as the flet itself, i.e. a new reference is *not* created for x. Right at the start of evaluation of b, x's reference is updated to be the value of e. Right after the evaluation of b, x's reference is restored to the value it had at the start.

QUESTION 3. Mutable pairs (as in Lisp/Scheme). These are pairs that can have their components destructively modified. Pairs are created using "(,)", accessed using fst and snd, and destructively modified using setfst and setsnd. Example:

t = ( (0,1), (2,3) ):
print(t);
setfst(snd(t), 4);
print(t)

prints

((0, 1), (2, 3))
((0, 1), (4, 3))

The update for pairs to the type EVal indicates how such pairs should be implemented. Note that you will also need to update applyPrimitive for fst and snd. There is also a "null" constant added to L3 so that pairs can be used to represent lists (null is like nil or []).

Attachment:- assignment.rar

Reference no: EM13860814

Questions Cloud

Choices are consistent with nash equilibrium : Four political candidates are deciding whether or not to enter a race for an elected office where the decision depends on who else is throwing his or her hat into the ring. If we assume that their choices are consistent with Nash equilibrium, who wil..
What role does serialization have in rmi : What role does serialization have in RMI? Why would I want to implement Externalizable instead of Serializable? Will serialization save the superclass fields for me?
The principle of the invisible hand asserts : "The principle of the invisible hand asserts that self-interest behavior on the part of resource-owners leads inevitably to chaos" true or false, why?
What are the major markets and economic decision makers : What are the major markets and economic decision makers
Modifications to the interpreter : These are pairs that can have their components destructively modified. Pairs are created using "(,)", accessed using fst and snd, and destructively modified using setfst and setsnd.
Find all nash equilibria : On Friday night, Elton and his partner Rodney are deciding where to go for dinner. The choices are Indian, Korean, and Mexican. Elton most likes Indian food and most dislikes Mexican food, whereas Mexican is Rodney’s favorite and Indian is his least ..
Why does not serialization save value of static variables : 1) Why doesn't serialization save the value of static variables? 2) What are the advantages and disadvantags of serialization? 3) What things are required for a class that implements Serializable?
Describe the relationship of race-class and gender : Describe the relationship of race, class, and gender and its effect on health and mental care delivery in the United States. What steps could be taken to guarantee that all have the same access to the appropriate health care? Should funds be made ava..
Derive the payoff matrix and nash equilibria : Two companies are deciding at what point to enter a market. The market lasts for four periods and companies simultaneously decide whether to enter in period 1, 2, 3, or 4, or not enter at all. Thus, the strategy set of a company is {1,2,3,4,do not en..

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Can gained competitive advantages be sustained

What are some internal (e.g. organisational, individual, and management factors) and external factors (e.g. market, industry, social, economic, technological and political/policy factors) influencing the success or failure of organisations' attemp..

  Explain what can-t be measured can-t be effectively managed

According to the following quote "what can't be measured can't be effectively managed." The question is can everything that is important in network security be measured using metrics or any other process? Why or Why not?

  What are two main functions of user accounts in a network

1. What are the two main functions of user accounts in a network? As a network administrator, how would you establish user rights and permissions to minimize maintenance efforts? How would you assign work groups? what are some issues with user..

  Do a lot more than calculations and reporting

Project managers do a lot more than calculations and reporting; they must keep the team on track, ensure ethical decisions are made, deal with conflict, and, depending on the type of organization, they may perform employee evaluations, issue bonuses,..

  Identify the troublesome computer''s ip address and host

What commands would you use to identify the troublesome computer's ip address and host name?

  Define transferring data from any core to any other core

Explain why loose timings on RAM memory might be useful in a multicore environment. If you know how to do a timing diagram that could be useful but you can also explain the concept. Assume that transferring data from any core to any other core c..

  Determine the monthly payment for a loan

Write a program to determine the monthly payment for a loan where the annual interest rate, the amount of the loan, and the number of years are entered as input.

  Find levels resulting tree have if key compression is used

How many levels would resulting tree have if key compression is used and it decreases the average size of each key in the entry to 10 bytes?

  Discusses network design element

Write a 1-page summary that discusses network design elements such as Cloud and Virtualization that can be security risks and how they can be applied to your future IT career.

  Responsibility to maintain ethical standard in department

Do managers have a responsibility to maintain an ethical standard within a department? If so, how is the expected ethical standard established? How is it documented? How is compliance measured?

  Final project plan

Final Project Plan

  The processing of the reference scheme

Page faults occur during the processing of the reference scheme? The hit ratio is for each of the following policies in a pure demand paging system? What do you observe when you move from Scheme 1 to Scheme 2? Explain.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd