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

Function _findMatchingParen

src/tools/liquid_tool_parser.js:107–125  ·  view source on GitHub ↗
(s, start)

Source from the content-addressed store, hash-verified

105
106// Walk from `start` forward, return index of the matching `)`. -1 if not found.
107function _findMatchingParen(s, start) {
108 let depth = 1;
109 let i = start;
110 while (i < s.length) {
111 const c = s[i];
112 if (c === "'" || c === '"') {
113 i = _skipString(s, i);
114 if (i === -1) return -1;
115 continue;
116 }
117 if (c === '(' || c === '[' || c === '{') depth++;
118 else if (c === ')' || c === ']' || c === '}') {
119 depth--;
120 if (depth === 0 && c === ')') return i;
121 }
122 i++;
123 }
124 return -1;
125}
126
127// Skip a Python-style string starting at `s[start]` (single or double quote).
128// Returns index just past the closing quote, or -1 on EOF.

Callers 1

_parseCallListFunction · 0.85

Calls 1

_skipStringFunction · 0.85

Tested by

no test coverage detected