schala/src/schala_lang/mod.rs

29 lines
778 B
Rust
Raw Normal View History

2017-01-23 11:27:11 -08:00
pub mod tokenizer;
pub mod parser;
pub mod eval;
pub mod compilation;
2017-01-23 19:11:50 -08:00
use language::{ProgrammingLanguage, ParseError, TokenError, LLVMCodeString};
2017-01-23 11:27:11 -08:00
pub struct Schala { }
impl<'a> ProgrammingLanguage<eval::Evaluator<'a>> for Schala {
type Token = tokenizer::Token;
type AST = parser::AST;
fn tokenize(input: &str) -> Result<Vec<Self::Token>, TokenError> {
2017-01-23 19:45:26 -08:00
tokenizer::tokenize(input)
2017-01-23 11:27:11 -08:00
}
fn parse(input: Vec<Self::Token>) -> Result<Self::AST, ParseError> {
parser::parse(&input, &[]).map_err(|x| ParseError { msg: x.msg })
}
fn evaluate(ast: Self::AST, evaluator: &mut eval::Evaluator) -> Vec<String> {
evaluator.run(ast)
}
2017-01-23 19:11:50 -08:00
fn compile(ast: Self::AST) -> LLVMCodeString {
2017-01-23 11:27:11 -08:00
compilation::compile_ast(ast)
}
}