summaryrefslogtreecommitdiff
path: root/tests/params.toc
blob: 4d37cf170a58baae3fb63ba3d47c4607c8326f7f (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
33
34
35
36
37
38
39
40
addmul ::= fn (x:=0, y:=0) add := x+y, mul := x*y {
};

do_foo ::= fn (x := 3) y := x {
	   y *= 12;
	   y += x;
};

puti ::= fn(x: int) {
	 #C("#ifndef __TINYC__
extern int printf(const char *fmt, ...);
#endif
");
	 #C("printf(\"%ld\\n\", x);");
};


main ::= fn() {
	 a, m := addmul();
	 puti(a); puti(m);
	 a, m = addmul(7,3);
	 puti(a); puti(m);
	 a, m = addmul(5);
	 puti(a); puti(m);
	 a, m = addmul(y = 17);
	 puti(a); puti(m);

	 c, d ::= addmul();
	 puti(c); puti(d);
	 e, f ::= addmul(y = 3, x = 7);
	 puti(e); puti(f);
	 

	 z := do_foo();
	 puti(z);
	 z = do_foo(-1);
	 puti(z);
	 z = do_foo(x = -1);
	 puti(z);
};