- SEQ — Sequential execution, with replicators (
SEQ i = 0 FOR n) and optional STEP - PAR — Parallel execution via goroutines + sync.WaitGroup, with replicators
- IF — Multi-branch conditionals, maps to if/else if chains, with replicators; supports multi-statement bodies (declarations scoped before process)
- WHILE — Loops, maps to Go
forloops; supports multi-statement bodies - CASE — Pattern matching with multiple cases and ELSE branch; supports multi-statement bodies
- ALT / PRI ALT — Channel alternation, maps to Go
select; supports boolean guards, timer timeouts, multi-statement bodies, and replicators (ALT i = 0 FOR nusingreflect.Select). PRI ALT treated identically (Go has no priority select). - PRI PAR — Priority parallel, treated identically to PAR (Go goroutines have no priority)
- SKIP — No-op process
- STOP — Error + deadlock
- INT, INT16, INT32, INT64, BYTE, BOOL, REAL, REAL32, REAL64 — Scalar types (INT16/32/64 map to int16/32/64, REAL/REAL64 map to float64, REAL32 maps to float32)
- Variable declarations —
INT x, y, z: - Arrays —
[n]TYPE arr:with index expressions; multi-dimensional[n][m]TYPEwith nested init loops; mixed-dimension abbreviations[][n]TYPEand[][]TYPE - Channels —
CHAN OF TYPE c:with send (!) and receive (?);CHAN BYTEshorthand (withoutOF) - Channel arrays —
[n]CHAN OF TYPE cs:with indexed send/receive; multi-dimensional[n][m]CHAN OF TYPEwith nested init loops;[]CHAN,[][]CHAN, etc. proc params - Channel direction —
CHAN OF INT c?(receive-only) andCHAN OF INT c!(send-only); direction annotations at call sites (out!,in?) accepted and ignored - Timers —
TIMER tim:with reads andAFTERexpressions - Abbreviations —
VAL INT x IS 1:,INT y IS z:, untypedVAL x IS expr:— named constants and aliases - INITIAL declarations —
INITIAL INT x IS 42:— mutable variables with initial values - Byte literals —
'A','0'with occam escape sequences (*n,*c,*t) - Hex integer literals —
#FF,#80000000
- PROC — Declaration with VAL, reference, CHAN OF, and open array (
[]TYPE) parameters - PROC calls — With automatic
&/*for reference params, pass-through for channels - FUNCTION (IS form) —
INT FUNCTION square(VAL INT x) IS x * x - FUNCTION (VALOF form) — Local declarations + VALOF body + RESULT
- Multi-result FUNCTIONs —
INT, INT FUNCTION f(...)returning multiple values viaRESULT a, b - Nested PROCs/FUNCTIONs — Local definitions inside a PROC body, compiled as Go closures
- KRoC-style colon terminators — Optional
:at end of PROC/FUNCTION body - INLINE modifier —
INT INLINE FUNCTION f(...)— accepted and ignored (optimization hint only) - Built-in print —
print.int,print.bool,print.string,print.newline
- Arithmetic —
+,-,*,/,\(modulo) - Comparison —
=,<>,<,>,<=,>= - Logical —
AND,OR,NOT - Bitwise —
/\,\/,><,~,<<,>> - AFTER — As boolean expression (maps to
>) - Parenthesized expressions
- Array indexing —
arr[i],arr[expr], multi-dimensionalgrid[i][j] - String literals — Double-quoted strings
- Type conversions —
INT expr,INT16 expr,INT32 expr,INT64 expr,BYTE expr,BOOL expr,REAL32 expr,REAL64 expr(including BOOL↔numeric conversions, and ROUND/TRUNC qualifiers for float↔int conversions) - Checked arithmetic —
PLUS,MINUS,TIMES— modular (wrapping) operators - MOSTNEG/MOSTPOS — Type min/max constants for INT, INT16, INT32, INT64, BYTE, REAL32, REAL64
- SIZE operator —
SIZE arr,SIZE "str"maps tolen() - Array slices —
[arr FROM n FOR m]with slice assignment - Array literals —
[1, 2, 3]— inline array/table expressions - Multi-assignment —
a, b := f(...)including indexed targets likex[0], x[1] := x[1], x[0] - Multi-line expression continuation — Binary operators and
:=at end of line continue expression on next line
- Simple —
PROTOCOL SIG IS INT(type alias) - Sequential —
PROTOCOL PAIR IS INT ; BYTE(struct) - Variant —
PROTOCOL MSG CASE tag; TYPE ...(interface + concrete types), including dotted tag names (bar.data,bar.terminate)
- RECORD — Struct types with field access via bracket syntax (
p[x])
- RETYPES — Bit-level type reinterpretation (
VAL INT X RETYPES X :for float32→int,VAL [2]INT X RETYPES X :for float64→int pair) - Transputer intrinsics —
LONGPROD,LONGDIV,LONGSUM,LONGDIFF,NORMALISE,SHIFTLEFT,SHIFTRIGHT— extended-precision arithmetic as Go helper functions - CAUSEERROR — Error-raising primitive, maps to
panic("CAUSEERROR")
#IF/#ELSE/#ENDIF— Conditional compilation withTRUE,FALSE,DEFINED(),NOT, equality#DEFINE— Symbol definition#INCLUDE— File inclusion with search paths and include guards#COMMENT/#PRAGMA/#USE— Ignored (blank lines)- Predefined symbols —
TARGET.BITS.PER.WORD = 64
- gen-module — Generate
.modulefiles from KRoC SConscript build files
| Feature | Notes | Used in |
|---|---|---|
DATA TYPE X IS TYPE: |
Simple type alias (e.g. DATA TYPE COLOUR IS BYTE:). |
shared_screen.inc |
DATA TYPE X RECORD |
Alternative record syntax (vs current RECORD X). |
shared_screen.inc |
| Counted array protocol | BYTE::[]BYTE — length-prefixed array in protocols. |
shared_screen.inc, shared_screen.occ |
RESULT param qualifier |
RESULT INT len on PROC params (output-only, like a write-only reference). |
float_io.occ |
| Feature | Notes |
|---|---|
| PLACED PAR | Assigning processes to specific hardware. |
| PORT OF | Hardware port mapping. |
VAL []BYTE abbreviations |
VAL []BYTE cmap IS "0123456789ABCDEF": — named string constants. |
#PRAGMA DEFINED |
Compiler hint to suppress definedness warnings. Can be ignored. |