#![warn(missing_docs)]
use std::{fs, path::PathBuf};
mod elf;
mod error;
use error::{AssemErrorKind, AssemblerError};
mod parse;
use parse::{BinFormat, Program};
mod text;
#[allow(missing_docs)]
pub mod prelude;
#[cfg(test)]
mod tests;
pub fn assemble(srcfile: PathBuf, format: BinFormat) -> Result<Vec<u8>, AssemblerError> {
let source = match fs::read_to_string(&srcfile) {
Ok(s) => s,
Err(_) => return Err(AssemblerError::new(None, AssemErrorKind::FileRead(srcfile))),
};
let mut prog = Program::from_source(source, format)?;
prog.resolve_symbols()?;
prog.encode()
}