organic/src/main.rs

33 lines
1023 B
Rust
Raw Normal View History

2023-03-23 23:35:32 +00:00
#![feature(round_char_boundary)]
2023-03-25 15:27:38 +00:00
use crate::parser::document;
2022-11-25 22:54:26 +00:00
use tracing_subscriber::fmt::format::FmtSpan;
2023-03-27 19:08:29 +00:00
use tracing_subscriber::EnvFilter;
2022-07-16 03:26:49 +00:00
mod parser;
const TEST_DOC: &'static str = include_str!("../toy_language.txt");
fn main() -> Result<(), Box<dyn std::error::Error>> {
2023-03-27 19:08:29 +00:00
init_telemetry()?;
let parsed = document(TEST_DOC);
println!("{}\n\n\n", TEST_DOC);
println!("{:#?}", parsed);
Ok(())
}
fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
let env_filter = EnvFilter::try_from_default_env().unwrap_or(EnvFilter::new("WARN"));
let format = tracing_subscriber::fmt::format()
2023-03-27 19:08:29 +00:00
.pretty()
.with_file(true)
.with_line_number(true)
.with_thread_ids(false)
.with_target(false);
let subscriber = tracing_subscriber::fmt()
.event_format(format)
2022-11-25 22:54:26 +00:00
.with_span_events(FmtSpan::ENTER | FmtSpan::EXIT)
2023-03-27 19:08:29 +00:00
.with_env_filter(env_filter)
.finish();
tracing::subscriber::set_global_default(subscriber)?;
2022-07-16 03:26:49 +00:00
Ok(())
}