While is working but untested, read more

* TODO: break and continue keywords need to be implemented
* TODO: while-then needs testing
* Fixed the parser not liking zero-length strings
This commit is contained in:
2024-11-26 14:48:24 +11:00
parent 0947430c29
commit 6cc331d462
7 changed files with 139 additions and 25 deletions

27
scripts/fizzbuzz.toy Normal file
View File

@@ -0,0 +1,27 @@
//moment of truth
var counter: int = 1;
while (counter <= 100) {
var result: string = "";
if (counter % 3 == 0) {
result = result .. "fizz";
}
if (counter % 5 == 0) {
result = result .. "buzz";
}
//finally
if (result == "") {
print counter;
}
else {
print result;
}
counter += 1;
}

9
scripts/looping.toy Normal file
View File

@@ -0,0 +1,9 @@
var a: int = 0;
while(a < 10) {
print a;
a += 1;
}
print "Finished";