cl-repl: hack together some temporary file loading, to aid in standard library development
This commit is contained in:
parent
862d81a9d4
commit
e9dc8a7e32
@ -225,6 +225,18 @@ pub mod cli {
|
|||||||
fn from(value: Args) -> Self {
|
fn from(value: Args) -> Self {
|
||||||
let Args { path, repl, mode } = value;
|
let Args { path, repl, mode } = value;
|
||||||
match (repl, path) {
|
match (repl, path) {
|
||||||
|
(true, Some(path)) => {
|
||||||
|
let prog = std::fs::read_to_string(path).unwrap();
|
||||||
|
let code = conlang::parser::Parser::new(conlang::lexer::Lexer::new(&prog))
|
||||||
|
.file()
|
||||||
|
.unwrap();
|
||||||
|
let mut env = conlang::interpreter::env::Environment::new();
|
||||||
|
env.eval(&code).unwrap();
|
||||||
|
env.call("dump", &[])
|
||||||
|
.expect("calling dump in the environment shouldn't fail");
|
||||||
|
|
||||||
|
Self::Repl(Repl { mode, env, ..Default::default() })
|
||||||
|
}
|
||||||
(_, Some(path)) => Self::File { mode, path },
|
(_, Some(path)) => Self::File { mode, path },
|
||||||
(true, None) => Self::Repl(Repl { mode, ..Default::default() }),
|
(true, None) => Self::Repl(Repl { mode, ..Default::default() }),
|
||||||
(false, None) => Self::Stdin { mode },
|
(false, None) => Self::Stdin { mode },
|
||||||
|
Loading…
Reference in New Issue
Block a user