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 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<Box<ProgrammingLanguageInterface>> =
vec![
Box::new(schala_lang::Schala::new()),
Box::new(maaru_lang::Maaru::new()),
Box::new(robo_lang::Robo::new()),
/*

View File

@ -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<ASTNode>;
#[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,
}
}
}

View File

@ -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<Vec<Self::Token>, TokenError> {
parsing::tokenize(input)
}
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!()
fn evaluate_in_repl(&mut self, input: &str, eval_options: EvalOptions) -> Vec<String> {
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
}
}