challenge.pr 6.24 KB
Newer Older
1
/* CIF PROCESS (150, 150), (150, 75) */
Maxime Perrotin's avatar
Maxime Perrotin committed
2
PROCESS challenge;
Maxime Perrotin's avatar
Maxime Perrotin committed
3
STATE on;
Maxime Perrotin's avatar
Maxime Perrotin committed
4
5
6
SUBSTRUCTURE
in (via_toto);
out (ret0);
Maxime Perrotin's avatar
Maxime Perrotin committed
7
8
STATE hello;
SUBSTRUCTURE
Maxime Perrotin's avatar
Maxime Perrotin committed
9
/* CIF PROCEDURE (892, 436), (73, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
PROCEDURE entry;
/* CIF START (178, 136), (70, 35) */
START;
/* CIF PROCEDURECALL (160, 186), (106, 35) */
CALL writeln('8');
/* CIF PROCEDURECALL (145, 236), (136, 35) */
CALL writeln('Hello!');
/* CIF RETURN (195, 286), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (349, 133), (70, 35) */
START;
/* CIF NEXTSTATE (312, 183), (144, 35) */
NEXTSTATE wait_in_sub_hello;
/* CIF STATE (582, 147), (144, 35) */
STATE wait_in_sub_hello;
ENDSTATE;

ENDSUBSTRUCTURE;
Maxime Perrotin's avatar
Maxime Perrotin committed
29
30
31
32
33
34
35
/* CIF TEXT (242, 251), (334, 95) */
dcl myresult T_UInt8 := 4;
-- Use a variable with the same name as a variable
-- in the outer scope, to check that code generators
-- use the proper one
dcl result T_UInt32 := 9;
/* CIF ENDTEXT */
Maxime Perrotin's avatar
Maxime Perrotin committed
36
/* CIF PROCEDURE (558, 143), (70, 33) */
Maxime Perrotin's avatar
Maxime Perrotin committed
37
PROCEDURE exit
Maxime Perrotin's avatar
Maxime Perrotin committed
38
/* CIF COMMENT (648, 118), (157, 93) */
Maxime Perrotin's avatar
Maxime Perrotin committed
39
COMMENT 'Special exit
Maxime Perrotin's avatar
Maxime Perrotin committed
40
procedure - called
Maxime Perrotin's avatar
Maxime Perrotin committed
41
42
automatically when
leaving the nested
Maxime Perrotin's avatar
Maxime Perrotin committed
43
state';
Maxime Perrotin's avatar
Maxime Perrotin committed
44
/* CIF START (163, 119), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
45
START;
Maxime Perrotin's avatar
Maxime Perrotin committed
46
47
48
/* CIF PROCEDURECALL (68, 169), (259, 35) */
CALL writeln('LEAVING the nested state');
/* CIF RETURN (180, 219), (35, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (239, 522), (102, 35) */
PROCEDURE inner_proc;
/* CIF TEXT (31, 41), (364, 93) */
fpar in toto T_UInt8;

