MCPcopy
hub / github.com/TomWright/dasel / readMultiLineString

Method readMultiLineString

parsing/kdl/internal/tokenizer.go:556–581  ·  view source on GitHub ↗
(line, col int)

Source from the content-addressed store, hash-verified

554}
555
556func (t *Tokenizer) readMultiLineString(line, col int) (Token, error) {
557 var sb strings.Builder
558 for {
559 if t.pos >= len(t.input) {
560 return Token{}, t.error("unterminated multi-line string")
561 }
562 ch := t.peek()
563 if ch == '"' && t.peekAt(1) == '"' && t.peekAt(2) == '"' {
564 t.advance()
565 t.advance()
566 t.advance()
567 content := dedentMultiLineString(sb.String())
568 return Token{Type: TokenMultiLineString, Value: content, Line: line, Col: col}, nil
569 }
570 ch = t.advance()
571 if ch == '\\' {
572 escaped, err := t.readEscape()
573 if err != nil {
574 return Token{}, err
575 }
576 sb.WriteString(escaped)
577 } else {
578 sb.WriteRune(ch)
579 }
580 }
581}
582
583// dedentMultiLineString removes common leading whitespace from multi-line strings.
584// The last line's whitespace determines the indentation to strip.

Callers 1

readQuotedStringMethod · 0.95

Calls 7

errorMethod · 0.95
peekMethod · 0.95
peekAtMethod · 0.95
advanceMethod · 0.95
readEscapeMethod · 0.95
dedentMultiLineStringFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected