root / branches / compiler / cSharp / ooasCompiler / doc / examples / Stack.ooas
1 | 3 | krennw | types |
---|---|---|---|
2 | SmallInt = int [0..3]; |
||
3 | Stack = autocons system |
||
4 | |[ |
||
5 | var |
||
6 | my_stack : list [10] of SmallInt = [0] |
||
7 | actions |
||
8 | obs top (a : SmallInt) = requires (a = hd my_stack) : |
||
9 | skip |
||
10 | end ; |
||
11 | obs pop = requires (len my_stack > 0) : |
||
12 | my_stack := tl my_stack |
||
13 | end; |
||
14 | obs push (a : SmallInt) = requires len my_stack < 10 : |
||
15 | my_stack := [a] ^ my_stack |
||
16 | end |
||
17 | |||
18 | do |
||
19 | var A : SmallInt : push(A) [] pop() [] var B : SmallInt : top(B) |
||
20 | od |
||
21 | ]| |
||
22 | system |
||
23 | Stack |