sponge_lib/
lib.rs

1pub mod decompose_tokens;
2pub mod parse_tokens;
3pub mod generate_asm;
4
5use clap::{Arg, Command};
6use std::fs;
7
8pub fn run() {
9    let matches = Command::new("sponge-build")
10        .version("0.2.0")
11        .about("A powerful rust module to convert Rust to ASM")
12        .arg(Arg::new("input")
13            .short('i')
14            .long("input")
15            .value_parser(clap::value_parser!(String))
16            .required(true)
17            .help("Sets the input file"))
18        .arg(Arg::new("output")
19            .short('o')
20            .long("output")
21            .value_parser(clap::value_parser!(String))
22            .required(true)
23            .help("Sets the output file"))
24        .get_matches();
25
26    let input = matches.get_one::<String>("input").expect("Input file is required");
27    let output = matches.get_one::<String>("output").expect("Output file is required");
28
29    // Read the input file
30    let input_content = fs::read_to_string(input).expect("Failed to read the input file");
31
32    // Decompose the input content into tokens
33    let tokens = decompose_tokens::decompose(&input_content).expect("Failed to decompose tokens");
34
35    // Parse the tokens
36    let parsed_tokens = parse_tokens::parse(tokens);
37
38    // Generate ASM code
39    let asm_code = generate_asm::generate(&parsed_tokens);
40
41    // Write the ASM code to the output file
42    fs::write(output, asm_code).expect("Failed to write the output file");
43}