MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / scan_array_comma

Method scan_array_comma

src/parser.rs:192–208  ·  view source on GitHub ↗

After an array element, scans for the comma/close-bracket and returns the next token.

(&mut self)

Source from the content-addressed store, hash-verified

190 /// After an array element, scans for the comma/close-bracket and
191 /// returns the next token.
192 pub fn scan_array_comma(&mut self) -> Result<Option<Token<'a>>, ParseError> {
193 let token = self.scan()?;
194 if matches!(&token, Some(Token::Comma)) {
195 let comma_range = Range::new(self.scanner.token_start(), self.scanner.token_end());
196 let next = self.scan()?;
197 if matches!(&next, Some(Token::CloseBracket)) && !self.allow_trailing_commas {
198 return Err(
199 self
200 .scanner
201 .create_error_for_range(comma_range, ParseErrorKind::TrailingCommasNotAllowed),
202 );
203 }
204 Ok(next)
205 } else {
206 Ok(token)
207 }
208 }
209
210 fn scan_object_key(&mut self) -> Result<Option<ObjectKey<'a>>, ParseError> {
211 match self.scan()? {

Callers 3

parse_arrayFunction · 0.80
drain_arrayFunction · 0.80
next_element_seedMethod · 0.80

Calls 4

token_startMethod · 0.80
token_endMethod · 0.80
scanMethod · 0.45

Tested by

no test coverage detected