From 5103f03fa5748d702a5ff13c08e9792ae7d6a26d Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 23 Jan 2017 11:27:11 -0800 Subject: [PATCH] Forgot to add mod.rs file --- src/schala_lang/mod.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/schala_lang/mod.rs diff --git a/src/schala_lang/mod.rs b/src/schala_lang/mod.rs new file mode 100644 index 0000000..f225c8c --- /dev/null +++ b/src/schala_lang/mod.rs @@ -0,0 +1,28 @@ +pub mod tokenizer; +pub mod parser; +pub mod eval; +pub mod compilation; + +use language::{ProgrammingLanguage, ParseError, TokenError}; + +pub struct Schala { } + +impl<'a> ProgrammingLanguage> for Schala { + type Token = tokenizer::Token; + type AST = parser::AST; + + fn tokenize(input: &str) -> Result, TokenError> { + tokenizer::tokenize(input).map_err(|x| TokenError { msg: x.msg }) + } + + fn parse(input: Vec) -> Result { + parser::parse(&input, &[]).map_err(|x| ParseError { msg: x.msg }) + } + fn evaluate(ast: Self::AST, evaluator: &mut eval::Evaluator) -> Vec { + evaluator.run(ast) + } + fn compile(ast: Self::AST) -> String { + compilation::compile_ast(ast) + } +} +