From abdd56ebc0e01cd92f694ef2bcafcc394453d055 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sat, 25 Oct 2014 11:42:07 -0500 Subject: Rust: step0_repl and step1_read_print --- rust/src/step0_repl.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 rust/src/step0_repl.rs (limited to 'rust/src/step0_repl.rs') diff --git a/rust/src/step0_repl.rs b/rust/src/step0_repl.rs new file mode 100644 index 0000000..ac9cf24 --- /dev/null +++ b/rust/src/step0_repl.rs @@ -0,0 +1,25 @@ +use readline::mal_readline; +mod readline; + +// read +fn read(str: String) -> String { + str +} + +// eval +fn eval(ast: String) -> String { + ast +} + +// print +fn print(exp: String) -> String { + exp +} + +fn main() { + loop { + let line = mal_readline("user> "); + match line { None => break, _ => () } + println!("{}", print(eval(read(line.unwrap())))); + } +} -- cgit v1.2.3