Framework for compilation

This commit is contained in:
greg 2016-03-04 14:32:22 -08:00
parent cd69ebaa9d
commit 6c44d295db
3 changed files with 21 additions and 8 deletions

View File

@ -10,6 +10,12 @@ use self::iron_llvm::{LLVMRef, LLVMRefCtor};
use parser::{ParseResult, AST, ASTNode, Prototype, Function, Expression}; use parser::{ParseResult, AST, ASTNode, Prototype, Function, Expression};
pub fn compile_ast(ast: AST) {
println!("Compiling!");
}
/*
pub struct Context { pub struct Context {
context: core::Context, context: core::Context,
builder: core::Builder, builder: core::Builder,
@ -117,5 +123,4 @@ impl IRBuilder for Expression {
unimplemented!() unimplemented!()
} }
} }
*/

View File

@ -17,6 +17,8 @@ mod parser;
use eval::{Evaluator}; use eval::{Evaluator};
mod eval; mod eval;
use compilation::{compile_ast};
mod compilation;
fn main() { fn main() {
let args: Vec<String> = std::env::args().collect(); let args: Vec<String> = std::env::args().collect();
@ -42,12 +44,18 @@ fn run_noninteractive(filename: &String) {
Err(err) => { println!("Parse error: {:?}", err); return; } Err(err) => { println!("Parse error: {:?}", err); return; }
}; };
let compile = true;
if compile {
compile_ast(ast);
} else {
let mut evaluator = Evaluator::new(); let mut evaluator = Evaluator::new();
let results = evaluator.run(ast); let results = evaluator.run(ast);
for result in results.iter() { for result in results.iter() {
println!("{}", result); println!("{}", result);
} }
} }
}
fn run_repl() { fn run_repl() {
println!("Schala v 0.02"); println!("Schala v 0.02");

View File

@ -1,4 +1,4 @@
let a = 1 a = 1
let b = 2 b = 2
a + b a + b