Converted Robo to new style trait
This commit is contained in:
parent
7a6dfbbd0e
commit
14ccf9f1be
@ -31,10 +31,10 @@ fn main() {
|
||||
let languages: Vec<Box<ProgrammingLanguageInterface>> =
|
||||
vec![
|
||||
Box::new(maaru_lang::Maaru::new()),
|
||||
Box::new(robo_lang::Robo::new()),
|
||||
/*
|
||||
Box::new((schala_lang::Schala::new(), schala_lang::SchalaEvaluator::new())),
|
||||
Box::new((maaru_lang::Maaru::new(), maaru_lang::MaaruEvaluator::new(None))),
|
||||
Box::new((robo_lang::Robo::new(), robo_lang::RoboEvaluator::new())),
|
||||
*/
|
||||
];
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
extern crate itertools;
|
||||
use self::itertools::Itertools;
|
||||
|
||||
use language::{ProgrammingLanguage, EvaluationMachine, ParseError, TokenError, LLVMCodeString};
|
||||
use language::{ProgrammingLanguageInterface, EvalOptions, ProgrammingLanguage, EvaluationMachine, ParseError, TokenError, LLVMCodeString};
|
||||
|
||||
pub struct Robo {
|
||||
}
|
||||
@ -56,16 +56,7 @@ pub enum Expression {
|
||||
|
||||
}
|
||||
|
||||
impl ProgrammingLanguage for Robo {
|
||||
type Token = Token;
|
||||
type AST = AST;
|
||||
type Evaluator = RoboEvaluator;
|
||||
|
||||
fn name() -> String {
|
||||
"Robo".to_string()
|
||||
}
|
||||
|
||||
fn tokenize(input: &str) -> Result<Vec<Self::Token>, TokenError> {
|
||||
fn tokenize(input: &str) -> Result<Vec<Token>, TokenError> {
|
||||
use self::Token::*;
|
||||
let mut tokens = Vec::new();
|
||||
let mut iter = input.chars().peekable();
|
||||
@ -140,14 +131,23 @@ impl ProgrammingLanguage for Robo {
|
||||
Ok(tokens)
|
||||
}
|
||||
|
||||
fn parse(_input: Vec<Self::Token>) -> Result<Self::AST, ParseError> {
|
||||
Ok(vec!())
|
||||
impl ProgrammingLanguageInterface for Robo {
|
||||
fn get_language_name(&self) -> String {
|
||||
"Robo".to_string()
|
||||
}
|
||||
fn evaluate(_ast: Self::AST, _evaluator: &mut Self::Evaluator) -> Vec<String> {
|
||||
vec!["Unimplemented".to_string()]
|
||||
|
||||
fn evaluate_in_repl(&mut self, input: &str, eval_options: EvalOptions) -> Vec<String> {
|
||||
let mut output = vec!();
|
||||
let tokens = match tokenize(input) {
|
||||
Ok(tokens) => tokens,
|
||||
Err(e) => {
|
||||
output.push(format!("Tokenize error: {:?}", e));
|
||||
return output;
|
||||
}
|
||||
fn compile(_ast: Self::AST) -> LLVMCodeString {
|
||||
unimplemented!()
|
||||
};
|
||||
|
||||
output.push(format!("{:?}", tokens));
|
||||
output
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user