lily/src/main.cpp

23 lines
802 B
C++
Raw Normal View History

2019-06-04 20:45:06 -07:00
#include "ast.hpp"
#include "pattern.hpp"
#include "parser.hpp"
#include "gmachine.hpp"
#include "llvm.hpp"
2019-06-04 20:45:06 -07:00
int main() {
try {
lily::program_ptr prog = lily::parse(
2019-06-12 08:35:12 -07:00
"data IntPair = { MkPair(Int, Int) }\n"
"data IntList = { Nil, Cons(Int, IntList) }"
"defn fst p = { case p of { MkPair(a, b) -> { a } } }\n"
"defn snd p = { case p of { MkPair(a, b) -> { b } } }\n"
"defn sum l = { case l of { Nil -> { 0 } Cons(x, xs) -> { x + sum xs } } }\n"
"defn main = { let tl1 = { Cons 1 Nil } in { let tl2 = { Cons 2 tl1 } in { let tl3 = { Cons 3 tl2 } in { sum tl3 } } } }"
);
prog->gen_llvm();
2019-06-04 20:45:06 -07:00
} catch(lily::error& e) {
std::cout << e.message << std::endl;
}
}