Back to table

Continuation lines

The following is Valid µOCCAM. The program checks that continuation lines are dealt with correctly: continuation lines occur only after certain tokens, which are tested for in this valid example.

Program file: /public/cs3/web/ipptests-phase-1/continuation.accept
-- Example to test continuation lines and loops
PROC add(INT x,
                INT y)
  x :=
      x +
          y      -- use continuation to split up the expression
:
INT p = 1:
INT input:
CHAN keyboard:
SEQ
  keyboard ? input
  WHILE input <=
                  5
    -- valid comment, indented at least as much as the following statement
    INT q:
    INT r:
    IF p = 0 FOR
       input
      p >
        input
	q :=
	    p     -- tabs used as four indents from now on
  SEQ
    VAL x IS
      p:
    x :=
	r
  SKIP
  STOP