MCPcopy
hub / github.com/Doorman11991/smallcode / _parseList

Function _parseList

src/tools/liquid_tool_parser.js:246–275  ·  view source on GitHub ↗
(text, pos)

Source from the content-addressed store, hash-verified

244}
245
246function _parseList(text, pos) {
247 // Find matching ]
248 let depth = 1;
249 let i = pos + 1;
250 while (i < text.length && depth > 0) {
251 const c = text[i];
252 if (c === "'" || c === '"') { i = _skipString(text, i); if (i === -1) return null; continue; }
253 if (c === '[' || c === '(' || c === '{') depth++;
254 else if (c === ']' || c === ')' || c === '}') {
255 depth--;
256 if (depth === 0 && c === ']') break;
257 }
258 i++;
259 }
260 if (depth !== 0) return null;
261 const inner = text.slice(pos + 1, i);
262 const arr = [];
263 let p = 0;
264 while (p < inner.length) {
265 while (p < inner.length && /\s/.test(inner[p])) p++;
266 if (p >= inner.length) break;
267 const v = _parseValue(inner, p);
268 if (!v) return null;
269 arr.push(v.value);
270 p = v.next;
271 while (p < inner.length && /\s/.test(inner[p])) p++;
272 if (p < inner.length && inner[p] === ',') p++;
273 }
274 return { value: arr, next: i + 1 };
275}
276
277function _parseDict(text, pos) {
278 // Find matching }

Callers 1

_parseValueFunction · 0.85

Calls 2

_skipStringFunction · 0.85
_parseValueFunction · 0.85

Tested by

no test coverage detected