#include #include #include "node.hpp" #include "codegen.hpp" extern int grammarparse( void ); extern NBlock* programBlock; int main( ) { std::cout << "-- lexical analysis" << std::endl; grammarparse( ); std::cout << "-- syntactic analysis and ADT construction" << std::endl << *programBlock << std::endl; CodeGenContext context; std::cout << "-- generating LLVM code" << std::endl; context.generateCode( *programBlock ); std::cout << "-- generated LLVM code" << std::endl; context.printGeneratedCode( ); std::cout << "-- running the LLVM code" << std::endl; llvm::InitializeNativeTarget( ); context.runCode( ); std::ofstream o( "test.llvm" ); std::string code = context.getGeneratedCode( ); o << code; o.flush( ); return 0; }