summaryrefslogtreecommitdiff
path: root/test.toc
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-04-24 17:43:21 -0400
committerLeo Tenenbaum <pommicket@gmail.com>2020-04-24 17:43:21 -0400
commitecf8b49cf99ccf0bf941a2ed9707ee5d43ebf0ad (patch)
tree43638dcef61e96f1ad25c7d3815ebcbca50bb7d2 /test.toc
parent2de90e47312b8a7de69712015590fc7fbd3d9b0a (diff)
improve cgen for loops and allow returning something of unknown type
Diffstat (limited to 'test.toc')
-rw-r--r--test.toc22
1 files changed, 9 insertions, 13 deletions
diff --git a/test.toc b/test.toc
index ed66392..011b5a3 100644
--- a/test.toc
+++ b/test.toc
@@ -1,18 +1,14 @@
#include "std/io.toc";
-
-foo ::= fn() int {
- puts("Hello");
- 3
-}
-
-bar ::= fn() (int, int) {
- foo(), foo()
+c_add ::= fn(x:int, y:int) int {
+ #C("x+y")
}
main ::= fn() {
- _ := 5;
- _ := 6+_;
- _ := foo();
- _,_ := bar();
- _,_ := bar();
+ xs : [5]int;
+ for x, i := &xs {
+ *x = c_add(i*i, i*i*i);
+ }
+ for x := xs {
+ puti(x);
+ }
}