1#![warn(missing_docs)]
5
6use std::{fs, path::PathBuf};
7
8mod elf;
9
10mod error;
11use error::{AssemErrorKind, AssemblerError};
12
13mod parse;
14use parse::{BinFormat, Program};
15
16mod text;
17
18#[allow(missing_docs)]
19pub mod prelude;
20
21#[cfg(test)]
22mod tests;
23
24pub fn assemble(srcfile: PathBuf, format: BinFormat) -> Result<Vec<u8>, AssemblerError> {
28 let source = match fs::read_to_string(&srcfile) {
29 Ok(s) => s,
30 Err(_) => return Err(AssemblerError::new(None, AssemErrorKind::FileRead(srcfile))),
31 };
32
33 let mut prog = Program::from_source(source, format)?;
34
35 prog.resolve_symbols()?;
36 prog.encode()
37}