More misc changes including edition 2018

This commit is contained in:
greg 2019-03-12 02:39:25 -07:00
parent 981d4f88bf
commit 8d8d7d8bf8
5 changed files with 44 additions and 15 deletions

View File

@ -2,6 +2,7 @@
name = "schala-repl"
version = "0.1.0"
authors = ["greg <greg.shuflin@protonmail.com>"]
edition = "2018"
[dependencies]
llvm-sys = "70.0.2"

View File

@ -25,14 +25,37 @@ mod repl;
mod language;
mod webapp;
pub fn start_repl() {
include!(concat!(env!("OUT_DIR"), "/static.rs"));
const VERSION_STRING: &'static str = "0.1.0";
pub fn start_repl(langs: Vec<Box<dyn ProgrammingLanguageInterface>>) {
let command_line_options = command_line_options().parse(std::env::args()).unwrap_or_else(|e| {
println!("{:?}", e);
exit(1);
});
if command_line_options.opt_present("help") {
println!("{}", program_options().usage("Schala metainterpreter"));
exit(0);
}
let mut repl = repl::NewRepl::new();
repl.run_repl();
}
const VERSION_STRING: &'static str = "0.1.0";
fn command_line_options() -> getopts::Options {
let mut options = getopts::Options::new();
options.optflag("h",
"help",
"Show help text");
options.optflag("w",
"webapp",
"Start up web interpreter");
options
}
include!(concat!(env!("OUT_DIR"), "/static.rs"));
/* --------------------------- */
pub use language::{ProgrammingLanguageInterface, EvalOptions,
ExecutionMethod, TraceArtifact, FinishedComputation, UnfinishedComputation, PassDebugOptionsDescriptor, PassDescriptor};

View File

@ -5,7 +5,7 @@ use std::sync::Arc;
use colored::*;
use itertools::Itertools;
use language::{ProgrammingLanguageInterface, EvalOptions,
use crate::language::{ProgrammingLanguageInterface, EvalOptions,
PassDebugOptionsDescriptor};
mod command_tree;
use self::command_tree::CommandTree;
@ -30,13 +30,16 @@ impl NewRepl {
}
pub fn run_repl(&mut self) {
println!("Schala MetaInterpreter version {}", ::VERSION_STRING);
self.line_reader.load_history(HISTORY_SAVE_FILE).unwrap_or(());
println!("Schala MetaInterpreter version {}", crate::VERSION_STRING);
println!("Type {}help for help with the REPL", self.interpreter_directive_sigil);
self.line_reader.load_history(HISTORY_SAVE_FILE).unwrap_or(());
self.handle_repl_loop();
self.line_reader.save_history(HISTORY_SAVE_FILE).unwrap_or(());
self.save_options();
println!("Exiting...");
}
@ -50,8 +53,7 @@ impl NewRepl {
println!("readline IO Error: {}", e);
break;
},
Ok(Eof) => break,
Ok(Signal(_)) => break,
Ok(Eof) | Ok(Signal(_)) => break,
Ok(Input(ref input)) => {
self.line_reader.add_history_unique(input.to_string());
let output = match input.chars().nth(0) {
@ -158,7 +160,7 @@ impl Repl {
pub fn run(&mut self) {
use linefeed::ReadResult;
println!("Schala MetaInterpreter version {}", ::VERSION_STRING);
println!("Schala MetaInterpreter version {}", crate::VERSION_STRING);
println!("Type {}help for help with the REPL", self.interpreter_directive_sigil);
self.line_reader.load_history(HISTORY_SAVE_FILE).unwrap_or(());

View File

@ -3,9 +3,9 @@ use rocket::State;
use rocket::response::Content;
use rocket::http::ContentType;
use rocket_contrib::json::Json;
use language::{ProgrammingLanguageInterface, EvalOptions};
use WEBFILES;
use ::PLIGenerator;
use crate::language::{ProgrammingLanguageInterface, EvalOptions};
use crate::WEBFILES;
use crate::PLIGenerator;
#[get("/")]
fn index() -> Content<String> {

View File

@ -4,18 +4,21 @@ extern crate maaru_lang;
extern crate rukka_lang;
extern crate robo_lang;
extern crate schala_lang;
use schala_repl::{PLIGenerator, repl_main, start_repl};
use schala_repl::{PLIGenerator, ProgrammingLanguageInterface, repl_main, start_repl};
extern { }
fn main() {
/*
let generators: Vec<PLIGenerator> = vec![
Box::new(|| { Box::new(schala_lang::Schala::new())}),
Box::new(|| { Box::new(maaru_lang::Maaru::new())}),
Box::new(|| { Box::new(robo_lang::Robo::new())}),
Box::new(|| { Box::new(rukka_lang::Rukka::new())}),
];
//repl_main(generators);
start_repl();
repl_main(generators);
*/
let langs: Vec<Box<ProgrammingLanguageInterface>> = vec![Box::new(schala_lang::Schala::new())];
start_repl(langs);
}