Docsity

CS615 HW1: Programming Language Design & Operational Semantics - Prof. Westley Weimer, Assignments of Programming Languages

Toggle sidebar
bg1
CS615 — Homework Assignment 1
Wes Weimer
Exercise 1: Bookkeeping. Indicate in a sentence or two how much time
you spent on this homework, how difficult you found it subjectively, and
what you found to be the hardest part. Any non-empty answer will receive
full credit.
Exercise 2: Language Design. Comment on some aspect from Hoare’s
Hints On Programming Language Design that relates to your programming
experience. Provide additional evidence in favor of one his points and against
one of his points. Do not exceed three paragraphs. Both your ideas and also
the clarity with which they are expressed (i.e., your English prose) matter.
I should be able to identify your main claim, the arguments you are brining
to bear, and your conclusion.
Exercise 3: Simple Operational Semantics. Consider the IMP lan-
guage discussed in class, with the Aexp sub-language extended with a di-
vision operator. Explain what changes must be made to the operational
semantics (big-step only). Write out formally any new rules of inference you
introduce.
Exercise 4: Language Feature Design. Consider the IMP language
with a new command construct “let x=ein c”. The informal semantics of
this construct is that the Aexp eis evaluated and then a new local variable
xis created with lexical scope cand initialized with the result of evaluating
e. Then the command cis evaluated. We also extend IMP with a new
command “print e” which evaluates the Aexp eand “displays the result”
in some un-modeled manner but is otherwise similar to skip.
We expect (the curly braces are syntactic sugar):
x:=1;
y:=2;
{ let x = 3 in
print x ;
print y ;
1
pf2

Partial preview of the text

Download CS615 HW1: Programming Language Design & Operational Semantics - Prof. Westley Weimer and more Assignments Programming Languages in PDF only on Docsity!

CS615 — Homework Assignment 1

Wes Weimer

Exercise 1: Bookkeeping. Indicate in a sentence or two how much time you spent on this homework, how difficult you found it subjectively, and what you found to be the hardest part. Any non-empty answer will receive full credit.

Exercise 2: Language Design. Comment on some aspect from Hoare’s Hints On Programming Language Design that relates to your programming experience. Provide additional evidence in favor of one his points and against one of his points. Do not exceed three paragraphs. Both your ideas and also the clarity with which they are expressed (i.e., your English prose) matter. I should be able to identify your main claim, the arguments you are brining to bear, and your conclusion.

Exercise 3: Simple Operational Semantics. Consider the IMP lan- guage discussed in class, with the Aexp sub-language extended with a di- vision operator. Explain what changes must be made to the operational semantics (big-step only). Write out formally any new rules of inference you introduce.

Exercise 4: Language Feature Design. Consider the IMP language with a new command construct “let x = e in c”. The informal semantics of this construct is that the Aexp e is evaluated and then a new local variable x is created with lexical scope c and initialized with the result of evaluating e. Then the command c is evaluated. We also extend IMP with a new command “print e” which evaluates the Aexp e and “displays the result” in some un-modeled manner but is otherwise similar to skip. We expect (the curly braces are syntactic sugar):

x := 1 ; y := 2 ; { let x = 3 in print x ; print y ;

x := 4 ; y := 5 } ; print x ; print y

to display “3 2 1 5”.

  • Extend the natural-style operational semantics judgment < c, σ >⇓ σ′ with one new rule for dealing with the let command. Pay careful attention to the scope of the newly declared variable and to changes to other variables.
  • Extend the set of redexes, contexts and reduction rules for the contextual- style operational semantics that we discussed in class to account for the let command.
  • Download the Homework 1 code pack from the course web page. Mod- ify hw1.ml so that it implements a complete interpreter for IMP (in- cluding let and print). Base your interpreter on IMP’s large-step operational semantics. The Makefile includes a “make test” target that you should use (at least) to test your work.
  • Modify the file example-imp-command so that it contains a “tricky” IMP command that can be parsed by our IMP test harness (e.g., “imp < example-imp-command” should not yield a parse error).
  • Rename hw1.ml to your uva email-hw1.ml and rename example-imp-command to your uva email-imp-command.ml and email them to me. The uva email I’m looking for is the five-character one (e.g., for me it is wrw6y not weimer). Do not modify any other files. Your submission’s grade will be based on how many of the submitted example-imp-commands it in- terprets correctly (in a manner just like the “make test” trials). If your submitted example-imp-command breaks the greatest number of interpreters (and more than 0!), you will receive extra credit. If there is a tie all tiers will receive the extra credit.