DEADSOFTWARE

Добавлена конструкция WITH
[dsw-obn.git] / src / test.c
index a144f3616074e1f8891dbc30af0007420bad0ef9..dab2914ca12507682c8a29122dd5498aebb221b1 100644 (file)
@@ -8,37 +8,34 @@ static char source_test[] =
        "(* Main module *)"
        "MODULE Test;"
        "IMPORT Out;"
-       ""
        "TYPE"
-       "  R = INTEGER;"
+       "  R1 = POINTER TO R1Desc;"
+       "  R1Desc = RECORD a : INTEGER; END;"
+       "  R2 = POINTER TO R2Desc;"
+       "  R2Desc = RECORD (R1Desc) b : INTEGER; END;"
+       "  Y1 = POINTER TO Y1Desc;"
+       "  Y1Desc = RECORD END;"
+       ""
+       "VAR"
+       "  r1 : R1;"
+       "  r2 : R2;"
+       "  y1 : Y1;"
        ""
-       "PROCEDURE Factorial(n : R) : R;"
        "BEGIN"
-       "  IF n <= 1 THEN"
-       "    RETURN 1;"
+       "  NEW(r1);"
+       "  NEW(r2);"
+       "  NEW(y1);"
+       "  r1 := r2;"
+       "  Out.Open;"
+       "  WITH r1 : R2 DO"
+       "    r1.b := 666;"
+       "    Out.String('R2 branch');"
+       "  | y1 : Y1 DO"
+       "    Out.String('Y1 branch');"
        "  ELSE"
-       "    RETURN n * Factorial(n - 1);"
+       "    Out.String('Something else');"
        "  END;"
-       "  RETURN 0; (* Детектор ретурнов - дерьмо *)"
-       "END Factorial;"
-       ""
-       "BEGIN"
-       "  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;"
+       "  Out.Ln;"
        "END Test."
 ;