summaryrefslogtreecommitdiff
path: root/test.toc
diff options
context:
space:
mode:
Diffstat (limited to 'test.toc')
-rw-r--r--test.toc54
1 files changed, 14 insertions, 40 deletions
diff --git a/test.toc b/test.toc
index a999512..143dc0b 100644
--- a/test.toc
+++ b/test.toc
@@ -7,45 +7,19 @@ putf ::= fn(x: float) {
");
};
-// it would be nice if Arr.data.len == Arr.len (: but this will require some C code...
-Arr ::= fn (t :: Type) Type {
- struct {
- data : []t;
- len, cap : int;
- }
-};
-
-arr_add ::= fn(t :: Type, a : &Arr(t), x : t) {
- if a.len >= a.cap {
- a.cap = a.cap * 2 + 2;
- new_data := new(t, a.cap);
- each i := 0..a.len-1 {
- new_data[i] = a.data[i];
- }
- a.data = new_data;
- }
- a.data[a.len] = x;
- a.len += 1;
-};
-
-
-ArrInt ::= Arr(int);
+main ::= fn() {
+ puti(f(3));
+ puti(f(7));
+ puti(f(3,4));
-inc ::= fn(t :: Type, x : t) t {
- x + 1
-};
+// TODO: semiconst breaks this for some reason
+ f ::= fn(x :: int, y := x) int { y };
-main ::= fn() {
- arr : ArrInt;
- farr : Arr(float);
- each i := 1..100 {
- arr_add(int, &arr, inc(int, i*i));
- arr_add(float, &farr, inc(float, (i*i) as float));
- }
- each i := 0..arr.len - 1 {
- puti(arr.data[i]);
- }
- each i := 0..farr.len - 1 {
- putf(farr.data[i]);
- }
-};
+ r ::= f(3);
+ puti(r);
+ s ::= f(7);
+ puti(s);
+ t ::= f(3,4);
+ puti(t);
+
+}; \ No newline at end of file