| 123456789101112131415161718192021222324252627 |
- MODULE TCompat;
- // GNU/classic compatibility accepted by V3 for self-hosting the
- // Coco/R-generated sources: '&' (AND) and '~' (NOT), LENGTH (alias of
- // LEN), CAP, ORDL, the octal character literal 0C, and empty
- // THEN/ELSE bodies. Exit 42.
- VAR ExitCode : INTEGER;
- VAR s : ARRAY [0..2] OF CHAR;
- VAR c : CHAR;
- VAR n : INTEGER;
- PROCEDURE Len (a : ARRAY OF CHAR) : INTEGER;
- BEGIN RETURN LENGTH(a) END Len;
- BEGIN
- s := "abc";
- n := Len(s); // 3 (LENGTH alias)
- c := CAP("q"); // 'Q'
- IF (n = 3) & (c = "Q") THEN
- n := n + 39 // & = AND -> 42
- ELSE
- END; // empty ELSE
- c := 0C; // octal char literal -> NUL
- IF ~(c = CHR(0)) THEN n := 0 END; // ~ = NOT
- n := n + ORDL(0); // ORDL
- IF n = 42 THEN ELSE n := 0 END; // empty THEN + ELSE
- ExitCode := n
- END TCompat.
|