forked from AbleOS/holey-bytes
fixed label handling
This commit is contained in:
parent
059e2b4b66
commit
c7b5512ada
|
@ -128,7 +128,7 @@ pub fn assembly(code: &str, buf: &mut Vec<u8>) -> Result<(), Error> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Ok(Token::Label(lbl))) => {
|
Some(Ok(Token::Label(lbl))) => {
|
||||||
self.label_map.insert(lbl, self.buf.len() as u64 + 1);
|
self.label_map.insert(lbl, self.buf.len() as u64);
|
||||||
}
|
}
|
||||||
Some(Ok(Token::ISep)) => (),
|
Some(Ok(Token::ISep)) => (),
|
||||||
Some(Ok(_)) => return Err(ErrorKind::UnexpectedToken),
|
Some(Ok(_)) => return Err(ErrorKind::UnexpectedToken),
|
||||||
|
|
|
@ -6,7 +6,7 @@ use {
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut prog = vec![];
|
let mut prog = vec![];
|
||||||
stdin().read_to_end(&mut prog)?;
|
stdin().read_to_end(&mut prog)?;
|
||||||
|
|
||||||
if let Err(e) = validate(&prog) {
|
if let Err(e) = validate(&prog) {
|
||||||
eprintln!("Program validation error: {e:?}");
|
eprintln!("Program validation error: {e:?}");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
Loading…
Reference in a new issue