Initial SFERA platform baseline
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::io::{self, Read};
|
||||
|
||||
use bsl_parser::parse_module;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let source_path = args.get(1).map(String::as_str).unwrap_or("-");
|
||||
let source = match args.get(1) {
|
||||
Some(path) => fs::read_to_string(path).unwrap_or_else(|error| {
|
||||
eprintln!("failed to read {path}: {error}");
|
||||
std::process::exit(2);
|
||||
}),
|
||||
None => {
|
||||
let mut buffer = String::new();
|
||||
io::stdin()
|
||||
.read_to_string(&mut buffer)
|
||||
.unwrap_or_else(|error| {
|
||||
eprintln!("failed to read stdin: {error}");
|
||||
std::process::exit(2);
|
||||
});
|
||||
buffer
|
||||
}
|
||||
};
|
||||
|
||||
let unit = parse_module(source_path, &source);
|
||||
serde_json::to_writer_pretty(io::stdout(), &unit).unwrap_or_else(|error| {
|
||||
eprintln!("failed to serialize parse result: {error}");
|
||||
std::process::exit(2);
|
||||
});
|
||||
println!();
|
||||
}
|
||||
Reference in New Issue
Block a user