1 #include <stdio.h>
2 #include <string.h>
3 #include <assert.h>
8 "(* Main module *)"
9 "MODULE Test;"
10 "IMPORT Out;"
11 ""
12 "TYPE"
13 " R = INTEGER;"
14 ""
15 "PROCEDURE Factorial(n : R) : R;"
16 "BEGIN"
17 " IF n <= 1 THEN"
18 " RETURN 1;"
19 " ELSE"
20 " RETURN n * Factorial(n - 1);"
21 " END;"
22 " RETURN 0; (* Детектор ретурнов - дерьмо *)"
23 "END Factorial;"
24 ""
25 "BEGIN"
26 " Out.Open();"
27 " Out.Int(Factorial(0), 0); Out.Ln;"
28 " Out.Int(Factorial(1), 0); Out.Ln;"
29 " Out.Int(Factorial(2), 0); Out.Ln;"
30 " Out.Int(Factorial(3), 0); Out.Ln;"
31 " Out.Int(Factorial(4), 0); Out.Ln;"
32 " Out.Int(Factorial(5), 0); Out.Ln;"
33 " Out.Int(Factorial(6), 0); Out.Ln;"
34 " Out.Int(Factorial(7), 0); Out.Ln;"
35 " Out.Int(Factorial(8), 0); Out.Ln;"
36 " Out.Int(Factorial(9), 0); Out.Ln;"
37 " Out.Int(Factorial(10), 0); Out.Ln;"
38 " Out.Int(Factorial(11), 0); Out.Ln;"
39 " Out.Int(Factorial(12), 0); Out.Ln;"
40 " Out.Int(Factorial(13), 0); Out.Ln;"
41 " Out.Int(Factorial(14), 0); Out.Ln;"
42 "END Test."
43 ;
46 "MODULE Out;"
47 " PROCEDURE Open*;"
48 " END Open;"
49 ""
50 " PROCEDURE Char* (ch : CHAR);"
51 " END Char;"
52 ""
53 " PROCEDURE String* (str : ARRAY OF CHAR);"
54 " END String;"
55 ""
56 " PROCEDURE Int*(i, n : LONGINT);"
57 " END Int;"
58 ""
59 " PROCEDURE Real*(x : REAL; n : INTEGER);"
60 " END Real;"
61 ""
62 " PROCEDURE LongReal*(x : LONGREAL; n : INTEGER);"
63 " END LongReal;"
64 ""
65 " PROCEDURE Ln*;"
66 " END Ln;"
67 ""
68 "END Out."
69 ;
76 {
78 {
80 }
82 {
84 }
85 else
86 {
88 }
89 }
94 {
95 }
100 {
105 {
107 }
109 }
114 {
119 {
121 }
123 }
128 {
130 }
133 {
142 }
145 {
148 }
150 int
152 {
158 // init_system_modules();
160 // oberon_generator_dump(ctx, "dump.txt");
162 // start_module();
166 }