Super simple janky input
This commit is contained in:
parent
9e393d2753
commit
bd8bf1945c
@ -1,5 +1,6 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
use std::io;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ impl<'a> State<'a> {
|
|||||||
let mut values = StateStack::new(Some(format!("global")));
|
let mut values = StateStack::new(Some(format!("global")));
|
||||||
builtin_binding!("print", values);
|
builtin_binding!("print", values);
|
||||||
builtin_binding!("println", values);
|
builtin_binding!("println", values);
|
||||||
|
builtin_binding!("getline", values);
|
||||||
State { values }
|
State { values }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,6 +412,11 @@ impl<'a> State<'a> {
|
|||||||
println!("{}", anything.to_repl());
|
println!("{}", anything.to_repl());
|
||||||
Expr::Unit
|
Expr::Unit
|
||||||
},
|
},
|
||||||
|
("getline", &[]) => {
|
||||||
|
let mut buf = String::new();
|
||||||
|
io::stdin().read_line(&mut buf).expect("Error readling line in 'getline'");
|
||||||
|
Lit(StringLit(Rc::new(buf)))
|
||||||
|
},
|
||||||
_ => return Err(format!("Runtime error: bad or unimplemented builtin")),
|
_ => return Err(format!("Runtime error: bad or unimplemented builtin")),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user