72 lines
1.5 KiB
Rust
72 lines
1.5 KiB
Rust
#![feature(slice_take)]
|
|
#![allow(special_module_name)]
|
|
|
|
use std::{
|
|
fs::{self, File},
|
|
io::Write,
|
|
};
|
|
|
|
use rlisp_library::{
|
|
Environ,
|
|
Expr::{self, Bool},
|
|
RispError, default_env, parse_eval,
|
|
};
|
|
|
|
mod packages;
|
|
mod environ;
|
|
use environ::extend_environ;
|
|
|
|
fn main() {
|
|
let env = &mut default_env();
|
|
let env = &mut extend_environ(env.clone());
|
|
// let env = &mut
|
|
|
|
let cfg = include_str!("../assets/system.rl");
|
|
|
|
let mut complete_exprs: Vec<String> = vec![];
|
|
let mut left_parens = 0;
|
|
let mut idx_of_first_left_paran = 0;
|
|
|
|
for (i, character) in cfg.chars().enumerate() {
|
|
if character == '(' {
|
|
if left_parens == 0 {
|
|
idx_of_first_left_paran = i;
|
|
}
|
|
left_parens += 1
|
|
}
|
|
|
|
if character == ')' {
|
|
left_parens -= 1;
|
|
if left_parens == 0 {
|
|
let idx_of_last_right_paran = i + 1;
|
|
|
|
complete_exprs
|
|
.push(cfg[idx_of_first_left_paran..idx_of_last_right_paran].to_string());
|
|
}
|
|
}
|
|
}
|
|
|
|
if left_parens != 0 {
|
|
panic!("unmatched parens. Good luck finding them!");
|
|
}
|
|
|
|
// TODO: Mount the disk image here.
|
|
|
|
for expr in complete_exprs {
|
|
match parse_eval(expr, env) {
|
|
Ok(_res) => {}
|
|
Err(e) => {
|
|
panic!("{:?}", e)
|
|
}
|
|
}
|
|
}
|
|
|
|
let path = format!("out/system/config.rl");
|
|
|
|
let mut file = File::create(path).unwrap();
|
|
|
|
let _ = file.write_all(cfg.as_bytes());
|
|
|
|
// TODO: unmount the disk image here.
|
|
}
|