Assigned: Friday, February 26, 1999
Due: Monday, March 8, 1999
You need only do problem 1 (all parts) on the semantics of SIMPLE. Problem 2 will serve as extra credit.
In defining the semantics of SIMPLE, we decided on types for a number of the semantic functions and also began defining many of those functions. In this problem, you will consider how to develop semantic functions for some of the remainder of the language.
Here are the types of the semantic functions.
meaningProg : Prog -> Input -> Output meaningSL : SL -> Cont -> Env -> Input -> Output meaningStat : Stat -> Cont -> Env -> Input -> Output meaningExp : Exp -> Env -> N meaningNum : Num -> N
meaningNum is built-in).
Here are the corresponding semantic domains.
Input = N* (lists of natural numbers) Output = N* (lists of natural numbers) Env = Ide -> N (functions from symbols to natural numbers) Cont = Env -> Input -> Output
You may also wish to refer to the class outline that gives an overview of the SIMPLE semantics.
SIMPLE has two kinds of conditionals.
Stat => if E then L1 else L2 fi Stat => if E then L fi
Write equations that define the semantics of these two statements.
Suppose we decide to extend SIMPLE with a simple case statement of the following form:
case (E) of Num1: S1 ; Num2: S2 ; ... Numn: Sn
Show how we'd extend the abstract syntax to incorporate this new kind of statement.
Write equations that define the semantics of the new case statement.
meaningExp, the semantic function for SIMPLE expressions.
Recall that the abstract syntax for expressions is as follows.
Exp => E1 + E2 | E1 - E2 | E1 * E2 | E1 / E2 | I | N | (E) where E is an element of Exp I is an element of Ide N is an element of Num
In some languages (such as C and its descendants) it is possible to use an assignment statement as an expression, as in
while (x := x+1) do ... od
What changes would we have to make to the SIMPLE semantics to incorporate assignment expressions? Note that you need not describe changes to the concrete syntax, but just to the abstract syntax, semantic domains, and semantic functions.
A close reading of the Scheme semantics suggests that there's no formal
description of what happens with
let. Why not?
Describe, in English, what's happening in the definition of cwcc in the left column of p. 43 of the Scheme semantics.
Disclaimer Often, these pages were created ``on the fly'' with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
This page may be found at http://www.math.grin.edu/~rebelsky/Courses/CS302/99S/Assignments/assign.03.html
Source text last modified Wed Mar 3 09:19:50 1999.
This page generated on Wed Mar 3 09:21:49 1999 by SiteWeaver. Validate this page's HTML.
Contact our webmaster at firstname.lastname@example.org