MCPcopy Create free account
hub / github.com/Effect-TS/effect / parseLiteralString

Method parseLiteralString

packages/effect/src/encoding/Toml.ts:389–414  ·  view source on GitHub ↗
(multiline: boolean)

Source from the content-addressed store, hash-verified

387 }
388
389 private parseLiteralString(multiline: boolean): string {
390 this.expect("'")
391 if (multiline) {
392 this.expect("'")
393 this.expect("'")
394 this.advance(this.input.startsWith("\r\n", this.index) ? 2 : this.peek() === "\n" ? 1 : 0)
395 }
396 const start = this.index
397 while (!this.done) {
398 if (multiline && this.input.startsWith("'''", this.index)) {
399 const output = this.input.slice(start, this.index)
400 this.advance(3)
401 return output + this.closingQuotes("'")
402 }
403 if (!multiline && this.peek() === "'") {
404 const output = this.input.slice(start, this.index)
405 this.advance()
406 return output
407 }
408 if (!multiline && (this.peek() === "\n" || this.peek() === "\r")) {
409 this.fail("Literal strings cannot contain newlines")
410 }
411 this.advance()
412 }
413 this.fail("Unterminated literal string")
414 }
415
416 private closingQuotes(quote: string): string {
417 let quotes = ""

Callers 2

parseKeyPathMethod · 0.95
parseValueMethod · 0.95

Calls 6

expectMethod · 0.95
advanceMethod · 0.95
peekMethod · 0.95
closingQuotesMethod · 0.95
failMethod · 0.95
sliceMethod · 0.80

Tested by

no test coverage detected