challenge.pr 7.92 KB
Newer Older
1 2 3 4 5 6 7 8 9
/* CIF PROCESS (150, 150), (150, 75) */
PROCESS challenge;
    STATE AGGREGATION Safe;
    SUBSTRUCTURE
        STATE A;
        SUBSTRUCTURE
            START;
            NEXTSTATE HA;
            STATE HA;
10 11
                input run;
                nextstate -;
12 13 14 15 16 17 18
            ENDSTATE;
        ENDSUBSTRUCTURE;
        STATE B;
        SUBSTRUCTURE
            START;
            NEXTSTATE BEH;
            STATE BEH;
19 20
                input any_one;
                nextstate beh;
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
            ENDSTATE;
        ENDSUBSTRUCTURE;
    ENDSUBSTRUCTURE;
    STATE on;
    SUBSTRUCTURE
        in (via_toto);
        out (ret0);
            STATE hello;
            SUBSTRUCTURE
                    /* CIF PROCEDURE (892, 436), (73, 35) */
                    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;
49 50 51 52 53 54 55
            STATE AGGREGATION AggregNextToHello;
            SUBSTRUCTURE
                STATE C;
                SUBSTRUCTURE
                    START;
                    NEXTSTATE CEH;
                    STATE CEH;
56 57
                        input any_two;
                        nextstate ceh;
58 59 60 61 62 63 64 65 66 67 68
                    ENDSTATE;
                ENDSUBSTRUCTURE;
                STATE D; 
                SUBSTRUCTURE
                    START;
                    NEXTSTATE DEH;
                    STATE DEH;
                    ENDSTATE;
                ENDSUBSTRUCTURE;
            ENDSUBSTRUCTURE;

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
            /* 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 */
            /* CIF PROCEDURE (554, 54), (73, 35) */
            PROCEDURE entry
            /* CIF COMMENT (643, 31), (190, 83) */
            COMMENT 'Special Entry
procedure - called
automatically upon
entrance to the nested
state';
                /* CIF START (191, 78), (70, 35) */
                START;
                    /* CIF PROCEDURECALL (100, 128), (251, 35) */
                    CALL writeln('ENTERING NESTED STATE');
                    /* CIF RETURN (208, 178), (35, 35) */
                    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:
                    /* CIF PROCEDURECALL (457, 197), (113, 35) */
                    CALL writeln('10');
                    /* CIF TASK (453, 247), (121, 35) */
                    TASK result := false;
                    /* CIF LABEL (473, 297), (82, 35) */
                    leaving:
                    /* CIF RETURN (496, 347), (35, 35) */
                    RETURN ;
            ENDPROCEDURE;
            /* CIF PROCEDURE (558, 143), (70, 33) */
            PROCEDURE exit
            /* CIF COMMENT (648, 118), (157, 93) */
            COMMENT 'Special exit
procedure - called
automatically when
leaving the nested
state';
                /* CIF START (163, 119), (70, 35) */
                START;
                    /* CIF PROCEDURECALL (68, 169), (259, 35) */
                    CALL writeln('LEAVING the nested state');
                    /* CIF RETURN (180, 219), (35, 35) */
                    RETURN ;
            ENDPROCEDURE;
            /* CIF START (1188, 7), (89, 35) */
            START via_toto ;
                /* CIF PROCEDURECALL (1179, 57), (106, 35) */
                CALL writeln('3');
                /* CIF RETURN (1215, 107), (35, 35) */
                RETURN ret0;
            /* CIF START (938, 8), (70, 35) */
            START;
                /* CIF PROCEDURECALL (920, 58), (106, 35) */
                CALL writeln('7');
                /* 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;
                /* CIF LABEL (929, 366), (88, 35) */
                nslabel:
                /* CIF NEXTSTATE (938, 416), (70, 35) */
Maxime Perrotin's avatar
Maxime Perrotin committed
153
                NEXTSTATE AggregNextToHello;
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
            /* CIF LABEL (512, 472), (141, 35) */
            CONNECTION another_floating:
                /* CIF PROCEDURECALL (526, 522), (113, 35) */
                CALL writeln('9');
                /* CIF TASK (525, 572), (115, 35) */
                TASK myresult := 1;
                /* CIF PROCEDURECALL (500, 622), (164, 35) */
                CALL inner_proc(myresult);
                /* CIF RETURN (565, 672), (35, 35) */
                RETURN ;
            /* CIF End Label */
            ENDCONNECTION;
            /* CIF LABEL (132, 324), (90, 35) */
            CONNECTION to_label:
                /* CIF JOIN (159, 374), (35, 35) */
                JOIN another_floating;
            /* CIF End Label */
            ENDCONNECTION;
            /* CIF STATE (0, 0), (70, 35) */
            STATE hello;
                /* CIF INPUT (6, 55), (70, 35) */
                INPUT run;
                    /* CIF PROCEDURECALL (-46, 111), (175, 35) */
                    CALL writeln('27 == ', result);
                    /* CIF TASK (-21, 161), (125, 53) */
                    TASK myresult := 88,
result := 33;
                    /* CIF JOIN (24, 229), (35, 35) */
                    JOIN to_label;
            ENDSTATE;
Maxime Perrotin's avatar
Maxime Perrotin committed
184 185
            state AggregNextToHello;
            endstate;
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
    ENDSUBSTRUCTURE;
    /* CIF TEXT (51, 0), (298, 56) */
    -- This system tests nested states

dcl result T_uint32 :=0;
    /* CIF ENDTEXT */
    /* CIF START (0, 113), (68, 37) */
    START;
        /* CIF PROCEDURECALL (-19, 165), (106, 35) */
        CALL writeln('1');
        /* CIF NEXTSTATE (-1, 215), (70, 35) */
        NEXTSTATE OFF;
    /* CIF STATE (234, 140), (65, 35) */
    STATE on;
        /* CIF CONNECT (267, 195), (0, 35) */
        CONNECT ret0;
            /* CIF NEXTSTATE (234, 245), (67, 35) */
            NEXTSTATE Safe;
        /* CIF CONNECT (179, 195), (0, 35) */
        CONNECT ;
            /* CIF NEXTSTATE (144, 245), (70, 35) */
            NEXTSTATE off;
    ENDSTATE;
    /* CIF STATE (-1, 215), (70, 35) */
    STATE OFF;
        /* CIF INPUT (-1, 270), (70, 35) */
        INPUT run;
            /* CIF PROCEDURECALL (-19, 320), (106, 35) */
            CALL writeln('2');
            /* CIF NEXTSTATE (-32, 371), (132, 35) */
            NEXTSTATE on
            /* CIF COMMENT (119, 371), (219, 35) */
            COMMENT 'Enter substate via entry point';
    ENDSTATE;
    state safe;
    endstate;
ENDPROCESS challenge;