merge zxq5 changes with mine lol
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user