Bail out if the current token is not an expected token, or consume it if it is
(&mut self, expected: &Token)
| 1946 | |
| 1947 | /// Bail out if the current token is not an expected token, or consume it if it is |
| 1948 | fn expect_token(&mut self, expected: &Token) -> Result<(), ParserError> { |
| 1949 | if self.consume_token(expected) { |
| 1950 | Ok(()) |
| 1951 | } else { |
| 1952 | self.expected(self.peek_pos(), expected, self.peek_token()) |
| 1953 | } |
| 1954 | } |
| 1955 | |
| 1956 | /// Bail out if the current token is not one of the expected tokens, or consume it if it is |
| 1957 | fn expect_one_of_tokens(&mut self, tokens: &[Token]) -> Result<Token, ParserError> { |
no test coverage detected