MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / primary

Function primary

src/math-json/parse-sympy.ts:331–353  ·  view source on GitHub ↗
(
  s: string,
  start: number
)

Source from the content-addressed store, hash-verified

329
330function primary(
331 s: string,
332 start: number
333): [index: number, result: Expression | null] {
334 // Attribute references, subscriptions, slices, and calls are not supported;
335 // only atoms are recognized here.
336
337 // eslint-disable-next-line prefer-const
338 let [i, e] = atom(s, start);
339 if (e) return [i, e];
340
341 // subscription, slice, call attribute reference (x[i], x[a:b], x(a), x.a)
342 if (e !== null && s[i] === '(') {
343 if (symbol(e)) {
344 let args: Expression[];
345 [i, args] = expressionList(s, i);
346 if (s[i] === ')') {
347 return [i, [symbol(e), ...args] as Expression];
348 }
349 }
350 }
351
352 return [start, null];
353}
354
355function expression(
356 s: string,

Callers 1

expressionFunction · 0.85

Calls 3

symbolFunction · 0.90
atomFunction · 0.85
expressionListFunction · 0.85

Tested by

no test coverage detected