equal
  deleted
  inserted
  replaced
  
    
    
|      1 // A Small LLVM Compiler for a Simple Functional Language |      1 // A Small LLVM Compiler for a Simple Functional Language | 
|      2 // (includes an external lexer and parser) |      2 // (includes a lexer and parser) | 
|      3 // |      3 // | 
|      4 // |      4 // | 
|      5 // call with  |      5 // call with  | 
|      6 // |      6 // | 
|      7 //     amm fun_llvm.sc main fact.fun |      7 //     amm fun_llvm.sc main fact.fun | 
|     39 //    llc -filetype=obj in_file.ll |     39 //    llc -filetype=obj in_file.ll | 
|     40 //    gcc in_file.o -o a.out |     40 //    gcc in_file.o -o a.out | 
|     41 //    ./a.out |     41 //    ./a.out | 
|     42  |     42  | 
|     43  |     43  | 
|     44 //> using toolkit 0.5.0 |     44 // > using toolkit 0.5.0 | 
|     45 // > using file fun_tokens.scala |     45 // > using file fun_tokens.scala | 
|     46 // > using file fun_parser.scala |     46 // > using file fun_parser.scala | 
|     47  |     47  | 
|     48 //import $file.fun_tokens, fun_tokens._ |     48 import $file.fun_tokens, fun_tokens._ | 
|     49 //import $file.fun_parser, fun_parser._  |     49 import $file.fun_parser, fun_parser._  | 
|     50  |     50  | 
|     51  |     51  | 
|     52 // for generating new labels |     52 // for generating new labels | 
|     53 var counter = -1 |     53 var counter = -1 | 
|     54  |     54  | 
|    141     CPS(e)(y => KLet(z, KWrite(y), k(KVar(z)))) |    141     CPS(e)(y => KLet(z, KWrite(y), k(KVar(z)))) | 
|    142   } |    142   } | 
|    143 }    |    143 }    | 
|    144  |    144  | 
|    145 //initial continuation |    145 //initial continuation | 
|    146 def CPSi(e: Exp) = CPS(e)(KReturn) |    146 def CPSi(e: Exp) = CPS(e)(KReturn(_)) | 
|    147  |    147  | 
|    148  |    148  | 
|    149  |    149  | 
|    150 //some testcases: |    150 //some testcases: | 
|    151 // (1 + 2) * 3 |    151 // (1 + 2) * 3 |