Not working
This commit is contained in:
parent
6d3f5f4b81
commit
1e7e407f00
@ -25,7 +25,7 @@ use std::rc::Rc;
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use schala_repl::{ProgrammingLanguageInterface,
|
use schala_repl::{ProgrammingLanguageInterface, ProgrammingLanguageStages,
|
||||||
ComputationRequest, ComputationResponse,
|
ComputationRequest, ComputationResponse,
|
||||||
LangMetaRequest, LangMetaResponse, GlobalOutputStats,
|
LangMetaRequest, LangMetaResponse, GlobalOutputStats,
|
||||||
DebugResponse, DebugAsk};
|
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 {
|
impl ProgrammingLanguageInterface for Schala {
|
||||||
|
type Stages = SchalaStages;
|
||||||
fn get_language_name(&self) -> String { format!("Schala") }
|
fn get_language_name(&self) -> String { format!("Schala") }
|
||||||
fn get_source_file_suffix(&self) -> String { format!("schala") }
|
fn get_source_file_suffix(&self) -> String { format!("schala") }
|
||||||
|
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
use std::time;
|
use std::time;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
pub trait ProgrammingLanguageStages {
|
||||||
|
fn to_string(&self) -> String;
|
||||||
|
}
|
||||||
|
|
||||||
pub trait ProgrammingLanguageInterface {
|
pub trait ProgrammingLanguageInterface {
|
||||||
|
type Stages : ProgrammingLanguageStages;
|
||||||
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;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ use std::process::exit;
|
|||||||
mod repl;
|
mod repl;
|
||||||
mod language;
|
mod language;
|
||||||
|
|
||||||
pub use language::{ProgrammingLanguageInterface,
|
pub use language::{ProgrammingLanguageInterface, ProgrammingLanguageStages,
|
||||||
ComputationRequest, ComputationResponse,
|
ComputationRequest, ComputationResponse,
|
||||||
LangMetaRequest, LangMetaResponse,
|
LangMetaRequest, LangMetaResponse,
|
||||||
DebugResponse, DebugAsk, GlobalOutputStats};
|
DebugResponse, DebugAsk, GlobalOutputStats};
|
||||||
@ -29,7 +29,7 @@ DebugResponse, DebugAsk, GlobalOutputStats};
|
|||||||
include!(concat!(env!("OUT_DIR"), "/static.rs"));
|
include!(concat!(env!("OUT_DIR"), "/static.rs"));
|
||||||
const VERSION_STRING: &'static str = "0.1.0";
|
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| {
|
let options = command_line_options().parse(std::env::args()).unwrap_or_else(|e| {
|
||||||
println!("{:?}", e);
|
println!("{:?}", e);
|
||||||
exit(1);
|
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 path = Path::new(filename);
|
||||||
let ext = path.extension().and_then(|e| e.to_str()).unwrap_or_else(|| {
|
let ext = path.extension().and_then(|e| e.to_str()).unwrap_or_else(|| {
|
||||||
println!("Source file lacks extension");
|
println!("Source file lacks extension");
|
||||||
|
@ -2,7 +2,7 @@ use std::sync::Arc;
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use colored::*;
|
use colored::*;
|
||||||
use crate::language::{ProgrammingLanguageInterface,
|
use crate::language::{ProgrammingLanguageInterface, ProgrammingLanguageStages,
|
||||||
ComputationRequest, ComputationResponse,
|
ComputationRequest, ComputationResponse,
|
||||||
DebugAsk, LangMetaResponse, LangMetaRequest};
|
DebugAsk, LangMetaResponse, LangMetaRequest};
|
||||||
|
|
||||||
@ -23,12 +23,12 @@ type InterpreterDirectiveOutput = Option<String>;
|
|||||||
pub struct Repl {
|
pub struct Repl {
|
||||||
pub interpreter_directive_sigil: char,
|
pub interpreter_directive_sigil: char,
|
||||||
line_reader: ::linefeed::interface::Interface<::linefeed::terminal::DefaultTerminal>,
|
line_reader: ::linefeed::interface::Interface<::linefeed::terminal::DefaultTerminal>,
|
||||||
language_states: Vec<Box<ProgrammingLanguageInterface>>,
|
language_states: Vec<Box<ProgrammingLanguageInterface<Stages = dyn ProgrammingLanguageStages>>>,
|
||||||
options: ReplOptions,
|
options: ReplOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Repl {
|
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;
|
use linefeed::Interface;
|
||||||
let line_reader = Interface::new("schala-repl").unwrap();
|
let line_reader = Interface::new("schala-repl").unwrap();
|
||||||
let interpreter_directive_sigil = ':';
|
let interpreter_directive_sigil = ':';
|
||||||
@ -113,7 +113,7 @@ impl Repl {
|
|||||||
directives.perform(self, &arguments)
|
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
|
//TODO this is obviously not complete
|
||||||
&mut self.language_states[0]
|
&mut self.language_states[0]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user