diff --git a/src/test.c b/src/test.c
index 3305807bbb3fa1c87b0cbd508aaec7e6787ebbfb..a144f3616074e1f8891dbc30af0007420bad0ef9 100644 (file)
--- a/src/test.c
+++ b/src/test.c
"(* Main module *)"
"MODULE Test;"
"IMPORT Out;"
- "TYPE"
- " Callback = PROCEDURE;"
- " Callfront = PROCEDURE(x : LONGINT) : LONGINT;"
- " RecDesc = RECORD"
- " cb : Callback;"
- " cf : Callfront;"
- " END;"
- ""
- "VAR"
- " r : RecDesc;"
- " i : LONGINT;"
""
- "PROCEDURE Stuff;"
- "BEGIN"
- " Out.Int(0123456789, 0); Out.Ln;"
- "END Stuff;"
+ "TYPE"
+ " R = INTEGER;"
""
- "PROCEDURE Ffuts (x : LONGINT) : LONGINT;"
+ "PROCEDURE Factorial(n : R) : R;"
"BEGIN"
- " RETURN 9876543210 + x;"
- "END Ffuts;"
+ " IF n <= 1 THEN"
+ " RETURN 1;"
+ " ELSE"
+ " RETURN n * Factorial(n - 1);"
+ " END;"
+ " RETURN 0; (* Детектор ретурнов - дерьмо *)"
+ "END Factorial;"
""
"BEGIN"
- " Out.Open;"
- " Out.Int(1, 0); Out.Ln;"
- " r.cb := Stuff;"
- " Out.Int(2, 0); Out.Ln;"
- " r.cb();"
- " Out.Int(3, 0); Out.Ln;"
- " r.cf := Ffuts;"
- " Out.Int(4, 0); Out.Ln;"
- " i := r.cf(0123456789);"
- " Out.Int(i, 0); Out.Ln;"
+ " Out.Open();"
+ " Out.Int(Factorial(0), 0); Out.Ln;"
+ " Out.Int(Factorial(1), 0); Out.Ln;"
+ " Out.Int(Factorial(2), 0); Out.Ln;"
+ " Out.Int(Factorial(3), 0); Out.Ln;"
+ " Out.Int(Factorial(4), 0); Out.Ln;"
+ " Out.Int(Factorial(5), 0); Out.Ln;"
+ " Out.Int(Factorial(6), 0); Out.Ln;"
+ " Out.Int(Factorial(7), 0); Out.Ln;"
+ " Out.Int(Factorial(8), 0); Out.Ln;"
+ " Out.Int(Factorial(9), 0); Out.Ln;"
+ " Out.Int(Factorial(10), 0); Out.Ln;"
+ " Out.Int(Factorial(11), 0); Out.Ln;"
+ " Out.Int(Factorial(12), 0); Out.Ln;"
+ " Out.Int(Factorial(13), 0); Out.Ln;"
+ " Out.Int(Factorial(14), 0); Out.Ln;"
"END Test."
;
-// PROCEDURE Char* (ch : CHAR);
-// PROCEDURE String* (str : ARRAY OF CHAR);
-
static char source_out[] =
"MODULE Out;"
" PROCEDURE Open*;"
" END Open;"
""
+ " PROCEDURE Char* (ch : CHAR);"
+ " END Char;"
+ ""
+ " PROCEDURE String* (str : ARRAY OF CHAR);"
+ " END String;"
+ ""
" PROCEDURE Int*(i, n : LONGINT);"
" END Int;"
""