commit ac87083777ff876d571fa4a42aa85fb16a3d0ef9 Author: Roman Godmaire Date: Tue Sep 12 07:21:51 2023 -0400 MAL Step 0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d4213ed --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "mal" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..647a9a7 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "mal" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..24a3688 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,35 @@ +use std::io::{self, Write}; + +fn main() { + let mut input = String::new(); + + println!("MAL -- REPL"); + + loop { + print!("> "); + io::stdout().flush().expect("failed to write to stdout"); + + let bytes_read = io::stdin() + .read_line(&mut input) + .expect("failed to read from stdin"); + + if bytes_read == 0 { + break; + } + + let ast = read(&input); + let res = eval(&ast); + + println!("{res}"); + + input.clear(); + } +} + +fn read(input: &str) -> String { + input.to_owned() +} + +fn eval(input: &str) -> String { + input.to_owned() +}