X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=examples%2FcodeGen.spl;h=ebede23fb7ac9fabfc66b997573cf08522c0d0d6;hb=f081c2c5e248331eb6e2f090f4afe818fd8259eb;hp=658ea6e3384e6d0523b299766cb34404fa9ed433;hpb=c922c4eb59493bbc73add331a348230978d0d036;p=cc1516.git diff --git a/examples/codeGen.spl b/examples/codeGen.spl index 658ea6e..ebede23 100644 --- a/examples/codeGen.spl +++ b/examples/codeGen.spl @@ -1,7 +1,36 @@ -f() { - return 2; +//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 1 + 2 + x + f(); + [Int] x1 = 1 : 2 : []; + [Int] x2 = 0 : x1; + [Int] x3 = []; + //Bool y1 = isEmpty(x2); //gives weird type error, not sure why + isEmpty(x2); + return; }