MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseArraySymbols

Function parseArraySymbols

scripts/generate_slash_command_appendix.mjs:441–468  ·  view source on GitHub ↗
(blockSource)

Source from the content-addressed store, hash-verified

439}
440
441function parseArraySymbols(blockSource) {
442 const entries = []
443 for (const item of splitTopLevelCommaList(blockSource)) {
444 const line = item.trim()
445 if (!line || line.startsWith('//')) continue
446
447 let match = line.match(/^\.\.\.\(([\s\S]+?)\?\s*\[([\s\S]+?)\]\s*:\s*\[\]\)$/)
448 if (match) {
449 const gate = match[1].trim()
450 const spreadItems = splitTopLevelCommaList(match[2])
451 for (const spreadItem of spreadItems) {
452 entries.push({
453 symbol: spreadItem.replace(/\(\)$/, '').trim(),
454 entryExpr: spreadItem.trim(),
455 gate,
456 })
457 }
458 continue
459 }
460
461 match = line.match(/^([A-Za-z_$][\w$]*(?:\(\))?)$/)
462 if (match) {
463 const entryExpr = match[1]
464 entries.push({ symbol: entryExpr.replace(/\(\)$/, ''), entryExpr, gate: '' })
465 }
466 }
467 return entries
468}
469
470function findCallObjectSource(source, calleeName) {
471 const regex = new RegExp(`\\b${calleeName}\\s*\\(`, 'm')

Calls 1

splitTopLevelCommaListFunction · 0.85

Tested by

no test coverage detected