-- Redefine a variable declared in outer scope
dcl result t_Boolean := true;
/* CIF ENDTEXT */
/* CIF START (479, 97), (70, 35) */
START;
/* CIF LABEL (471, 147), (86, 35) */
hey_joe:
Maxime Perrotin's avatar
Maxime Perrotin committed
63
64
/* CIF PROCEDURECALL (457, 197), (113, 35) */
CALL writeln('10');
Maxime Perrotin's avatar
Maxime Perrotin committed
65
66
67
68
69
70
71
/* CIF TASK (453, 247), (121, 35) */
TASK result := false;
/* CIF LABEL (473, 297), (82, 35) */
leaving:
/* CIF RETURN (496, 347), (35, 35) */
RETURN ;
ENDPROCEDURE;
Maxime Perrotin's avatar
Maxime Perrotin committed
72
73
74
75
/* CIF PROCEDURE (554, 54), (73, 35) */
PROCEDURE entry
/* CIF COMMENT (643, 31), (190, 83) */
COMMENT 'Special Entry
Maxime Perrotin's avatar
Maxime Perrotin committed
76
procedure - called
Maxime Perrotin's avatar
Maxime Perrotin committed
77
78
automatically upon
entrance to the nested
Maxime Perrotin's avatar
Maxime Perrotin committed
79
state';
Maxime Perrotin's avatar
Maxime Perrotin committed
80
/* CIF START (191, 78), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
81
START;
Maxime Perrotin's avatar
Maxime Perrotin committed
82
83
84
/* CIF PROCEDURECALL (100, 128), (251, 35) */
CALL writeln('ENTERING NESTED STATE');
/* CIF RETURN (208, 178), (35, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
85
86
87
RETURN ;
ENDPROCEDURE;
/* CIF START (1188, 7), (89, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
88
START via_toto ;
Maxime Perrotin's avatar
Maxime Perrotin committed
89
90
/* CIF PROCEDURECALL (1179, 57), (106, 35) */
CALL writeln('3');
Maxime Perrotin's avatar
Maxime Perrotin committed
91
/* CIF RETURN (1215, 107), (35, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
92
RETURN ret0;
Maxime Perrotin's avatar
Maxime Perrotin committed
93
/* CIF START (938, 8), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
94
START;
Maxime Perrotin's avatar
Maxime Perrotin committed
95
96
/* CIF PROCEDURECALL (920, 58), (106, 35) */
CALL writeln('7');
Maxime Perrotin's avatar
Maxime Perrotin committed
97
98
99
100
101
102
103
104
105
106
107
108
109
/* CIF LABEL (917, 108), (111, 35) */
inside_label:
/* CIF PROCEDURECALL (904, 158), (137, 35) */
CALL pow(3,3, result);
/* CIF DECISION (936, 208), (74, 50) */
DECISION result;
/* CIF ANSWER (861, 278), (92, 23) */
(myresult):
/* CIF ANSWER (985, 278), (70, 23) */
ELSE:
/* CIF TASK (962, 316), (115, 35) */
TASK myresult := 5;
ENDDECISION;
Maxime Perrotin's avatar
Maxime Perrotin committed
110
/* CIF LABEL (929, 366), (88, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
111
nslabel:
Maxime Perrotin's avatar
Maxime Perrotin committed
112
/* CIF NEXTSTATE (938, 416), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
113
NEXTSTATE hello;
Maxime Perrotin's avatar
Maxime Perrotin committed
114
115
116
117
118
119
/* CIF LABEL (132, 324), (90, 35) */
CONNECTION to_label:
/* CIF JOIN (159, 374), (35, 35) */
JOIN another_floating;
/* CIF End Label */
ENDCONNECTION;
Maxime Perrotin's avatar
Maxime Perrotin committed
120
121
/* CIF LABEL (512, 472), (141, 35) */
CONNECTION another_floating:
Maxime Perrotin's avatar
Maxime Perrotin committed
122
123
124
/* CIF PROCEDURECALL (526, 522), (113, 35) */
CALL writeln('9');
/* CIF TASK (525, 572), (115, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
125
TASK myresult := 1;
Maxime Perrotin's avatar
Maxime Perrotin committed
126
/* CIF PROCEDURECALL (500, 622), (164, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
127
CALL inner_proc(myresult);
Maxime Perrotin's avatar
Maxime Perrotin committed
128
/* CIF RETURN (565, 672), (35, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
129
130
131
132
RETURN ;
/* CIF End Label */
ENDCONNECTION;
/* CIF STATE (0, 0), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
133
STATE hello;
Maxime Perrotin's avatar
Maxime Perrotin committed
134
/* CIF INPUT (0, 61), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
135
INPUT run;
Maxime Perrotin's avatar
Maxime Perrotin committed
136
137
/* CIF PROCEDURECALL (-52, 111), (175, 35) */
CALL writeln('27 == ', result);
Maxime Perrotin's avatar
Maxime Perrotin committed
138
139
140
/* CIF PROCEDURECALL (0, 161), (70, 35) */
CALL toto;
/* CIF TASK (-27, 211), (125, 53) */
Maxime Perrotin's avatar
Maxime Perrotin committed
141
142
TASK myresult := 88,
result := 33;
Maxime Perrotin's avatar
Maxime Perrotin committed
143
/* CIF JOIN (17, 279), (35, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
144
JOIN to_label;
Maxime Perrotin's avatar
Maxime Perrotin committed
145
ENDSTATE;
Maxime Perrotin's avatar
Maxime Perrotin committed
146

Maxime Perrotin's avatar
Maxime Perrotin committed
147
ENDSUBSTRUCTURE;
Maxime Perrotin's avatar
Maxime Perrotin committed
148
/* CIF TEXT (506, 0), (298, 56) */
Maxime Perrotin's avatar
Maxime Perrotin committed
149
-- This system tests nested states
Maxime Perrotin's avatar
Maxime Perrotin committed
150
151

dcl result T_uint32 :=0;
Maxime Perrotin's avatar
Maxime Perrotin committed
152
/* CIF ENDTEXT */
Maxime Perrotin's avatar
Maxime Perrotin committed
153
/* CIF PROCEDURE (-19, 183), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
154
155
156
157
158
159
PROCEDURE foo;
/* CIF START (190, 53), (70, 35) */
START;
/* CIF RETURN (207, 103), (35, 35) */
RETURN ;
ENDPROCEDURE;
Maxime Perrotin's avatar
Maxime Perrotin committed
160
/* CIF PROCEDURE (-24, 247), (66, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
161
162
163
164
165
166
167
168
169
170
171
172
173
174
PROCEDURE toto;
/* CIF TEXT (371, 134), (298, 140) */
-- Declare your variables

-- Syntax: DCL <variable name> <type name>;

