Add basic 1-iteration repl

This commit is contained in:
Richard Feldman 2020-04-18 15:32:04 -04:00
parent d4a45ed489
commit 73fbc0e490
2 changed files with 620 additions and 1 deletions

View file

@ -2,7 +2,6 @@ extern crate roc_gen;
extern crate roc_reporting;
#[macro_use]
extern crate clap;
use bumpalo::Bump;
use inkwell::context::Context;
use inkwell::module::Linkage;
@ -32,6 +31,8 @@ use target_lexicon::{Architecture, OperatingSystem, Triple, Vendor};
use tokio::process::Command;
use tokio::runtime::Builder;
pub mod repl;
pub static FLAG_OPTIMIZE: &str = "optimize";
pub static FLAG_ROC_FILE: &str = "ROC_FILE";
@ -66,6 +67,9 @@ pub fn build_app<'a>() -> App<'a> {
.required(false),
)
)
.subcommand(App::new("repl")
.about("Launch the interactive Read Eval Print Loop (REPL)")
)
}
fn main() -> io::Result<()> {
@ -74,10 +78,12 @@ fn main() -> io::Result<()> {
match matches.subcommand_name() {
Some("build") => build(matches.subcommand_matches("build").unwrap(), false),
Some("run") => build(matches.subcommand_matches("run").unwrap(), true),
Some("repl") => repl::main(),
_ => unreachable!(),
}
}
pub fn build(matches: &ArgMatches, run_after_build: bool) -> io::Result<()> {
let filename = matches.value_of(FLAG_ROC_FILE).unwrap();
let opt_level = if matches.is_present(FLAG_OPTIMIZE) {