Eat the current token if its of the expected kind, otherwise adds an appropriate error.
(&mut self, expected: TokenKind)
| 605 | |
| 606 | /// Eat the current token if its of the expected kind, otherwise adds an appropriate error. |
| 607 | fn expect(&mut self, expected: TokenKind) -> bool { |
| 608 | if self.eat(expected) { |
| 609 | return true; |
| 610 | } |
| 611 | |
| 612 | self.add_error( |
| 613 | ParseErrorType::ExpectedToken { |
| 614 | found: self.current_token_kind(), |
| 615 | expected, |
| 616 | }, |
| 617 | self.current_token_range(), |
| 618 | ); |
| 619 | |
| 620 | false |
| 621 | } |
| 622 | |
| 623 | fn add_error<T>(&mut self, error: ParseErrorType, ranged: T) |
| 624 | where |