spl/src/main.rs

27 lines
971 B
Rust
Raw Normal View History

2023-08-04 20:38:47 +02:00
use spl::{find_in_splpath, lex, oxidizer::RustAppBuilder, start_file};
2023-02-17 22:47:45 +01:00
2023-08-04 20:38:47 +02:00
use std::{env::args, fs};
2023-02-17 20:00:39 +01:00
2023-02-25 11:37:07 +01:00
fn main() {
2023-08-04 20:38:47 +02:00
let mut args = args().skip(1);
let arg = &args
.next()
.unwrap_or_else(|| find_in_splpath("repl.spl").expect("no file to be run"));
if arg == "--build" {
let file = args.next().unwrap();
let data = fs::read_to_string(file.clone()).expect("unable to read specified file");
println!("Building SPL with specified natives file...");
let mut builder = RustAppBuilder::new();
println!("Embedding source...");
builder.add_source(file, data.to_owned());
println!("Preparing rust code...");
builder.prepare(lex(data.to_owned()).expect("invalid SPL in natives file."));
println!("Building...");
println!("Built! Binary is {}", builder.build().unwrap().get_binary());
return;
}
if let Err(x) = start_file(arg) {
2023-02-25 11:37:07 +01:00
println!("{x:?}");
}
2023-02-17 20:00:39 +01:00
}