21 lines
554 B
Rust
21 lines
554 B
Rust
use std::{env::args, fs};
|
|
|
|
use microlang::{Context, Value};
|
|
|
|
pub fn main() {
|
|
unsafe { backtrace_on_stack_overflow::enable() };
|
|
let mut context = Context::empty();
|
|
context.define_built("print", |values, _| {
|
|
for val in values {
|
|
print!("{} ", val.serialize());
|
|
}
|
|
println!();
|
|
Ok(Value::None)
|
|
});
|
|
|
|
let lines = fs::read_to_string(args().nth(1).expect("Pass a file as arg 1.")).expect("File could not be read.");
|
|
match context.eval(lines) {
|
|
Err(err) => panic!("Failed : {err:?}"),
|
|
Ok((_, value)) => println!("{}", value.serialize()),
|
|
}
|
|
}
|