Add first new language - Maaru

Maaru is intended to be a haskell-ish functional language.
Here's enough of a skeleton to print a thing
This commit is contained in:
greg 2017-01-25 20:09:51 -08:00
parent 421a9a7e9b
commit a303aa2a5b
2 changed files with 53 additions and 0 deletions

51
src/maaru_lang/mod.rs Normal file
View File

@ -0,0 +1,51 @@
use language::{ProgrammingLanguage, EvaluationMachine, ParseError, TokenError, LLVMCodeString};
pub struct Maaru {
}
pub struct MaaruEvaluator {
pub trace_evaluation: bool,
}
#[derive(Debug)]
struct Token { }
#[derive(Debug)]
struct AST { }
impl ProgrammingLanguage<MaaruEvaluator> for Maaru {
type Token = Token;
type AST = AST;
fn tokenize(input: &str) -> Result<Vec<Self::Token>, TokenError> {
Ok(vec![Token { }])
}
fn parse(input: Vec<Self::Token>) -> Result<Self::AST, ParseError> {
Ok(AST { })
}
fn evaluate(ast: Self::AST, evaluator: &mut MaaruEvaluator) -> Vec<String> {
vec!["Unimplemented".to_string()]
}
fn compile(ast: Self::AST) -> LLVMCodeString {
unimplemented!()
}
}
impl EvaluationMachine for MaaruEvaluator {
fn set_option(&mut self, option: &str, value: bool) -> bool {
if option == "trace_evaluation" {
self.trace_evaluation = value;
return true;
}
false
}
fn new() -> MaaruEvaluator {
MaaruEvaluator {
trace_evaluation: false,
}
}
}

View File

@ -12,6 +12,8 @@ mod schala_lang;
use schala_lang::SchalaEvaluator;
use schala_lang::Schala;
mod maaru_lang;
mod language;
use language::{ProgrammingLanguage, LLVMCodeString, EvaluationMachine};