fixed labels, added comments

wip/its-not-my-fault
ondra05 2023-06-09 13:33:17 +02:00
parent 8b823baff3
commit 60df2a0109
1 changed files with 2 additions and 0 deletions

View File

@ -14,6 +14,7 @@ macro_rules! tokendef {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Logos)]
#[logos(extras = Rodeo)]
#[logos(skip r"[ \t\f]+")]
#[logos(skip r"-- .*")]
pub enum Token {
$(#[token($opcode, |_| hbbytecode::opcode::[<$opcode:upper>])])*
OpCode(u8),
@ -130,6 +131,7 @@ pub fn assembly(code: &str, buf: &mut Vec<u8>) -> Result<(), Error> {
Some(Ok(Token::Label(lbl))) => {
self.lblmap.insert(lbl, self.buf.len() as u64 + 1);
}
Some(Ok(Token::ISep)) => (),
Some(Ok(_)) => return Err(ErrorKind::UnexpectedToken),
Some(Err(())) => return Err(ErrorKind::InvalidToken),
None => return Ok(()),