CS3 page · Project overview · Phase 1 · Phase 2 · Samples · Testing


CS3 Individual Programming Project

Sample Programs

This page presents a selection of test µOCCAM files submitted by students for Phase 2 of the project. You can add your own examples -- please do.

You may want to test your own µOCCAM compiler on these examples with the standard test script. If so, choose the examples you want and copy them to an ipptests directory in your own filespace. Take heed of the warning below and check to see that you agree with the accept/reject classification of any code you use.

There are three types of sample program.

WARNING! These tests programs are submitted by students on the course and classified as valid or invalid by their authors alone. The course lecturer can provide no reassurance that they actually are valid or invalid as stated.

If you think that a program is misclassified, post a message to the newsgroup with a copy to the author. If you are an author, and someone correctly spots a mistake, please try to correct it as soon as possible.

The sample programs submitted for Phase 1 are still available online.

Simple sequence Ian Stark Valid Simple sequence
Bad sequence Ian Stark Invalid Missing SEQ, PAR or ALT
Single declaration Ian Stark Valid Declares a variable
Faulty continuation Ian Stark Invalid Bad choice of line break
Final comment Ian Stark Valid Comment right at the end of program
One-stage pipeline Ian Stark I/O Copies input values to standard output
Scope Restoration Godfrey Achola Valid Tests for The Restoration of Scope After a Nesting...
Bad Declaration Pete Andrews Invalid Missing variable declaration
Scope Problem Stephen Barnes Invalid Tests proper scoping of variables
Undeclared variable Andrew Bates Invalid Tests whether the compiler complains if a variable is used without being declared
Procedure arguments Andrew Bates Invalid Makes sure that compiler tests for the correct number of arguments when calling procedures
My Birthday Damien Bird I/O Outputs my birthday
Max Euan Brodie IO Outputs the maximum value from three inputs
Factorials Chris Brown I/O A program that calculates factorials
Non constant in VAL James Brown Invalid A VAL declartion which has a non constant expression has been used
Non constant count in ALT James Brown Invalid The count in a replicated alternation must be constant.
Constant count in ALT James Brown Valid This is the counterpart to "Non constant count".
Indent Cont. Check Theo Burt Valid Checks for valid indenting in continuation lines
Invalid Comments Theo Burt Invalid Checks for Invalid comments in Continuation lines
procedure-test Barry Cairns Valid Tests procedures and some variable scope
Bad array assignment Michael Cameron Invalid Trying to assign to an array without specifying an element.
Monadic Dyadic Andrew Campbell Valid Tests the Negative sign as a monadic and dyadic operator
PAR variable access test Gary Campbell I/O Tests parent variable accesses from a spawned process
Parallel pipe Gary Campbell I/O Tests channels, scoping and parallel processes
Replicated ALT test Gary Campbell I/O Tests, er, replicated ALTs
Replicated PAR Gary Campbell I/O Tests replicated PARs
VAL declarations Gary Campbell I/O Checks to see if your VAL declarations and accesses work.
PAR test David Alex Carter Valid Three assignments in parallel folowed by an output of the results
Average Prog Kevin Cheng I/O Lil prog cal av
eof Allan Clark Valid Checks end of file indentation
Constant Allan Clark I/O Checks constant value declaration & use
Undeclared Variable Rupert Connell Invalid This program contains an undeclared variable, y.
Simple Test Michael Coughlin Valid Simple test involving assignments and a while statement
INTs and CHANs Ewan Crowe Invalid Tests to make sure INTs can't be used as CHANs
Whiles and Assigns Laura Cull Valid Tests while loops and assign statements
Indents and Comments Laura Cull Invalid Tests indentation and comments
Multiplying Input Laura Cull I/O Tests I/O and use of the variables they are assigned to
Conditional Test Alan Deans Valid Tests variable assignments and variable use in an IF conditional
Small Procedure Double Alan Deans Invalid Tests a small, invalid procedure named double
Variable Tester Alan Deans Invalid Tests variable assignments using three simple variables
Simple Parallelism Test Tom Dearden Invalid Tests variable access in PAR
Out of Scope Simon Delicato Invalid Tests whether parser rejects an assignment to a variable that is out of scope.
While Loops and Output Iain Findlay Valid This program tests the while loops capability of handling assignments and outputting them.
Procedure def Paul Flanagan Valid Simple procedure definition
Swap with 2 variables used Ross Fleming Valid Swaps two variables without using an extra variable
Simple Summation David Forbes I/O Takes two integers and outputs all integers between them and their sum
Simple indentation test Brian Ford Valid Simple identation test
Seq Swap Ben Freeman Valid Tests Variable declaration
Declare & Assign David Gilley Valid A Basic Declaration and Assignment
Scopetest Duncan Grant Invalid Variable used outside scope
WhileEof Alasdair Gray Valid Checks some defns, and a simple while loop, EOF at end of comment
undeclaredvariable Marc Guerin Invalid Tests to make sure undeclared variables are rejected
Testing while Elizabeth Hamilton Stewart Valid Tests while, comments, tabs, and variable declarations
wrong scope... Keith Hargreaves Invalid out of scope variable use
Out Of Scope John Hawkins Invalid Tests that a variable comes out of scope when it's supposed to.
Invalid Procedure call Gareth Hewitt Invalid Tests if your compiler rejects a call to a procedure that does not exist
Two variables Phil Hooker Valid Tests variable declaration, assignment and comments
Replicator Redeclaration Rory Hunter Invalid Test to check that a replicated variable isn't already declared.
Times Tables Dave Keen I/O A (longwinded) program to tell your times tables using arrays
invalid_swap Spyros Lambrinidis Invalid short swap program
varsncons Michael Langford Valid Variables and Continuation Lines
scopeprobs Michael Langford Invalid Variable out of scope
Yet Another Scope Test Chris Lisle I/O A test for variable scope, which outputs a set of variables at a couple of places in the program, if you have variable scope working then the values should follow the example output file. I hope.
Multiple Declarations Derek Long Valid Test multiple declarations of integers.
not declared variable Samuel Mackwell Invalid variable not declared
Various Tom Mason Valid Various grammar check
Broken While Chris McGowan Invalid Broken While condition.
Assignment Ian McWilliams Valid Tests assignments to variables.
While loops Ian McWilliams I/0 Simple test of while loops and output.
Pointless While Loop Robin Metcalfe I/O A simple while loop which eventually terminates
In Scope Gregor Miller Valid Checks to see that the compiler accepts a variable which is in scope
Array Declaration Gregor Miller Valid Tests integer array declarations
Invalid Array Declaration Gregor Miller Invalid Tests integer array declarations without a constant expression
Bad Count Dan Mossop Invalid A SEQ replicator with an invalid count
Mismatched Bracket David Muir Invalid Simple test for mismatched brackets.
Not Operators David Muir Valid Test the two types of not (negation) operators.
Reads a number from stdinput an squares and displays it Cahit Oz I/O Finds the squre of a number
Missing Declaration Thomas Reisinger Invalid This program uses an undeclared variable.
Not enough arguments Malcolm Rigg Invalid A simple function call that does not have enough arguments
Too many arguments Malcolm Rigg Invalid A simple function call that has too many arguments
Bad Spelling Struan Robertson Invalid Tests whether you've mixed up your spelling
Multiply Me! Iain Sampson Valid Multiples 2 integers together and stores in other variable
bad_decleration.reject Andrew Scott Invalid A variable is declaired, just not the right one.
Naive Factorial Program William Scott I/O Tests that a variable is repeatedly decremented
Another Simple PROC call Mark Seddon Valid Simple in extremis
Bad Continuation Line Stuart Shannon Invalid there is a comment within a continuation line making it invalid
ZZZ wrongtype test Neil Smith Invalid This test assigns an integer to a CHAN which is illegal
All Declared Laura Snell Valid Variables declared then used in expressions
Assignment Test Jackson Tong Invalid Tests a no. of invalidities
Declarations and Types Andreas Tsiamis Invalid tests whether some declarations and types are correct
A_few_things Ian Usher Invalid No semantics, just syntax, tested quite harshly
Simple Expression David Walters Valid Tests simple parallel assignment, and addition
Procedure def Yu Wang Invalid Undefined Variable
Procedure def Yu Wang Valid Check the SEQ programme
Testing Declarations Ian J. White Invalid Re-declares a variable with another type
Selection James Whiteside Valid Simple case construction, compares variable with letters.
Invalid Array Declaration David Wilkie Invalid Checks to see if your program allows an array to be declared with a variable expression
Incorrect Channels Graeme Miller Invalid Tests if a declared integer can be used as a channel
Simple Addition Graeme Miller I/O Tests if two inputed integers are correctly added together