summaryrefslogtreecommitdiff
path: root/test.toc
blob: 566aed9ec7b4becc9aae3de90428123db0a26867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
puti ::= fn(x: int) {
	 #C("printf(\"%ld\\n\", (long)x);
");
};
putf ::= fn(x: float) {
	 #C("printf(\"%f\\n\", (double)x);
");
};

SuperArray ::= fn(n :: int, t :: Type) Type {
	  struct {
	  		 data: [n]t;
			 field : t;
	  }
};

checksum ::= fn(t ::=, n ::=, x:SuperArray(n,t)) t {
		 total := 0 as t;
		 each i := 0..n-1 {
		 	  total += x.data[i];
		 }
		 total + x.field
};

Super ::= SuperArray(3, int);

main ::= fn() {
x: Super;
x.data[0] = 3;
x.field = 1932;
puti(checksum(x));
};