Stage 1 done; added test file for break/continue
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 26 Jun 2020 20:06:26 +0000 (15:06 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 26 Jun 2020 20:06:26 +0000 (15:06 -0500)
docs/plan
progs/break_test.onyx [new file with mode: 0644]

index 109dcf6beeaa18a5bd3c956befed5d15c1f1d26f..26de694bbd6fd99902401d8a2f75d2558c2aed6a 100644 (file)
--- a/docs/plan
+++ b/docs/plan
@@ -59,8 +59,8 @@ HOW:
         [X] Comparison operators
         [X] Proper boolean type
         [X] Conditional branching works as expected
-        XX] Simple while loop is functioning as expected
-        [ ] break and continue semantics
+        [X] Simple while loop is functioning as expected
+        [X] break and continue semantics
         [X] Function calling works for the builtin types
         [X] Function return values are type checked
 
diff --git a/progs/break_test.onyx b/progs/break_test.onyx
new file mode 100644 (file)
index 0000000..a902383
--- /dev/null
@@ -0,0 +1,40 @@
+
+print :: foreign "host" "print" proc (val i32) ---
+
+export main :: proc {
+
+    x := 0;
+    while x < 10 {
+
+        if x == 4 {
+
+            x := 1;
+            while x < 1000000 {
+                print(x);
+
+                if x > 4 { break; }
+
+                x = x + 1;
+            }
+
+        }
+
+        if x == 2 {
+
+            x := 1;
+            while x <= 5 {
+                if x == 3 {
+                    x = x + 1;
+                    continue;
+                }
+
+                print(x);
+                x = x + 1;
+            }
+
+        }
+
+        x = x + 1;
+    }
+
+}