dcl i T_Int8  := 1;
/* CIF ENDTEXT */
/* CIF START (178, 86), (70, 35) */
START;
/* CIF DECISION (178, 136), (70, 50) */
DECISION i;
/* CIF ANSWER (131, 206), (73, 23) */
(1):
Maxime Perrotin's avatar
Maxime Perrotin committed
175
176
/* CIF TASK (96, 244), (143, 35) */
TASK i := (i + 1) mod 127;
Maxime Perrotin's avatar
Maxime Perrotin committed
177
178
/* CIF RETURN (150, 294), (35, 35) */
RETURN ;
Maxime Perrotin's avatar
Maxime Perrotin committed
179
/* CIF ANSWER (249, 206), (70, 23) */
Maxime Perrotin's avatar
Maxime Perrotin committed
180
ELSE:
Maxime Perrotin's avatar
Maxime Perrotin committed
181
/* CIF PROCEDURECALL (249, 244), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
182
CALL foo;
Maxime Perrotin's avatar
Maxime Perrotin committed
183
/* CIF RETURN (266, 294), (35, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
184
185
186
RETURN ;
ENDDECISION;
ENDPROCEDURE;
Maxime Perrotin's avatar
Maxime Perrotin committed
187
/* CIF START (-341, 99), (68, 37) */
Maxime Perrotin's avatar
Maxime Perrotin committed
188
START;
Maxime Perrotin's avatar
Maxime Perrotin committed
189
190
191
/* CIF PROCEDURECALL (-360, 151), (106, 35) */
CALL writeln('1');
/* CIF NEXTSTATE (-342, 201), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
192
193
194
NEXTSTATE OFF;


Maxime Perrotin's avatar
Maxime Perrotin committed
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/* CIF STATE (157, 278), (73, 35) */
STATE Safe;
/* CIF INPUT (102, 333), (70, 35) */
INPUT *;
/* CIF PROCEDURECALL (84, 383), (106, 35) */
CALL writeln('5');
/* CIF PROCEDURECALL (72, 433), (130, 35) */
CALL pow(2,2, result);
/* CIF PROCEDURECALL (53, 483), (168, 35) */
CALL writeln('4 == ', result);
/* CIF NEXTSTATE (102, 533), (70, 35) */
NEXTSTATE -;
/* CIF INPUT (297, 333), (88, 35) */
INPUT any_one;
Maxime Perrotin's avatar
Maxime Perrotin committed
209
/* CIF PROCEDURECALL (284, 383), (113, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
210
211
212
213
214
215
CALL writeln('6');
/* CIF NEXTSTATE (306, 433), (70, 35) */
NEXTSTATE on;
ENDSTATE;


Maxime Perrotin's avatar
Maxime Perrotin committed
216
217


Maxime Perrotin's avatar
Maxime Perrotin committed
218
/* CIF STATE (851, 72), (65, 35) */
Marco Lattuada's avatar
Marco Lattuada committed
219
STATE on;
Maxime Perrotin's avatar
Maxime Perrotin committed
220
/* CIF INPUT (1043, 127), (88, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
221
INPUT any_one;
Maxime Perrotin's avatar
Maxime Perrotin committed
222
/* CIF NEXTSTATE (1030, 177), (113, 35) */
223
NEXTSTATE -;
Maxime Perrotin's avatar
Maxime Perrotin committed
224
/* CIF INPUT (1153, 127), (78, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
225
INPUT go_off;
Maxime Perrotin's avatar
Maxime Perrotin committed
226
/* CIF NEXTSTATE (1161, 177), (62, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
227
NEXTSTATE OFF;
Maxime Perrotin's avatar
Maxime Perrotin committed
228
/* CIF CONNECT (884, 127), (0, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
229
CONNECT ret0;
Maxime Perrotin's avatar
Maxime Perrotin committed
230
231
232
/* CIF PROCEDURECALL (831, 177), (106, 35) */
CALL writeln('4');
/* CIF NEXTSTATE (850, 227), (67, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
233
NEXTSTATE Safe;
Maxime Perrotin's avatar
Maxime Perrotin committed
234
/* CIF CONNECT (568, 127), (0, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
235
CONNECT ;
Maxime Perrotin's avatar
Maxime Perrotin committed
236
237
/* CIF PROCEDURECALL (494, 177), (147, 35) */
CALL writeln('11 (end)');
Maxime Perrotin's avatar
Maxime Perrotin committed
238
239
240
/* CIF PROCEDURECALL (533, 227), (70, 35) */
CALL toto;
/* CIF NEXTSTATE (533, 277), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
241
242
243
NEXTSTATE off;
ENDSTATE;

Maxime Perrotin's avatar
Maxime Perrotin committed
244
/* CIF STATE (-342, 201), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
245
STATE OFF;
Maxime Perrotin's avatar
Maxime Perrotin committed
246
/* CIF INPUT (-342, 256), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
247
INPUT run;
Maxime Perrotin's avatar
Maxime Perrotin committed
248
249
250
/* CIF PROCEDURECALL (-360, 306), (106, 35) */
CALL writeln('2');
/* CIF NEXTSTATE (-374, 357), (132, 35) */
Marco Lattuada's avatar
Marco Lattuada committed
251
NEXTSTATE on via via_toto
Maxime Perrotin's avatar
Maxime Perrotin committed
252
/* CIF COMMENT (-222, 357), (219, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
253
COMMENT 'Enter substate via entry point';
Maxime Perrotin's avatar
Maxime Perrotin committed
254
ENDSTATE;
Marco Lattuada's avatar
Marco Lattuada committed
255
ENDPROCESS challenge;