From 4b13fef734ff6c0586710f66b340c2d6b214d21d Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 31 Aug 2017 14:57:56 -0700 Subject: [PATCH] More cleanup --- src/main.rs | 3 ++- src/robo_lang/mod.rs | 27 ++++++--------------------- src/schala_lang/mod.rs | 36 +++++------------------------------- 3 files changed, 13 insertions(+), 53 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5e4a65a..774084b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,7 +20,7 @@ mod maaru_lang; mod robo_lang; mod language; -use language::{ProgrammingLanguage, LanguageInterface, ProgrammingLanguageInterface, EvalOptions, LLVMCodeString, EvaluationMachine}; +use language::{ProgrammingLanguage, LanguageInterface, ProgrammingLanguageInterface, EvalOptions, LLVMCodeString}; mod llvm_wrap; @@ -30,6 +30,7 @@ use virtual_machine::{run_vm, run_assembler}; fn main() { let languages: Vec> = vec![ + Box::new(schala_lang::Schala::new()), Box::new(maaru_lang::Maaru::new()), Box::new(robo_lang::Robo::new()), /* diff --git a/src/robo_lang/mod.rs b/src/robo_lang/mod.rs index 7d17de1..2fa9a0d 100644 --- a/src/robo_lang/mod.rs +++ b/src/robo_lang/mod.rs @@ -1,7 +1,7 @@ extern crate itertools; use self::itertools::Itertools; -use language::{ProgrammingLanguageInterface, EvalOptions, ProgrammingLanguage, EvaluationMachine, ParseError, TokenError, LLVMCodeString}; +use language::{ProgrammingLanguageInterface, EvalOptions, ProgrammingLanguage, ParseError, TokenError, LLVMCodeString}; pub struct Robo { } @@ -12,10 +12,7 @@ impl Robo { } } -pub struct RoboEvaluator { - pub trace_evaluation: bool, -} - +#[allow(dead_code)] #[derive(Debug)] pub enum Token { StrLiteral(String), @@ -37,20 +34,24 @@ pub enum Token { NumLiteral(Number), } +#[allow(dead_code)] #[derive(Debug)] pub enum Number { IntegerRep(String), FloatRep(String) } +#[allow(dead_code)] pub type AST = Vec; +#[allow(dead_code)] #[derive(Debug)] pub enum ASTNode { FunctionDefinition(String, Expression), ImportStatement(String), } +#[allow(dead_code)] #[derive(Debug)] pub enum Expression { @@ -151,19 +152,3 @@ impl ProgrammingLanguageInterface for Robo { } } -impl EvaluationMachine for RoboEvaluator { - fn set_option(&mut self, option: &str, value: bool) -> bool { - if option == "trace_evaluation" { - self.trace_evaluation = value; - return true; - } - - false - } - - fn new() -> RoboEvaluator { - RoboEvaluator { - trace_evaluation: false, - } - } -} diff --git a/src/schala_lang/mod.rs b/src/schala_lang/mod.rs index 2c09692..62fdbb3 100644 --- a/src/schala_lang/mod.rs +++ b/src/schala_lang/mod.rs @@ -1,4 +1,4 @@ -use language::{ProgrammingLanguage, EvaluationMachine, ParseError, TokenError, LLVMCodeString}; +use language::{ProgrammingLanguageInterface, EvalOptions, ParseError, TokenError, LLVMCodeString}; mod parsing; @@ -11,38 +11,12 @@ impl Schala { } } -impl ProgrammingLanguage for Schala { - type Token = parsing::Token; - type AST = parsing::AST; - type Evaluator = SchalaEvaluator; - - fn name() -> String { +impl ProgrammingLanguageInterface for Schala { + fn get_language_name(&self) -> String { "Schala".to_string() } - fn tokenize(input: &str) -> Result, TokenError> { - parsing::tokenize(input) - } - fn parse(input: Vec) -> Result { - unimplemented!() - } - fn evaluate(ast: Self::AST, evaluator: &mut Self::Evaluator) -> Vec { - unimplemented!() - } - fn compile(ast: Self::AST) -> LLVMCodeString { - unimplemented!() + fn evaluate_in_repl(&mut self, input: &str, eval_options: EvalOptions) -> Vec { + vec!(format!("evaluation")) } } - -pub struct SchalaEvaluator { } - -impl EvaluationMachine for SchalaEvaluator { - fn new() -> SchalaEvaluator { - SchalaEvaluator { } - } - fn set_option(&mut self, option: &str, value: bool) -> bool { - false - } -} - -