Back to table

Yet Another Scope Test

The following is a valid µOCCAM program that performs I/O. yascopes is yet another scope test that delcares a set of INT variables and messes about with them, outputting them to stdout at certain points, compare these printed values with the values you get for each scope by looking at the declarations in the file. Executing this file requires implementation of: variable declaration and scoping (not variable assignment at declaration however), channel output to stdout and variable assignment operations in code.

Program file: /public/cs3/web/ipptests/yascopes.io

INT var1 :
INT var2 :
SEQ
  var1 := 1
  var2 := 2
  INT var1 :
  INT var3 :
  SEQ
    var1 := var2
    var2 := 3
    var3 := var1
    stdout ! var1
    stdout ! var2
    stdout ! var3
  stdout ! var1
  stdout ! var2

When provided with this input: /public/cs3/web/ipptests/yascopes.in

[an error occurred while processing this directive]

it should generate the following output: /public/cs3/web/ipptests/yascopes.out

==> 2
==> 3
==> 2
==> 1
==> 2