5: #line 144 "./lpsrc/flx_regress.pak"
6:
7:
8: header r"""
9: #include <stdio.h>
10: typedef char *charp;
11: """;
12:
13: typedef bool = 2;
14: type int = "int";
15: type string = "charp";
16:
17: proc print: string = 'printf("%s",$1);';
18: proc print: int = 'printf("%d",$1);';
19:
20: fun sub: int * int -> int = "$1 - $2";
21: fun mul: int * int -> int = "$1 * $2";
22: fun gt: int * int -> bool = "$1 > $2";
23: fun eq: int * int -> bool = "$1 == $2";
24:
25:
26: fun fact(a:int): int =
27: {
28: fun f (a:int, p:int) : int = {
29: return
30: if a>1 then f(a-1, p*a) else p endif;
31: }
32: return f(a,1);
33: }
34:
35:
36: val factc : int -> int = fact of (int);
37: assert (fact 6 == 6 * 5 * 4 * 3 * 2);
38: assert (factc 6 == 6 * 5 * 4 * 3 * 2);
39:
40:
41: proc printer (a:int) { print a; }
42: val printv = printer of (int);
43: printer 10;
44: print "\n";
45: printv 10;
46:
47:
48: struct X = {
49: x : int;
50: y : int;
51: }
52:
53: proc printX (x:X) {
54: print "x=";
55: print x.x;
56: print ", y=";
57: print x.y;
58: print "\n";
59: }
60:
61: val x = X(1,2);
62: printX x;
63:
64:
65: proc t1()
66: {
67: proc print: int = 'printf("int=%d",$1);';
68: print "Not hidden: ";
69: print 1;
70: print " print:int hides outer\n";
71: }
72: t1();
73:
74: module A
75: {
76: proc print:int='printf("module A print int=%d",$1);';
77: print 1;
78: print "\n";
79: }