The following is a valid µOCCAM program that performs I/O. Tests to see if VAL declarations for a range of expressions work. Evaluation of these expressions can all be implemented in such a way that constant_expression() recognises the expression as being constant and can give a value for it at compile time.
Program file:
/public/cs3/web/ipptests/val_test.io
VAL t IS 10: VAL s IS 6: VAL ts IS t * s: VAL t.mod.s IS t \ s: VAL neg.t IS -t: VAL not.t IS NOT t: VAL s.eq.t IS t = t: VAL mix IS (ts * ((t.mod.s + s) \ t)) / 4: SEQ stdout ! t stdout ! neg.t stdout ! s stdout ! ts stdout ! t.mod.s stdout ! mix
When provided with this input:
/public/cs3/web/ipptests/val_test.in
it should generate the following output:
/public/cs3/web/ipptests/val_test.out
==> 10 ==> -10 ==> 6 ==> 60 ==> 4 ==> 0