added some type checking stuff. vardecl now works for basictypes and unary operators
[cc1516.git] / examples / example.spl
index ee36ff3..e71c216 100644 (file)
@@ -2,10 +2,14 @@
        Three ways to implement the f acto rial function in SPL.
        First the recursive version .
 */
-var r = 1;
-var facN = 1;
-var ok = True;
-
+Int r = 1;
+Char r = 1;
+Int r = -1;
+Void r = 0;
+Bool r = !True;
+Bool r = -True;
+//var facN = 1;
+//var ok = True;
 
 facR(n) :: Int -> Int {
        if (n < 2) {
@@ -15,6 +19,7 @@ facR(n) :: Int -> Int {
        }
 }
 
+
 //The iterative version of the factorial function
 facl ( n ) :: Int -> Int {
        var r = 1;
@@ -48,7 +53,7 @@ facL (n) :: Int -> Int {
 }
 
 //Generates a list of integers from the first to the last argument
-fromTo (from, to) :: Int  Int -> [Int] {
+fromTo (from, to) :: Int -> Int -> [Int] {
        if(from <= to){
                return from:fromTo(from+1, to);
        } else {
@@ -78,7 +83,7 @@ swap(tuple) :: (a, a) -> (a, a){
 }
 
 //list append
-append(l1, l2) :: [t] [t] -> [t] {
+append(l1, l2) :: [t] -> [t] -> [t] {
        if(isEmpty(l1)){
                return l2;
        } else {