MCPcopy Create free account
hub / github.com/openai/plugins / readBlockString

Function readBlockString

plugins/shopify/skills/shopify-admin/scripts/validate.mjs:1427–1491  ·  view source on GitHub ↗
(lexer, start)

Source from the content-addressed store, hash-verified

1425 );
1426 }
1427 function readBlockString(lexer, start) {
1428 const body = lexer.source.body;
1429 const bodyLength = body.length;
1430 let lineStart = lexer.lineStart;
1431 let position = start + 3;
1432 let chunkStart = position;
1433 let currentLine = "";
1434 const blockLines = [];
1435 while (position < bodyLength) {
1436 const code = body.charCodeAt(position);
1437 if (code === 34 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34) {
1438 currentLine += body.slice(chunkStart, position);
1439 blockLines.push(currentLine);
1440 const token = createToken(
1441 lexer,
1442 _tokenKind.TokenKind.BLOCK_STRING,
1443 start,
1444 position + 3,
1445 // Return a string of the lines joined with U+000A.
1446 (0, _blockString.dedentBlockStringLines)(blockLines).join("\n")
1447 );
1448 lexer.line += blockLines.length - 1;
1449 lexer.lineStart = lineStart;
1450 return token;
1451 }
1452 if (code === 92 && body.charCodeAt(position + 1) === 34 && body.charCodeAt(position + 2) === 34 && body.charCodeAt(position + 3) === 34) {
1453 currentLine += body.slice(chunkStart, position);
1454 chunkStart = position + 1;
1455 position += 4;
1456 continue;
1457 }
1458 if (code === 10 || code === 13) {
1459 currentLine += body.slice(chunkStart, position);
1460 blockLines.push(currentLine);
1461 if (code === 13 && body.charCodeAt(position + 1) === 10) {
1462 position += 2;
1463 } else {
1464 ++position;
1465 }
1466 currentLine = "";
1467 chunkStart = position;
1468 lineStart = position;
1469 continue;
1470 }
1471 if (isUnicodeScalarValue(code)) {
1472 ++position;
1473 } else if (isSupplementaryCodePoint(body, position)) {
1474 position += 2;
1475 } else {
1476 throw (0, _syntaxError.syntaxError)(
1477 lexer.source,
1478 position,
1479 `Invalid character within String: ${printCodePointAt(
1480 lexer,
1481 position
1482 )}.`
1483 );
1484 }

Callers 1

readNextTokenFunction · 0.70

Calls 4

createTokenFunction · 0.70
isUnicodeScalarValueFunction · 0.70
isSupplementaryCodePointFunction · 0.70
printCodePointAtFunction · 0.70

Tested by

no test coverage detected