add serialization of values

This commit is contained in:
Matthieu Jolimaitre 2024-10-24 06:03:40 +02:00
parent da82c775db
commit 6350e4a40f
5 changed files with 87 additions and 26 deletions

15
example/run.rs Normal file
View file

@ -0,0 +1,15 @@
use std::{env::args, fs};
use microlang::Context;
pub fn main() {
unsafe { backtrace_on_stack_overflow::enable() };
let mut context = Context::empty();
let lines = fs::read_to_string(args().nth(1).expect("Pass a file as arg 1.")).expect("File could not be read.");
for line in lines.lines() {
match context.eval(line.into()) {
Err(err) => panic!("Failed : {err:?}"),
Ok((_, value)) => println!("{}", value.serialize()),
}
}
}