X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=examples%2FcodeGen.spl;h=77b02a1235fb6a5564b43b30f352c7fb3222c370;hb=c5e89ecf06145895bd8c8bca19e7e0587cfe1082;hp=5b366ba3ca59b54684aa0ee0b04c132b2e2200b2;hpb=a5c9b65860f9af03a7c999f7abd6ab5f12f63523;p=cc1516.git diff --git a/examples/codeGen.spl b/examples/codeGen.spl index 5b366ba..77b02a1 100644 --- a/examples/codeGen.spl +++ b/examples/codeGen.spl @@ -1,16 +1,44 @@ -f(x, y) { - return x; +//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, 2); - f(x1, 2); - return x1; + // [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 : []; + (Bool, Int) z = (True, 2); + var y = z.fst; + var x = (True, 5) : (False,0) : []; + var sdaf = isE(x1); + var z = isEmpty(x1); + Char c = read(); + x.hd.snd = 8; + return; }