PLT11 course -- assignment 1

(C) Ralf Lämmel, Andrei Varanovich, University of Koblenz Landau



Extend the small-step semantics, in its Prolog incarnation, by the following language constructs:

  • A for-loop:
    • There is loop variable (see "i" below).
    • The loop variable is initialized (see "1" below).
    • The loop terminates when the loop variable is greater than a limit (see "5" below).
    • Example: for i=1 to 5 do y = y * i od
  • A throw/try/catch mechanism:
    • Look at the simple abort mechanism from the SOS lecture for inspiration.
    • The mechanism should be a brutally simplified variation on ditto mechanism in Java.
    • Subconstructs:
      • throw x: throws an exception named "x".
      • try S catch x : S': tries S and executes S' if S throws x.
      • If instead S throws y <> x, then S' is not executed.
      • However, the try/catch block could be inside another try/catch block.

Obviously, you can start off with the Prolog code from the lecture.

General comments and hints:

  • The second part is non-trivial assignment; ask questions in the newsgroup to get help.
  • The first part is trivial; this is about "syntactic sugar".
  • Don't care about the concrete syntax used above for illustration.
  • There is a concise solution for the second part (just a few rules).
  • Verbose solutions are also Ok.
  • The second part should be much harder with big-step style, but please try, if you like.

Provide test cases with your extended interpreter.