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

Function _parseValue

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

Source from the content-addressed store, hash-verified

166// Parse a single Python literal starting at `text[pos]`. Returns
167// `{ value, next }` or null on failure.
168function _parseValue(text, pos) {
169 while (pos < text.length && /\s/.test(text[pos])) pos++;
170 if (pos >= text.length) return null;
171 const c = text[pos];
172
173 if (c === "'" || c === '"') return _parseString(text, pos);
174 if (c === '[') return _parseList(text, pos);
175 if (c === '{') return _parseDict(text, pos);
176
177 // Identifier-like: True/False/None or a bare keyword we don't accept.
178 const idMatch = text.slice(pos).match(/^(True|False|None)\b/);
179 if (idMatch) {
180 const map = { True: true, False: false, None: null };
181 return { value: map[idMatch[1]], next: pos + idMatch[0].length };
182 }
183
184 // Number — including scientific notation and signs.
185 const numMatch = text.slice(pos).match(/^[+-]?(\d+\.\d*|\.\d+|\d+)([eE][+-]?\d+)?/);
186 if (numMatch) {
187 return { value: parseFloat(numMatch[0]), next: pos + numMatch[0].length };
188 }
189
190 return null;
191}
192
193function _parseString(text, pos) {
194 const quote = text[pos];

Callers 3

_parseKwargsFunction · 0.85
_parseListFunction · 0.85
_parseDictFunction · 0.85

Calls 3

_parseStringFunction · 0.85
_parseListFunction · 0.85
_parseDictFunction · 0.85

Tested by

no test coverage detected