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)] #[derive(Debug, Default)]
pub struct ReplOutput { pub struct LanguageOutput {
output: String, output: String,
artifacts: Vec<TraceArtifact> artifacts: Vec<TraceArtifact>
} }
impl ReplOutput { impl LanguageOutput {
pub fn add_artifact(&mut self, artifact: TraceArtifact) { pub fn add_artifact(&mut self, artifact: TraceArtifact) {
self.artifacts.push(artifact); self.artifacts.push(artifact);
} }
@ -90,7 +90,7 @@ impl TraceArtifact {
} }
pub trait ProgrammingLanguageInterface { 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_language_name(&self) -> String;
fn get_source_file_suffix(&self) -> String; fn get_source_file_suffix(&self) -> String;
fn compile(&mut self, _input: &str) -> LLVMCodeString { fn compile(&mut self, _input: &str) -> LLVMCodeString {

View File

@ -32,7 +32,7 @@ pub mod llvm_wrap;
include!(concat!(env!("OUT_DIR"), "/static.rs")); 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 type PLIGenerator = Box<Fn() -> Box<ProgrammingLanguageInterface> + Send + Sync>;
pub fn schala_main(generators: Vec<PLIGenerator>) { 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); compilation_sequence(llvm_bytecode, filename);
} }
} else { } 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()) print(main())
const xxx

View File

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

View File

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

View File

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

View File

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