More cleanup

This commit is contained in:
greg 2017-08-31 14:57:56 -07:00
parent 14ccf9f1be
commit 4b13fef734
3 changed files with 13 additions and 53 deletions

View File

@ -20,7 +20,7 @@ mod maaru_lang;
mod robo_lang; mod robo_lang;
mod language; mod language;
use language::{ProgrammingLanguage, LanguageInterface, ProgrammingLanguageInterface, EvalOptions, LLVMCodeString, EvaluationMachine}; use language::{ProgrammingLanguage, LanguageInterface, ProgrammingLanguageInterface, EvalOptions, LLVMCodeString};
mod llvm_wrap; mod llvm_wrap;
@ -30,6 +30,7 @@ use virtual_machine::{run_vm, run_assembler};
fn main() { fn main() {
let languages: Vec<Box<ProgrammingLanguageInterface>> = let languages: Vec<Box<ProgrammingLanguageInterface>> =
vec![ vec![
Box::new(schala_lang::Schala::new()),
Box::new(maaru_lang::Maaru::new()), Box::new(maaru_lang::Maaru::new()),
Box::new(robo_lang::Robo::new()), Box::new(robo_lang::Robo::new()),
/* /*

View File

@ -1,7 +1,7 @@
extern crate itertools; extern crate itertools;
use self::itertools::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 { pub struct Robo {
} }
@ -12,10 +12,7 @@ impl Robo {
} }
} }
pub struct RoboEvaluator { #[allow(dead_code)]
pub trace_evaluation: bool,
}
#[derive(Debug)] #[derive(Debug)]
pub enum Token { pub enum Token {
StrLiteral(String), StrLiteral(String),
@ -37,20 +34,24 @@ pub enum Token {
NumLiteral(Number), NumLiteral(Number),
} }
#[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
pub enum Number { pub enum Number {
IntegerRep(String), IntegerRep(String),
FloatRep(String) FloatRep(String)
} }
#[allow(dead_code)]
pub type AST = Vec<ASTNode>; pub type AST = Vec<ASTNode>;
#[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
pub enum ASTNode { pub enum ASTNode {
FunctionDefinition(String, Expression), FunctionDefinition(String, Expression),
ImportStatement(String), ImportStatement(String),
} }
#[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
pub enum Expression { 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,
}
}
}

View File

@ -1,4 +1,4 @@
use language::{ProgrammingLanguage, EvaluationMachine, ParseError, TokenError, LLVMCodeString}; use language::{ProgrammingLanguageInterface, EvalOptions, ParseError, TokenError, LLVMCodeString};
mod parsing; mod parsing;
@ -11,38 +11,12 @@ impl Schala {
} }
} }
impl ProgrammingLanguage for Schala { impl ProgrammingLanguageInterface for Schala {
type Token = parsing::Token; fn get_language_name(&self) -> String {
type AST = parsing::AST;
type Evaluator = SchalaEvaluator;
fn name() -> String {
"Schala".to_string() "Schala".to_string()
} }
fn tokenize(input: &str) -> Result<Vec<Self::Token>, TokenError> { fn evaluate_in_repl(&mut self, input: &str, eval_options: EvalOptions) -> Vec<String> {
parsing::tokenize(input) vec!(format!("evaluation"))
}
fn parse(input: Vec<Self::Token>) -> Result<Self::AST, ParseError> {
unimplemented!()
}
fn evaluate(ast: Self::AST, evaluator: &mut Self::Evaluator) -> Vec<String> {
unimplemented!()
}
fn compile(ast: Self::AST) -> LLVMCodeString {
unimplemented!()
} }
} }
pub struct SchalaEvaluator { }
impl EvaluationMachine for SchalaEvaluator {
fn new() -> SchalaEvaluator {
SchalaEvaluator { }
}
fn set_option(&mut self, option: &str, value: bool) -> bool {
false
}
}