From a303aa2a5bb6551d18c63b7a31ee2e67e38e0ed4 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 25 Jan 2017 20:09:51 -0800 Subject: [PATCH] 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 --- src/maaru_lang/mod.rs | 51 +++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 2 ++ 2 files changed, 53 insertions(+) create mode 100644 src/maaru_lang/mod.rs diff --git a/src/maaru_lang/mod.rs b/src/maaru_lang/mod.rs new file mode 100644 index 0000000..2d7d7be --- /dev/null +++ b/src/maaru_lang/mod.rs @@ -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 for Maaru { + type Token = Token; + type AST = AST; + + fn tokenize(input: &str) -> Result, TokenError> { + Ok(vec![Token { }]) + } + + fn parse(input: Vec) -> Result { + Ok(AST { }) + } + fn evaluate(ast: Self::AST, evaluator: &mut MaaruEvaluator) -> Vec { + 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, + } + } +} diff --git a/src/main.rs b/src/main.rs index 9df9144..469ace8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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};