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

Method parse_comment_block

src/scanner.rs:314–333  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

312 }
313
314 fn parse_comment_block(&mut self) -> Result<Token<'a>, ParseError> {
315 debug_assert!(self.bytes[self.byte_index] == b'/');
316 self.byte_index += 1;
317 debug_assert!(self.bytes[self.byte_index] == b'*');
318 let start_byte_index = self.byte_index + 1;
319 self.byte_index += 1;
320
321 // scan byte-by-byte for */; both are ASCII and safe to scan through UTF-8
322 loop {
323 match self.bytes.get(self.byte_index) {
324 Some(&b'*') if self.bytes.get(self.byte_index + 1) == Some(&b'/') => {
325 let end_byte_index = self.byte_index;
326 self.byte_index += 2;
327 return Ok(Token::CommentBlock(&self.file_text[start_byte_index..end_byte_index]));
328 }
329 Some(_) => self.byte_index += 1,
330 None => return Err(self.create_error_for_current_token(ParseErrorKind::UnterminatedCommentBlock)),
331 }
332 }
333 }
334
335 fn skip_whitespace(&mut self) {
336 while let Some(&b) = self.bytes.get(self.byte_index) {

Callers 1

scanMethod · 0.80

Calls 3

CommentBlockClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected