Not working

This commit is contained in:
greg 2019-06-21 01:59:04 -07:00
parent 6d3f5f4b81
commit 1e7e407f00
4 changed files with 22 additions and 8 deletions

View File

@ -25,7 +25,7 @@ use std::rc::Rc;
use std::collections::HashSet;
use itertools::Itertools;
use schala_repl::{ProgrammingLanguageInterface,
use schala_repl::{ProgrammingLanguageInterface, ProgrammingLanguageStages,
ComputationRequest, ComputationResponse,
LangMetaRequest, LangMetaResponse, GlobalOutputStats,
DebugResponse, DebugAsk};
@ -259,8 +259,17 @@ fn stage_names() -> Vec<&'static str> {
]
}
pub enum SchalaStages {
Something
}
impl ProgrammingLanguageStages {
fn to_string() -> String {
format!("DUMMY")
}
}
impl ProgrammingLanguageInterface for Schala {
type Stages = SchalaStages;
fn get_language_name(&self) -> String { format!("Schala") }
fn get_source_file_suffix(&self) -> String { format!("schala") }

View File

@ -1,7 +1,12 @@
use std::time;
use std::collections::HashSet;
pub trait ProgrammingLanguageStages {
fn to_string(&self) -> String;
}
pub trait ProgrammingLanguageInterface {
type Stages : ProgrammingLanguageStages;
fn get_language_name(&self) -> String;
fn get_source_file_suffix(&self) -> String;

View File

@ -21,7 +21,7 @@ use std::process::exit;
mod repl;
mod language;
pub use language::{ProgrammingLanguageInterface,
pub use language::{ProgrammingLanguageInterface, ProgrammingLanguageStages,
ComputationRequest, ComputationResponse,
LangMetaRequest, LangMetaResponse,
DebugResponse, DebugAsk, GlobalOutputStats};
@ -29,7 +29,7 @@ DebugResponse, DebugAsk, GlobalOutputStats};
include!(concat!(env!("OUT_DIR"), "/static.rs"));
const VERSION_STRING: &'static str = "0.1.0";
pub fn start_repl(langs: Vec<Box<dyn ProgrammingLanguageInterface>>) {
pub fn start_repl(langs: Vec<Box<dyn ProgrammingLanguageInterface<Stages = dyn ProgrammingLanguageStages>>>) {
let options = command_line_options().parse(std::env::args()).unwrap_or_else(|e| {
println!("{:?}", e);
exit(1);
@ -51,7 +51,7 @@ pub fn start_repl(langs: Vec<Box<dyn ProgrammingLanguageInterface>>) {
};
}
fn run_noninteractive(filename: &str, languages: Vec<Box<ProgrammingLanguageInterface>>) {
fn run_noninteractive(filename: &str, languages: Vec<Box<ProgrammingLanguageInterface<Stages = dyn ProgrammingLanguageStages>>>) {
let path = Path::new(filename);
let ext = path.extension().and_then(|e| e.to_str()).unwrap_or_else(|| {
println!("Source file lacks extension");

View File

@ -2,7 +2,7 @@ use std::sync::Arc;
use std::collections::HashSet;
use colored::*;
use crate::language::{ProgrammingLanguageInterface,
use crate::language::{ProgrammingLanguageInterface, ProgrammingLanguageStages,
ComputationRequest, ComputationResponse,
DebugAsk, LangMetaResponse, LangMetaRequest};
@ -23,12 +23,12 @@ type InterpreterDirectiveOutput = Option<String>;
pub struct Repl {
pub interpreter_directive_sigil: char,
line_reader: ::linefeed::interface::Interface<::linefeed::terminal::DefaultTerminal>,
language_states: Vec<Box<ProgrammingLanguageInterface>>,
language_states: Vec<Box<ProgrammingLanguageInterface<Stages = dyn ProgrammingLanguageStages>>>,
options: ReplOptions,
}
impl Repl {
pub fn new(initial_states: Vec<Box<ProgrammingLanguageInterface>>) -> Repl {
pub fn new(initial_states: Vec<Box<ProgrammingLanguageInterface<Stages = dyn ProgrammingLanguageStages>>>) -> Repl {
use linefeed::Interface;
let line_reader = Interface::new("schala-repl").unwrap();
let interpreter_directive_sigil = ':';
@ -113,7 +113,7 @@ impl Repl {
directives.perform(self, &arguments)
}
fn get_cur_language_state(&mut self) -> &mut Box<ProgrammingLanguageInterface> {
fn get_cur_language_state(&mut self) -> &mut Box<ProgrammingLanguageInterface<Stages = dyn ProgrammingLanguageStages>> {
//TODO this is obviously not complete
&mut self.language_states[0]
}