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:
parent
421a9a7e9b
commit
a303aa2a5b
51
src/maaru_lang/mod.rs
Normal file
51
src/maaru_lang/mod.rs
Normal 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,8 @@ mod schala_lang;
|
|||||||
use schala_lang::SchalaEvaluator;
|
use schala_lang::SchalaEvaluator;
|
||||||
use schala_lang::Schala;
|
use schala_lang::Schala;
|
||||||
|
|
||||||
|
mod maaru_lang;
|
||||||
|
|
||||||
mod language;
|
mod language;
|
||||||
use language::{ProgrammingLanguage, LLVMCodeString, EvaluationMachine};
|
use language::{ProgrammingLanguage, LLVMCodeString, EvaluationMachine};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user