diff options
author | Dominick Allen <dominick.allen1989@gmail.com> | 2020-06-26 21:12:16 -0500 |
---|---|---|
committer | Dominick Allen <dominick.allen1989@gmail.com> | 2020-06-26 21:12:16 -0500 |
commit | ad9f7e6a689c7fe42444cbe22ecdf1de8d092d5b (patch) | |
tree | f387be46e818cdfafeae36c69a94d09ed1da26f9 /src/main.rs | |
parent | 36e1bf722a3d366cea20ab7315d63d588d23dc48 (diff) |
Evaluate basic arithmetic.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs index 15cf60b..49c916a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,8 @@ pub mod lib; use rustyline::error::ReadlineError; use rustyline::Editor; +use lib::environment::Environment; + fn read<T: rustyline::Helper>(rl: &mut Editor<T>) -> Option<String> { let readline = rl.readline(">> "); match readline { @@ -35,13 +37,12 @@ fn means_exit(input: &str) -> bool { } } -fn eval(env: &mut lib::eval::Env, input: &str) -> String { +fn eval(env: &mut Environment, input: &str) -> String { let sexp = match lib::parse::parse(input) { Ok(x) => x, Err(f) => return f }; - println!("{:?}", sexp); let res = lib::eval::eval(&sexp, env); match res { Ok(x) => format!("{:?}", x), @@ -50,7 +51,7 @@ fn eval(env: &mut lib::eval::Env, input: &str) -> String { } fn main() { - let mut env = lib::eval::Env::new(); + let mut env = Environment::new(); let hist_file = "history.txt"; // `()` can be used when no completer is required |