MAL Step 0
This commit is contained in:
commit
ac87083777
4 changed files with 51 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
@ -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"
|
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
|
@ -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]
|
35
src/main.rs
Normal file
35
src/main.rs
Normal file
|
@ -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()
|
||||||
|
}
|
Loading…
Reference in a new issue