1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#![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);
Ok(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()
},
)
}