Returns an error appropriate for an unexpected token.
(&self, token: &Token)
| 109 | |
| 110 | /// Returns an error appropriate for an unexpected token. |
| 111 | pub fn unexpected_token_error(&self, token: &Token) -> ParseError { |
| 112 | let kind = match token { |
| 113 | Token::CloseBracket => ParseErrorKind::UnexpectedCloseBracket, |
| 114 | Token::CloseBrace => ParseErrorKind::UnexpectedCloseBrace, |
| 115 | Token::Comma => ParseErrorKind::UnexpectedComma, |
| 116 | Token::Colon => ParseErrorKind::UnexpectedColon, |
| 117 | Token::Word(_) => ParseErrorKind::UnexpectedWord, |
| 118 | _ => ParseErrorKind::UnexpectedToken, |
| 119 | }; |
| 120 | self.scanner.create_error_for_current_token(kind) |
| 121 | } |
| 122 | |
| 123 | /// Scans the next object entry (key or close brace), handling commas |
| 124 | /// between entries. Pass `first = true` for the first entry. |
no test coverage detected