Pristine Ack-5.5
[Ack-5.5.git] / lang / occam / test / xxtoy.ocm
1 def otherwise=true:
2
3 def NLET= ('z'-'a')+1:
4
5 proc xxtoy(chan in, out, value x, y)=
6     var c:
7     seq
8         c:= not EOF
9         while c<>EOF
10             seq
11                 in ? c
12                 if
13                     c=x
14                         seq
15                             in ? c
16                             if
17                                 c=x
18                                     out ! y
19                                 otherwise
20                                     out ! x; c
21                     otherwise
22                         out ! c
23 :
24 chan link[NLET-1]:
25
26 par
27     xxtoy(input, link[0], 'a', 'b')
28
29     par i=[0 for NLET-2]
30         xxtoy(link[i], link[i+1], i+'b', i+'c')
31
32     xxtoy(link[NLET-2], output, 'y', 'z')