X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=examples%2FcodeGen.spl;h=5008ef9866ce55a6fd513939ada72f4bbd4c90d3;hb=53f1053727e36cb97e9670d1392c6e26848707a5;hp=1f8cbfdbf7e2964a0bcd1c610982bc2af1d64553;hpb=2dfaf554d3b448567e41a140d46a27f6dfb5d901;p=cc1516.git diff --git a/examples/codeGen.spl b/examples/codeGen.spl index 1f8cbfd..5008ef9 100644 --- a/examples/codeGen.spl +++ b/examples/codeGen.spl @@ -1,4 +1,37 @@ +//f(x, y) { +// var ret = 0; +// if (x < y) { +// ret = x; +// } +// else { +// ret = y; +// } +// return ret; +//}// + +//main() { +// Int x1 = 1; +// var x2 = 4; +// var x3 = f(x1, x2); +// print(x1); +// x1 = 5; +// return x3 + x1; +//} + +isE(x) :: [a] -> Bool { + if (x == []) { + return True; + } else { + return False; + } +} + main() { - var x = 3; - return 4 + 2 + x; -} \ No newline at end of file + // [Int] x2 = 0 : x1; + // [Int] x3 = []; + // (Int, Bool) x4 = (4, True); + // //Bool y1 = isEmpty(x2); //gives weird type error, not sure why +// isEmpty(x2); + [Int] x1 = 8 : 2 : []; + return x1.hd; +}