use endbasic_core::{
ast::Value,
exec::{Machine, StopReason},
syms::Symbol,
};
use futures_lite::future::block_on;
const INPUT: &str = r#"
foo_value = 123
enable_bar = (foo_value > 122)
'enable_baz = "this is commented out"
"#;
fn main() {
let mut machine = Machine::default();
loop {
match block_on(machine.exec(&mut INPUT.as_bytes())).expect("Execution error") {
StopReason::Eof => break,
StopReason::Exited(i) => println!("Script explicitly exited with code {}", i),
StopReason::Break => (), }
}
match machine.get_symbols().get_auto("foo_value") {
Some(Symbol::Variable(Value::Integer(i))) => {
println!("foo_value is {}", i)
}
_ => println!("Input did not contain foo_value or is of an invalid type"),
}
match machine.get_symbols().get_auto("enable_bar") {
Some(Symbol::Variable(Value::Boolean(b))) => {
println!("enable_bar is {}", b)
}
_ => println!("Input did not contain enable_bar or is of an invalid type"),
}
match machine.get_symbols().get_auto("enable_baz") {
Some(_) => {
println!("enable_baz should not have been set")
}
_ => println!("enable_baz is not set"),
}
}