diff options
Diffstat (limited to 'test.toc')
-rw-r--r-- | test.toc | 27 |
1 files changed, 21 insertions, 6 deletions
@@ -7,11 +7,26 @@ putf ::= fn(x: float) { "); }; -main ::= fn() { - Integer ::= id(int); - x : Integer; - puti(foo(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 }; -id ::= fn(t ::=, x :: t) t { x }; -foo ::= fn(t ::=, x : id(t)) int { 3 as t }; +Super ::= SuperArray(3, int); + +main ::= fn() { +x: Super; +x.data[0] = 3; +x.field = 1932; +puti(checksum(x)); +}; |