Clean up warnings, update next_body, add more tests

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2020-05-08 16:19:01 -04:00
parent 378bcef40b
commit e233ff1cfc
4 changed files with 95 additions and 85 deletions

View File

@@ -3,9 +3,7 @@ mod syn;
use std::{
convert::TryFrom,
fs,
io::{stdout, Write},
path::{Path, PathBuf},
process,
path::PathBuf,
};
use structopt::StructOpt;
@@ -34,35 +32,7 @@ fn main() -> Result<()> {
let opt = Options::from_args();
let text = fs::read_to_string(&opt.input)?;
let parser = Parser::try_from(text.as_str())?;
/*
let object = assemble::assemble_path(&opt.input)?;
if opt.compile_only {
let outfile = opt.out.clone().unwrap_or_else(|| {
let mut outfile = opt.input.clone();
assert!(outfile.set_extension("obj"));
outfile
});
let bytes = object.to_bytes();
let mut writer = get_writer(&outfile)?;
writer.write(&bytes)?;
Ok(())
} else if opt.disassemble {
let outfile = opt
.out
.as_ref()
.map(|p| p.as_path())
.unwrap_or_else(|| Path::new("-"));
let mut writer = get_writer(&outfile)?;
object.disasm(&mut writer)?;
Ok(())
} else {
let mut state = State::new();
state.load_object(object, opt.max_mem.unwrap_or(DEFAULT_MAX_MEM))?;
let status = state.exec()?;
process::exit((status & 0xffff_ffff) as i32);
}
*/
let mut parser = Parser::try_from(text.as_str())?;
println!("{:#?}", parser.next_body()?);
Ok(())
}