summaryrefslogtreecommitdiff
path: root/test.toc
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-16 15:46:14 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-16 15:46:14 -0400
commitd7b155a319b423d3b1cda76bd33360964e124a65 (patch)
treec2815e9eb82eddfbe2240f18599bfc2429a64342 /test.toc
parent7d5365973221b596fd1b8c57f648ba05aff67715 (diff)
runtime break/continue
Diffstat (limited to 'test.toc')
-rw-r--r--test.toc41
1 files changed, 6 insertions, 35 deletions
diff --git a/test.toc b/test.toc
index 03ffe28..398f7b7 100644
--- a/test.toc
+++ b/test.toc
@@ -1,38 +1,9 @@
-
-printf ::= #foreign("printf","libc.so.6") fn(#C &"const char", #C ..) #C int;
-
-
-// NOTE: this doesn't work (e.g. "%%%")
-tprintf_valid ::= fn(fmt :: []char, nargs: int) bool {
- if fmt[fmt.len-1] != '\0' {
- return false;
- }
- count := 0;
- for x, i := fmt {
- if x == '%' {
- if i == fmt.len-1 {
- count += 1;
- } elif fmt[i+1] != '%' {
- count += 1;
- } else {
- count -= 1;
- }
- }
- }
- count == nargs
-}
-
-
-tprintf ::= fn(fmt :: []char, args: ..) {
- #if !tprintf_valid(fmt, args.len) {
- #error "Invalid printf format";
- }
- f := fmt;
- printf(&f[0], args);
-}
+#include "std/io.toc", io;
main ::= fn() {
- tprintf("%d %d%%\n\0", 3, 4);
+ for i := 1..10 {
+ if i % 2 == 0 { continue; }
+ io.puti(i);
+ if i == 7 { break; }
+ }
}
-
-main(); \ No newline at end of file