#![warn(missing_docs)]
#![allow(clippy::needless_doctest_main)]
pub mod commands;
pub mod intermediate_build;
pub mod parse;
use intermediate_build::generate_final_code;
pub use intermediate_build::CodegenConfig;
use parse::{find_file, parse_input, ParseOutput};
use std::io::Error;
pub fn generate_code(
input_file: Option<&str>,
codegen_cfg: &CodegenConfig,
) -> Result<ParseOutput, Error> {
println!("cargo:rerun-if-changed=build.rs");
let found_input = find_file(input_file)?;
let literate_rust_code = parse_input(found_input)?;
generate_final_code(&literate_rust_code.extractions, codegen_cfg).map(|_| literate_rust_code)
}
pub fn generate_default_code(input_file: &str) -> Result<ParseOutput, Error> {
generate_code(Some(input_file), &CodegenConfig::default())
}
pub fn generate_yin_code(input_file: &str) -> Result<ParseOutput, Error> {
generate_code(
Some(input_file),
&CodegenConfig {
yin: true,
..CodegenConfig::default()
},
)
}
#[macro_export]
macro_rules! warn {
($warning:tt) => (println!("{}", colored::Colorize::bold(colored::Colorize::yellow($warning))));
($($arg:tt)*) => ({
println!("{}", colored::Colorize::bold(colored::Colorize::yellow(format!($($arg)*).as_str())));
})
}