MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / read_string

Method read_string

atomic-core/src/diff/token/tokenizer.rs:440–464  ·  view source on GitHub ↗

Read a string literal token.

(&mut self, quote: u8)

Source from the content-addressed store, hash-verified

438
439 /// Read a string literal token.
440 fn read_string(&mut self, quote: u8) -> Token<'a> {
441 let start = self.position;
442 self.advance(); // consume opening quote
443
444 while let Some(b) = self.peek() {
445 if b == quote {
446 self.advance(); // consume closing quote
447 break;
448 } else if b == b'\\' {
449 self.advance(); // consume backslash
450 self.advance(); // consume escaped char
451 } else if Self::is_newline(b) {
452 // Unterminated string - stop at newline
453 break;
454 } else {
455 self.advance();
456 }
457 }
458
459 Token::new(
460 &self.content[start..self.position],
461 TokenKind::String,
462 start,
463 )
464 }
465
466 /// Read a single-line comment token.
467 fn read_comment(&mut self) -> Token<'a> {

Callers 1

nextMethod · 0.80

Calls 2

advanceMethod · 0.45
peekMethod · 0.45

Tested by

no test coverage detected