MCPcopy Create free account
hub / github.com/denoland/std / literalString

Function literalString

toml/_parser.ts:489–508  ·  view source on GitHub ↗
(scanner: Scanner)

Source from the content-addressed store, hash-verified

487}
488
489export function literalString(scanner: Scanner): ParseResult<string> {
490 scanner.skipWhitespaces();
491 if (scanner.char() !== "'") return failure();
492 scanner.next();
493 const acc: string[] = [];
494 while (scanner.char() !== "'" && !scanner.eof()) {
495 if (scanner.char() === "\n") {
496 throw new SyntaxError("Single-line string cannot contain EOL");
497 }
498 acc.push(scanner.char());
499 scanner.next();
500 }
501 if (scanner.eof()) {
502 throw new SyntaxError(
503 `Single-line string is not closed:\n${acc.join("")}`,
504 );
505 }
506 scanner.next(); // skip last "'"
507 return success(acc.join(""));
508}
509
510export function multilineBasicString(
511 scanner: Scanner,

Callers

nothing calls this directly

Calls 7

failureFunction · 0.85
successFunction · 0.85
charMethod · 0.80
skipWhitespacesMethod · 0.45
nextMethod · 0.45
eofMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected