better error handling, + "ok" in interpret mode only

This commit is contained in:
psf 2022-03-27 14:38:44 -07:00
parent 0b11491963
commit 182c374117

View file

@ -144,7 +144,10 @@ fn create_d(c: &mut Core) {
create(c, short_name);
c.post = Post::EatWord;
}
_ => {}
_ => {
println!(" create needs an argument");
c.post = Post::WarmReset;
}
}
}
@ -456,6 +459,7 @@ fn outer(c: &mut Core, s: &str) {
Post::WarmReset => {
c.tds = 0;
c.trs = 0;
c.state = State::Interpreting;
break; // discard rest of input line
}
Post::Nothing => { }
@ -468,7 +472,13 @@ fn main() {
loop {
let mut buf = String::new();
match io::stdin().read_line(&mut buf) {
Ok(_) => { outer(&mut c, &buf); println!(" ok");}
Ok(_) => {
outer(&mut c, &buf);
match c.state {
State::Interpreting => {println!(" ok")}
State::Compiling => {}
};
}
Err(_) => { break; }
}
}