Rename ReplOutput -> LanguageOutput

This commit is contained in:
greg 2018-03-07 22:07:13 -08:00
parent 35c67f73c3
commit 2e80045750
7 changed files with 21 additions and 17 deletions

View File

@ -16,12 +16,12 @@ pub struct EvalOptions {
}
#[derive(Debug, Default)]
pub struct ReplOutput {
pub struct LanguageOutput {
output: String,
artifacts: Vec<TraceArtifact>
}
impl ReplOutput {
impl LanguageOutput {
pub fn add_artifact(&mut self, artifact: TraceArtifact) {
self.artifacts.push(artifact);
}
@ -90,7 +90,7 @@ impl TraceArtifact {
}
pub trait ProgrammingLanguageInterface {
fn evaluate_in_repl(&mut self, input: &str, eval_options: &EvalOptions) -> ReplOutput;
fn evaluate_in_repl(&mut self, input: &str, eval_options: &EvalOptions) -> LanguageOutput;
fn get_language_name(&self) -> String;
fn get_source_file_suffix(&self) -> String;
fn compile(&mut self, _input: &str) -> LLVMCodeString {

View File

@ -32,7 +32,7 @@ pub mod llvm_wrap;
include!(concat!(env!("OUT_DIR"), "/static.rs"));
pub use language::{ProgrammingLanguageInterface, EvalOptions, ReplOutput, TraceArtifact, LLVMCodeString};
pub use language::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, LanguageOutput, LLVMCodeString};
pub type PLIGenerator = Box<Fn() -> Box<ProgrammingLanguageInterface> + Send + Sync>;
pub fn schala_main(generators: Vec<PLIGenerator>) {
@ -110,7 +110,9 @@ fn run_noninteractive(filename: &str, languages: Vec<Box<ProgrammingLanguageInte
compilation_sequence(llvm_bytecode, filename);
}
} else {
language.evaluate_in_repl(&buffer, &options);
let output = language.evaluate_in_repl(&buffer, &options);
// if output.has_error....
}
}

View File

@ -6,3 +6,5 @@ fn main() {
print(main())
const xxx

View File

@ -3,7 +3,7 @@ pub mod parser;
pub mod eval;
pub mod compilation;
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, ReplOutput, TraceArtifact, LLVMCodeString};
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, LanguageOutput, TraceArtifact, LLVMCodeString};
#[derive(Debug)]
pub struct TokenError {
@ -38,8 +38,8 @@ impl<'a> ProgrammingLanguageInterface for Maaru<'a> {
format!("maaru")
}
fn evaluate_in_repl(&mut self, input: &str, options: &EvalOptions) -> ReplOutput {
let mut output = ReplOutput::default();
fn evaluate_in_repl(&mut self, input: &str, options: &EvalOptions) -> LanguageOutput {
let mut output = LanguageOutput::default();
let tokens = match tokenizer::tokenize(input) {
Ok(tokens) => {

View File

@ -1,5 +1,5 @@
use itertools::Itertools;
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, ReplOutput};
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, LanguageOutput};
pub struct Robo {
}
@ -150,8 +150,8 @@ impl ProgrammingLanguageInterface for Robo {
format!("robo")
}
fn evaluate_in_repl(&mut self, input: &str, _eval_options: &EvalOptions) -> ReplOutput {
let mut output = ReplOutput::default();
fn evaluate_in_repl(&mut self, input: &str, _eval_options: &EvalOptions) -> LanguageOutput {
let mut output = LanguageOutput::default();
let tokens = match tokenize(input) {
Ok(tokens) => tokens,
Err(e) => {

View File

@ -1,5 +1,5 @@
use itertools::Itertools;
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, ReplOutput};
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, LanguageOutput};
use std::iter::Peekable;
use std::vec::IntoIter;
use std::str::Chars;
@ -68,8 +68,8 @@ impl ProgrammingLanguageInterface for Rukka {
format!("rukka")
}
fn evaluate_in_repl(&mut self, input: &str, _eval_options: &EvalOptions) -> ReplOutput {
let mut output = ReplOutput::default();
fn evaluate_in_repl(&mut self, input: &str, _eval_options: &EvalOptions) -> LanguageOutput {
let mut output = LanguageOutput::default();
let sexps = match read(input) {
Err(err) => {
output.add_output(format!("Error: {}", err));

View File

@ -1,5 +1,5 @@
use itertools::Itertools;
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, ReplOutput};
use schala_lib::{ProgrammingLanguageInterface, EvalOptions, TraceArtifact, LanguageOutput};
macro_rules! bx {
($e:expr) => { Box::new($e) }
@ -37,8 +37,8 @@ impl ProgrammingLanguageInterface for Schala {
format!("schala")
}
fn evaluate_in_repl(&mut self, input: &str, options: &EvalOptions) -> ReplOutput {
let mut output = ReplOutput::default();
fn evaluate_in_repl(&mut self, input: &str, options: &EvalOptions) -> LanguageOutput {
let mut output = LanguageOutput::default();
let tokens = tokenizing::tokenize(input);
if options.debug_tokens {
let token_string = tokens.iter().map(|t| format!("{:?}<L:{},C:{}>", t.token_type, t.offset.0, t.offset.1)).join(", ");