summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-03-16 15:53:06 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-03-16 15:53:06 -0400
commit8e5455bb58956031658caab650f0a162fc471508 (patch)
treea50cd8f0c0067b4e199cde3fbb2c5cd48573e807
parentd7b155a319b423d3b1cda76bd33360964e124a65 (diff)
oops forgot about while!
-rw-r--r--main.c14
-rw-r--r--parse.c1
-rw-r--r--test.toc8
3 files changed, 17 insertions, 6 deletions
diff --git a/main.c b/main.c
index 3e75e12..e21285a 100644
--- a/main.c
+++ b/main.c
@@ -10,19 +10,21 @@
TODO:
break
continue
+&&, ||
+don't allow while {3; 5} or for 0..10 { 3; 5 }
+make #sizeof always take a Type
+sizeof (not #sizeof)
+- make new(s) and del functions!
+start making a standard library... (printf; stringbuilder would be nice to have)
switch
+ - #fallthrough
+ - make sure break works inside a switch with cgen! - you'll need goto
enums
unions
-sizeof (not #sizeof)
-- make new and del functions!
---
switch to / add as an alternative: libffi
X ::= newtype(int); or something
-don't allow while {3; 5} or for 0..10 { 3; 5 } (once break is added)
any odd number of "s for a string
-consider- should #sizeof always take a Type? it would be more verbose, but we might not actually need
- #sizeof that much, given that we have new.
- it probably should, because #sizeof(x[0]) can't be evaluated at compile time if x is not a constant
---
#returns_code (struct body is a block, to be evaluated at compile time, which returns the actual statements)
- struct varargs
diff --git a/parse.c b/parse.c
index 4b95c70..b101afe 100644
--- a/parse.c
+++ b/parse.c
@@ -1437,6 +1437,7 @@ static Status parse_expr(Parser *p, Expression *e, Token *end) {
return false;
}
if (!parse_block(p, &w->body, 0)) return false;
+ w->body.flags |= BLOCK_IS_LOOP;
goto success;
}
case KW_FOR: {
diff --git a/test.toc b/test.toc
index 398f7b7..8103f08 100644
--- a/test.toc
+++ b/test.toc
@@ -6,4 +6,12 @@ main ::= fn() {
io.puti(i);
if i == 7 { break; }
}
+ i := 0;
+ while {
+ i += 1;
+ io.puti(i);
+ if i == 10 {
+ break;
+ }
+ }
}