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

Function parseCore

src/compute-engine/latex-syntax/parse.ts:3211–3229  ·  view source on GitHub ↗

* Parse `latex` into a MathJSON expression, marking any leftover tokens with * an `Error` node. This is the core routine, without the trailing-punctuation * recovery or `preserveLatex` post-processing applied by `parse`.

(
  latex: string,
  dictionary: IndexedLatexDictionary,
  options: Readonly<ParseLatexOptions>
)

Source from the content-addressed store, hash-verified

3209 if (typeof def.parse === 'function')
3210 result = def.parse(this, arg, { minPrec: 0 });
3211 else result = arg;
3212 if (result !== null) break;
3213 }
3214 }
3215 }
3216 }
3217
3218 // Restore the index if we did not find a match
3219 if (result === null) this.index = index;
3220
3221 return result;
3222 }
3223
3224 parsePostfixOperator(
3225 lhs: MathJsonExpression | null,
3226 until?: Readonly<Terminator>
3227 ): MathJsonExpression | null {
3228 console.assert(lhs !== null); // @todo validate
3229 if (lhs === null || this.atEnd) return null;
3230
3231 const start = this.index;
3232 // Skip visual space (e.g. `\ `, `\,`) before peeking postfix triggers, so

Callers 1

parseFunction · 0.85

Calls 3

parseExpressionMethod · 0.95
parseSyntaxErrorMethod · 0.95
tokenizeFunction · 0.90

Tested by

no test coverage detected