MCPcopy Create free account
hub / github.com/agenticsorg/lean-agentic / lex_string

Method lex_string

leanr-syntax/src/lexer.rs:349–372  ·  view source on GitHub ↗

Lex a string literal

(&mut self)

Source from the content-addressed store, hash-verified

347
348 /// Lex a string literal
349 fn lex_string(&mut self) -> TokenKind {
350 self.advance(); // Skip opening "
351 let start = self.pos;
352
353 while !self.is_eof() && self.current_char() != '"' {
354 if self.current_char() == '\\' {
355 self.advance(); // Skip escape char
356 if !self.is_eof() {
357 self.advance(); // Skip escaped char
358 }
359 } else {
360 self.advance();
361 }
362 }
363
364 if self.is_eof() {
365 return TokenKind::Error("Unterminated string".to_string());
366 }
367
368 let text = self.source.content[start..self.pos].to_string();
369 self.advance(); // Skip closing "
370
371 TokenKind::String(text)
372 }
373
374 /// Lex a line comment
375 fn lex_line_comment(&mut self) -> TokenKind {

Callers 1

next_tokenMethod · 0.80

Calls 4

ErrorEnum · 0.85
current_charMethod · 0.80
advanceMethod · 0.45
is_eofMethod · 0.45

Tested by

no test coverage detected