X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=examples%2FcodeGen.spl;h=ebede23fb7ac9fabfc66b997573cf08522c0d0d6;hb=f081c2c5e248331eb6e2f090f4afe818fd8259eb;hp=9982b4b249e8546798b0370f5526ec8616c7e504;hpb=6758e36a62b15fea8b7505f58b829ff4ff0ba94e;p=cc1516.git diff --git a/examples/codeGen.spl b/examples/codeGen.spl index 9982b4b..ebede23 100644 --- a/examples/codeGen.spl +++ b/examples/codeGen.spl @@ -1,16 +1,36 @@ -f(x) { - Int y = 2; - return 4; +//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() { -// Int x1 = 3; -// Char x2 = '\n'; -// Bool x3 = True; -// (Int, Char) x4 = (4, '\n'); -// [Bool] x5 = True : False : True : True : []; -// [Int] x1 = 42 : []; - Int x1 = 1; - Int x2 = f(x1); - return x1; + [Int] x1 = 1 : 2 : []; + [Int] x2 = 0 : x1; + [Int] x3 = []; + //Bool y1 = isEmpty(x2); //gives weird type error, not sure why + isEmpty(x2); + return; }