From 77376dc1ef80b35a7edb68bdd7ad9db94a2ab2d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind?= Date: Fri, 22 Apr 2022 18:40:36 +0200 Subject: [PATCH] Added more debug vsl --- .../vslc/vsl_programs/ps3-simplify/lists.vsl | 2 + .../vsl_programs/ps3-simplify/while_test.vsl | 57 +++++++++++++++++++ .../vslc/vsl_programs/ps6-codegen2/lists.vsl | 35 ++++++++++++ .../vsl_programs/ps6-codegen2/while_test.vsl | 36 +++++++++++- 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 exercises/06/vslc/vsl_programs/ps3-simplify/while_test.vsl create mode 100644 exercises/06/vslc/vsl_programs/ps6-codegen2/lists.vsl diff --git a/exercises/06/vslc/vsl_programs/ps3-simplify/lists.vsl b/exercises/06/vslc/vsl_programs/ps3-simplify/lists.vsl index b405f61..2e3daa6 100644 --- a/exercises/06/vslc/vsl_programs/ps3-simplify/lists.vsl +++ b/exercises/06/vslc/vsl_programs/ps3-simplify/lists.vsl @@ -28,4 +28,6 @@ func main() begin if my_func(1, 2, 3, 5, 8, 13, 21, 34) > 3 then begin print "True!" end + + return 0 end \ No newline at end of file diff --git a/exercises/06/vslc/vsl_programs/ps3-simplify/while_test.vsl b/exercises/06/vslc/vsl_programs/ps3-simplify/while_test.vsl new file mode 100644 index 0000000..5caa685 --- /dev/null +++ b/exercises/06/vslc/vsl_programs/ps3-simplify/while_test.vsl @@ -0,0 +1,57 @@ +// This program is a simple test of while loops, counting down from 19 to 0 +// and skipping 10 (if continue is implemented) + +func while_test () +begin + var a, b + a := 20 + + b := test_while() + + print a + + + if a > 0 then print "foobar" + while a > 0 do + begin + if a = 10 then + begin + a -= 1 + print "Skip..." + continue + end + else + a -= 1 + print a + end + return 0 +end + +func test_while() +begin + var n, m + + n := 4 + m := 21 + + while n > 0 do + begin + n -= 1 + if n = 2 then + continue + + while m > 0 do + begin + m -= 1 + + if m = 10 then + continue + + print n, m + end + + + end + + return 0 +end \ No newline at end of file diff --git a/exercises/06/vslc/vsl_programs/ps6-codegen2/lists.vsl b/exercises/06/vslc/vsl_programs/ps6-codegen2/lists.vsl new file mode 100644 index 0000000..dd9302f --- /dev/null +++ b/exercises/06/vslc/vsl_programs/ps6-codegen2/lists.vsl @@ -0,0 +1,35 @@ + +func my_func(a, b, c, d, e, f, g, h) begin + var i, j, k, l, m + + i := a + b + d + + print i, f + + if i = f then begin + print "hmmm" + end + + if 1 < 2 then begin + print "Whaa" + end + else begin + print "Whooo" + end + + + + return i +end + +func main() begin + var n, o, p, q, r, s, t, u, v, w + n := 5 + n += my_func(1, 2, 3, 5, 8, 13, 21, 34) + + if my_func(1, 2, 3, 5, 8, 13, 21, 34) > 3 then begin + print "True!" + end + + return 0 +end \ No newline at end of file diff --git a/exercises/06/vslc/vsl_programs/ps6-codegen2/while_test.vsl b/exercises/06/vslc/vsl_programs/ps6-codegen2/while_test.vsl index 6b1c322..5caa685 100644 --- a/exercises/06/vslc/vsl_programs/ps6-codegen2/while_test.vsl +++ b/exercises/06/vslc/vsl_programs/ps6-codegen2/while_test.vsl @@ -3,9 +3,14 @@ func while_test () begin - var a + var a, b a := 20 + + b := test_while() + print a + + if a > 0 then print "foobar" while a > 0 do begin @@ -19,5 +24,34 @@ begin a -= 1 print a end + return 0 +end + +func test_while() +begin + var n, m + + n := 4 + m := 21 + + while n > 0 do + begin + n -= 1 + if n = 2 then + continue + + while m > 0 do + begin + m -= 1 + + if m = 10 then + continue + + print n, m + end + + + end + return 0 end \ No newline at end of file