User Tools

Site Tools


LiP final project 2010

Exercise 1 (15 points)

Consider an imperative language featuring:

  • blocks of declarations: constants, variables, arrays, functions (with one parameter)
  • integer and boolean expressions, with static typechecking to ensure that booleans and integers are not unproperly mixed
  • command sequence, if-then-else, while loops
  • call-by-value function invocation
  • dynamic controls to prevent array index out of bounds

Specify the types for expressions, declarations, commands and programs, and write an interpreter of the language.

For instance, a legitimate program (in concrete syntax) could be:

program {
  const int n=10;
  int x;
  int function fie(int x) {
    return x+1
  x := 1;
  while x<n do x := fie(x)

The following program should not be executed, because it uses an integer expression (instead of a boolean) to guard the while loop:

program {
  const int n=10;
  int x;
  x := n;
  while x do x := x-1

The following program should result in a runtime error, when the index i exits from the bounds of the array a:

program {
  const int n=10;
  int array a[n];
  int i;
  i := 0;
  while i<=n do {
    a[i] := i;
    i := i+1

Exercise 2 (10 points)

Write an interpreter of the assembly language specified here

Exercise 3 (15 points)

Write a compiler for the imperative language specified above, following the directions given here.

Submission policy

  • If you want to change your group, you must declare the new group by 31.1.2011.
    • The policy for group collaboration is described here
    • To change your a group, send an email to the teaching assistant.
    • The subject of the email must begin with [LIP] (automatic filtering will be used).
    • The body of the email must contain the names of the components (min 1, max 3)
    • You must declare your group even though you want to work alone (otherwise I cannot assign you an ID).
    • The groups and their IDs will be displayed here.
  • You must submit your project by 28.2.2011, 23.59 GMT +1.
    • To submit a project, send it by email to the teaching assistant.
    • The subject of the email must be [LIP], where XX is the ID of your group.
    • The solutions to the exercises must be pasted into the body of the email (plain text).
    • The email will contain no attachments.
    • You can submit a project only once.
  • You must adhere the LiP honesty policy.
  • You are not required to exploit the solution of an exercise to solve the subsequent ones: you can start each exercise from scratch.

lip-final-2010.txt · Last modified: 2015/10/08 15:20 (external edit)