Eat the current token if its of the expected kind, otherwise adds an appropriate error.
(&mut self, expected: TokenKind)
| 650 | |
| 651 | /// Eat the current token if its of the expected kind, otherwise adds an appropriate error. |
| 652 | fn expect(&mut self, expected: TokenKind) -> bool { |
| 653 | if self.eat(expected) { |
| 654 | return true; |
| 655 | } |
| 656 | |
| 657 | self.add_error( |
| 658 | ParseErrorType::ExpectedToken { |
| 659 | found: self.current_token_kind(), |
| 660 | expected, |
| 661 | }, |
| 662 | self.current_token_range(), |
| 663 | ); |
| 664 | |
| 665 | false |
| 666 | } |
| 667 | |
| 668 | fn add_error<T>(&mut self, error: ParseErrorType, ranged: T) |
| 669 | where |