User Tools

Site Tools


lip-final-2010

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

lip-final-2010 [2015/10/08 15:20] (current)
Line 1: Line 1:
 +====== 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:
 +<code c>
 +program {
 +  const int n=10;
 +  int x;
 +  int function fie(int x) {
 +    return x+1
 +  }
 +  x := 1;
 +  while x<n do x := fie(x)
 +}
 +</​code>​
 +
 +The following program should not be executed, because it 
 +uses an integer expression (instead of a boolean) to guard the while loop:
 +<code c>
 +program {
 +  const int n=10;
 +  int x;
 +  x := n;
 +  while x do x := x-1
 +}
 +</​code>​
 +
 +The following program should result in a runtime error, ​
 +when the index i exits from the bounds of the array a:
 +<code c>
 +program {
 +  const int n=10;
 +  int array a[n];
 +  int i;
 +  i := 0;
 +  while i<=n do {
 +    a[i] := i;
 +    i := i+1
 +  }
 +}
 +</​code>​
 +
 +\\
 +
 +===== Exercise 2 (10 points) =====
 +
 +Write an interpreter of the assembly language specified [[asm|here]]
 +
 +\\
 +
 +===== Exercise 3 (15 points) =====
 +
 +Write a compiler for the imperative language specified above, ​
 +following the directions given [[imp-compiler|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 [[honesty-policy|here]]
 +    * To change your a group, send an email to the [[bart@unica.it|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 [[https://​spreadsheets.google.com/​pub?​key=0AinitsakPo0wdHRJaWlMci1NQ2syR0UtY3k2c0VjX3c&​hl=en_GB&​single=true&​gid=6&​output=html|here]].
 +  * You must submit your project by **28.2.2011**,​ 23.59 GMT +1.
 +    * To submit a project, send it by email to the [[bart@unica.it|teaching assistant]]. ​
 +    * The subject of the email must be ''​[LIP] lip10b-gXX.ml'',​ 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|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)