UNPKG

mathjslab

Version:

MathJSLab - An interpreter with language syntax like MATLAB®/Octave, ISBN 978-65-00-82338-7.

41 lines (40 loc) 1.54 kB
import { type NodeClassDef, type NodeInput, type NodeList } from './AST'; import { Interpreter } from './Interpreter'; /** * Typed parser and execution helpers for compatibility fixtures. * * These helpers keep tests from reaching into broad `NodeInput` shapes with * unchecked casts. A failing fixture should fail with an explicit structural * expectation, not with an accidental property read on the wrong AST node. */ /** * Require a value to be a top-level node list. * * @param value Value to validate. * @param message Error text used when the value is not a list. * @returns Validated AST list. */ declare const requireNodeList: (value: NodeInput, message?: string) => NodeList; /** * Parse source text and require the parser result to be a top-level list. * * @param source Source text to parse. * @returns Parsed top-level AST list. */ declare const parseList: (source: string) => NodeList; /** * Execute source text and require the result to be a top-level list. * * @param interpreter Interpreter instance used for execution. * @param source Source text to execute. * @returns Evaluated top-level result list. */ declare const executeList: (interpreter: Interpreter, source: string) => NodeList; /** * Parse a class definition fixture and return its first classdef node. * * @param source Classdef source text. * @returns Parsed class definition node. */ declare const parseClassDefinition: (source: string) => NodeClassDef; export { executeList, parseClassDefinition, parseList, requireNodeList };