merge zxq5 changes with mine lol

This commit is contained in:
2025-06-19 15:53:55 +01:00
3 changed files with 10 additions and 37 deletions
-30
View File
@@ -305,34 +305,4 @@ impl Parser {
Ok(self.tokens.last().unwrap().clone())
}
}
fn expect(&mut self, type_: TokenType) -> Result<Token, AssembleError> {
let tok = self.next()?;
if TokenType::from_token(&tok) == type_ {
Ok(tok)
} else {
Err(AssembleError::UnexpectedToken(tok, type_))
}
}
fn expect_any(&mut self, types: &[TokenType]) -> Result<Token, AssembleError> {
let tok = self.next()?;
if types.contains(&TokenType::from_token(&tok)) {
Ok(tok)
} else {
Err(AssembleError::UnexpectedToken(tok, types[0]))
}
}
fn maybe_expect(&mut self, types: &[TokenType]) -> Option<Token> {
let tok = self.peek_next().ok()?;
if types.contains(&TokenType::from_token(&tok)) {
Some(tok.clone())
} else {
None
}
}
}