numbl 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist-cli/cli.js +7277 -3344
- package/dist-lib/graphics/types.d.ts +262 -0
- package/dist-lib/lib.d.ts +19 -0
- package/dist-lib/lib.js +53709 -0
- package/dist-lib/numbl-core/diagnostics/errors.d.ts +8 -0
- package/dist-lib/numbl-core/diagnostics/index.d.ts +27 -0
- package/dist-lib/numbl-core/executeCode.d.ts +70 -0
- package/dist-lib/numbl-core/externalAccessDirective.d.ts +6 -0
- package/dist-lib/numbl-core/fileIOAdapter.d.ts +61 -0
- package/dist-lib/numbl-core/functionResolve.d.ts +59 -0
- package/dist-lib/numbl-core/helpers/arithmetic.d.ts +47 -0
- package/dist-lib/numbl-core/helpers/bessel.d.ts +40 -0
- package/dist-lib/numbl-core/helpers/check-helpers.d.ts +50 -0
- package/dist-lib/numbl-core/helpers/constants.d.ts +6 -0
- package/dist-lib/numbl-core/helpers/dummy.d.ts +5 -0
- package/dist-lib/numbl-core/helpers/erf.d.ts +5 -0
- package/dist-lib/numbl-core/helpers/linsolve.d.ts +26 -0
- package/dist-lib/numbl-core/helpers/ode-rk.d.ts +83 -0
- package/dist-lib/numbl-core/helpers/prng.d.ts +17 -0
- package/dist-lib/numbl-core/helpers/reduction/cumulative.d.ts +8 -0
- package/dist-lib/numbl-core/helpers/reduction/min-max.d.ts +5 -0
- package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +58 -0
- package/dist-lib/numbl-core/helpers/registry.d.ts +7 -0
- package/dist-lib/numbl-core/helpers/shape-utils.d.ts +7 -0
- package/dist-lib/numbl-core/helpers/sparse-arithmetic.d.ts +16 -0
- package/dist-lib/numbl-core/helpers/string.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/builtins/arithmetic.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/array-construction.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/array-extras.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/builtins/array-manipulation.d.ts +7 -0
- package/dist-lib/numbl-core/interpreter/builtins/cell-struct.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/builtins/complex.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/dictionary.d.ts +15 -0
- package/dist-lib/numbl-core/interpreter/builtins/fft.d.ts +7 -0
- package/dist-lib/numbl-core/interpreter/builtins/help-text.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +34 -0
- package/dist-lib/numbl-core/interpreter/builtins/introspection.d.ts +6 -0
- package/dist-lib/numbl-core/interpreter/builtins/linear-algebra.d.ts +9 -0
- package/dist-lib/numbl-core/interpreter/builtins/math.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/misc.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/numerical.d.ts +10 -0
- package/dist-lib/numbl-core/interpreter/builtins/predicates.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/prng.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/reductions.d.ts +6 -0
- package/dist-lib/numbl-core/interpreter/builtins/set-operations.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/sparse.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/special-math.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/string-extras.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/builtins/strings.d.ts +7 -0
- package/dist-lib/numbl-core/interpreter/builtins/time-system.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/builtins/type-constructors.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +109 -0
- package/dist-lib/numbl-core/interpreter/builtins/utility.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/builtins/validation.d.ts +4 -0
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +146 -0
- package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +51 -0
- package/dist-lib/numbl-core/interpreter/interpreterFunctions.d.ts +41 -0
- package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +18 -0
- package/dist-lib/numbl-core/interpreter/jit/index.d.ts +7 -0
- package/dist-lib/numbl-core/interpreter/jit/jitCodegen.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/jit/jitHelpers.d.ts +5 -0
- package/dist-lib/numbl-core/interpreter/jit/jitLoop.d.ts +25 -0
- package/dist-lib/numbl-core/interpreter/jit/jitLoopAnalysis.d.ts +25 -0
- package/dist-lib/numbl-core/interpreter/jit/jitLower.d.ts +20 -0
- package/dist-lib/numbl-core/interpreter/jit/jitTypes.d.ts +168 -0
- package/dist-lib/numbl-core/interpreter/types.d.ts +77 -0
- package/dist-lib/numbl-core/jsUserFunctions.d.ts +25 -0
- package/dist-lib/numbl-core/lexer/helpers.d.ts +15 -0
- package/dist-lib/numbl-core/lexer/index.d.ts +4 -0
- package/dist-lib/numbl-core/lexer/keywords.d.ts +3 -0
- package/dist-lib/numbl-core/lexer/token-config.d.ts +94 -0
- package/dist-lib/numbl-core/lexer/tokenizer.d.ts +9 -0
- package/dist-lib/numbl-core/lexer/types.d.ts +78 -0
- package/dist-lib/numbl-core/lowering/classInfo.d.ts +36 -0
- package/dist-lib/numbl-core/lowering/constants.d.ts +4 -0
- package/dist-lib/numbl-core/lowering/errors.d.ts +17 -0
- package/dist-lib/numbl-core/lowering/index.d.ts +3 -0
- package/dist-lib/numbl-core/lowering/itemTypes.d.ts +87 -0
- package/dist-lib/numbl-core/lowering/loweringContext.d.ts +206 -0
- package/dist-lib/numbl-core/native/bridge-resolve.d.ts +14 -0
- package/dist-lib/numbl-core/native/lapack-bridge.d.ts +387 -0
- package/dist-lib/numbl-core/native/ts-lapack-bridge.d.ts +9 -0
- package/dist-lib/numbl-core/parser/ArgumentsParser.d.ts +28 -0
- package/dist-lib/numbl-core/parser/ClassParser.d.ts +18 -0
- package/dist-lib/numbl-core/parser/CommandParser.d.ts +31 -0
- package/dist-lib/numbl-core/parser/ControlFlowParser.d.ts +16 -0
- package/dist-lib/numbl-core/parser/ExpressionParser.d.ts +32 -0
- package/dist-lib/numbl-core/parser/FunctionParser.d.ts +10 -0
- package/dist-lib/numbl-core/parser/Parser.d.ts +17 -0
- package/dist-lib/numbl-core/parser/ParserBase.d.ts +35 -0
- package/dist-lib/numbl-core/parser/StatementParser.d.ts +13 -0
- package/dist-lib/numbl-core/parser/errors.d.ts +15 -0
- package/dist-lib/numbl-core/parser/index.d.ts +7 -0
- package/dist-lib/numbl-core/parser/types.d.ts +316 -0
- package/dist-lib/numbl-core/runtime/compare.d.ts +5 -0
- package/dist-lib/numbl-core/runtime/constructors.d.ts +35 -0
- package/dist-lib/numbl-core/runtime/convert.d.ts +10 -0
- package/dist-lib/numbl-core/runtime/display.d.ts +6 -0
- package/dist-lib/numbl-core/runtime/error.d.ts +73 -0
- package/dist-lib/numbl-core/runtime/index.d.ts +12 -0
- package/dist-lib/numbl-core/runtime/indexing.d.ts +10 -0
- package/dist-lib/numbl-core/runtime/plotUtils.d.ts +215 -0
- package/dist-lib/numbl-core/runtime/runtime.d.ts +314 -0
- package/dist-lib/numbl-core/runtime/runtimeDispatch.d.ts +27 -0
- package/dist-lib/numbl-core/runtime/runtimeHelpers.d.ts +31 -0
- package/dist-lib/numbl-core/runtime/runtimeIndexing.d.ts +28 -0
- package/dist-lib/numbl-core/runtime/runtimeMemberAccess.d.ts +26 -0
- package/dist-lib/numbl-core/runtime/runtimeOperators.d.ts +24 -0
- package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +99 -0
- package/dist-lib/numbl-core/runtime/sentinels.d.ts +4 -0
- package/dist-lib/numbl-core/runtime/specialBuiltinNames.d.ts +2 -0
- package/dist-lib/numbl-core/runtime/specialBuiltins.d.ts +13 -0
- package/dist-lib/numbl-core/runtime/struct-access.d.ts +6 -0
- package/dist-lib/numbl-core/runtime/syncChannel.d.ts +1 -0
- package/dist-lib/numbl-core/runtime/tensor-construction.d.ts +10 -0
- package/dist-lib/numbl-core/runtime/types.d.ts +110 -0
- package/dist-lib/numbl-core/runtime/utils.d.ts +20 -0
- package/dist-lib/numbl-core/stdlib-bundle.d.ts +3 -0
- package/dist-lib/numbl-core/systemAdapter.d.ts +23 -0
- package/dist-lib/numbl-core/version.d.ts +2 -0
- package/dist-lib/numbl-core/workspace/index.d.ts +4 -0
- package/dist-lib/numbl-core/workspace/types.d.ts +16 -0
- package/dist-lib/ts-lapack/src/BLAS/daxpy.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dcopy.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/ddot.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dgemm.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dgemm_optimized.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dgemv.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dger.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dnrm2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/drot.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dscal.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dswap.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dtrmm.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dtrmv.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/dtrsm.d.ts +1 -0
- package/dist-lib/ts-lapack/src/BLAS/idamax.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dbdsqr.d.ts +10 -0
- package/dist-lib/ts-lapack/src/SRC/dgebak.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgebal.d.ts +5 -0
- package/dist-lib/ts-lapack/src/SRC/dgebd2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgebrd.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgeev.d.ts +3 -0
- package/dist-lib/ts-lapack/src/SRC/dgehd2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgehrd.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgelq2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgelqf.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgeqr2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgeqrf.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgeqrf_optimized.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgesvd.d.ts +28 -0
- package/dist-lib/ts-lapack/src/SRC/dgetrf.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgetrf2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dgetri.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dhseqr.d.ts +32 -0
- package/dist-lib/ts-lapack/src/SRC/dlabrd.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlacpy.d.ts +18 -0
- package/dist-lib/ts-lapack/src/SRC/dladiv.d.ts +9 -0
- package/dist-lib/ts-lapack/src/SRC/dlaexc.d.ts +21 -0
- package/dist-lib/ts-lapack/src/SRC/dlahqr.d.ts +24 -0
- package/dist-lib/ts-lapack/src/SRC/dlahr2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlaln2.d.ts +5 -0
- package/dist-lib/ts-lapack/src/SRC/dlamch.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlange.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlanv2.d.ts +12 -0
- package/dist-lib/ts-lapack/src/SRC/dlapy2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlaqr1.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlaqr30.d.ts +81 -0
- package/dist-lib/ts-lapack/src/SRC/dlaqr5.d.ts +38 -0
- package/dist-lib/ts-lapack/src/SRC/dlarf.d.ts +18 -0
- package/dist-lib/ts-lapack/src/SRC/dlarf1f.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlarfb.d.ts +25 -0
- package/dist-lib/ts-lapack/src/SRC/dlarfg.d.ts +4 -0
- package/dist-lib/ts-lapack/src/SRC/dlarft.d.ts +20 -0
- package/dist-lib/ts-lapack/src/SRC/dlarfx.d.ts +17 -0
- package/dist-lib/ts-lapack/src/SRC/dlartg.d.ts +5 -0
- package/dist-lib/ts-lapack/src/SRC/dlas2.d.ts +4 -0
- package/dist-lib/ts-lapack/src/SRC/dlascl.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlaset.d.ts +19 -0
- package/dist-lib/ts-lapack/src/SRC/dlasr.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlassq.d.ts +18 -0
- package/dist-lib/ts-lapack/src/SRC/dlasv2.d.ts +8 -0
- package/dist-lib/ts-lapack/src/SRC/dlaswp.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dlasy2.d.ts +5 -0
- package/dist-lib/ts-lapack/src/SRC/dorg2r.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dorgbr.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dorghr.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dorgl2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dorglq.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dorgqr.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dorgqr_optimized.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dorm2r.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dormhr.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dormqr.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dpotf2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dtrevc3.d.ts +27 -0
- package/dist-lib/ts-lapack/src/SRC/dtrexc.d.ts +24 -0
- package/dist-lib/ts-lapack/src/SRC/dtrti2.d.ts +1 -0
- package/dist-lib/ts-lapack/src/SRC/dtrtri.d.ts +1 -0
- package/dist-lib/ts-lapack/src/utils/constants.d.ts +28 -0
- package/dist-lib/ts-lapack/src/utils/iladlc.d.ts +1 -0
- package/dist-lib/ts-lapack/src/utils/iladlr.d.ts +1 -0
- package/dist-lib/ts-lapack/src/utils/ilaenv.d.ts +1 -0
- package/dist-lib/ts-lapack/src/utils/xerbla.d.ts +1 -0
- package/dist-plot-viewer/assets/index-BjKyNJgj.js +4426 -0
- package/dist-plot-viewer/index.html +1 -1
- package/package.json +12 -2
- package/dist-plot-viewer/assets/index-BMYdzDaW.js +0 -4426
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CommandParser - Command form parsing methods
|
|
3
|
+
*/
|
|
4
|
+
import { Expr } from "./types.js";
|
|
5
|
+
import { ExpressionParser } from "./ExpressionParser.js";
|
|
6
|
+
export declare class CommandParser extends ExpressionParser {
|
|
7
|
+
/**
|
|
8
|
+
* Detect whether the current position starts a command-form statement.
|
|
9
|
+
*
|
|
10
|
+
* Uses raw source scanning: an identifier followed by horizontal whitespace
|
|
11
|
+
* and then non-operator content is command form. Zero-arg invocations
|
|
12
|
+
* (e.g. `hold` alone) are handled by the expression parser + lowering
|
|
13
|
+
* which resolves bare identifiers to zero-arg function calls.
|
|
14
|
+
*/
|
|
15
|
+
canStartCommandForm(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Parse command arguments from the raw source text.
|
|
18
|
+
*
|
|
19
|
+
* Each whitespace-delimited token becomes a Char (character vector) node,
|
|
20
|
+
* matching MATLAB's command-syntax semantics. Single-quoted strings
|
|
21
|
+
* preserve interior spaces.
|
|
22
|
+
*
|
|
23
|
+
* Call this AFTER consuming the verb token with next().
|
|
24
|
+
*/
|
|
25
|
+
parseCommandArgsGeneral(): Expr[];
|
|
26
|
+
/**
|
|
27
|
+
* Check whether the character at `pos` in `this.input` can start a
|
|
28
|
+
* command-syntax argument (as opposed to a binary operator).
|
|
29
|
+
*/
|
|
30
|
+
private isCommandArgStart;
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ControlFlowParser - Control flow parsing methods (if/while/for/switch/try-catch)
|
|
3
|
+
*/
|
|
4
|
+
import { Token } from "../lexer/index.js";
|
|
5
|
+
import { Stmt } from "./types.js";
|
|
6
|
+
import { CommandParser } from "./CommandParser.js";
|
|
7
|
+
export declare class ControlFlowParser extends CommandParser {
|
|
8
|
+
parseIf(): Stmt;
|
|
9
|
+
parseWhile(): Stmt;
|
|
10
|
+
parseFor(): Stmt;
|
|
11
|
+
parseSwitch(): Stmt;
|
|
12
|
+
parseTryCatch(): Stmt;
|
|
13
|
+
parseBlock(term: (t: Token) => boolean): Stmt[];
|
|
14
|
+
protected parseStmt(): Stmt;
|
|
15
|
+
protected tryParseMultiAssign(): Stmt;
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ExpressionParser - Expression parsing methods
|
|
3
|
+
*/
|
|
4
|
+
import { Expr } from "./types.js";
|
|
5
|
+
import { ParserBase } from "./ParserBase.js";
|
|
6
|
+
export declare class ExpressionParser extends ParserBase {
|
|
7
|
+
parseExpr(): Expr;
|
|
8
|
+
private parseLogicalOr;
|
|
9
|
+
private parseLogicalAnd;
|
|
10
|
+
private parseBitwiseOr;
|
|
11
|
+
private parseBitwiseAnd;
|
|
12
|
+
private parseComparison;
|
|
13
|
+
private parseRange;
|
|
14
|
+
private parseAddSub;
|
|
15
|
+
private parseMulDiv;
|
|
16
|
+
private parsePow;
|
|
17
|
+
/** Parse the right-hand side of a ^ or .^ operator: unary prefixes then postfix. */
|
|
18
|
+
private parsePowRHS;
|
|
19
|
+
private parsePostfixWithBase;
|
|
20
|
+
private parsePostfix;
|
|
21
|
+
private parseUnary;
|
|
22
|
+
private parsePrimary;
|
|
23
|
+
private parseMatrix;
|
|
24
|
+
private parseMatrixExpr;
|
|
25
|
+
private parseCell;
|
|
26
|
+
/**
|
|
27
|
+
* Parse a single function call argument, handling MATLAB's Name=Value
|
|
28
|
+
* syntax. `foo(x, y, LineWidth=2)` is desugared to
|
|
29
|
+
* `foo(x, y, 'LineWidth', 2)` by pushing two args into the array.
|
|
30
|
+
*/
|
|
31
|
+
private parseFuncArg;
|
|
32
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FunctionParser - Function definition parsing methods
|
|
3
|
+
*/
|
|
4
|
+
import { Stmt } from "./types.js";
|
|
5
|
+
import { ArgumentsParser } from "./ArgumentsParser.js";
|
|
6
|
+
export declare class FunctionParser extends ArgumentsParser {
|
|
7
|
+
parseFunction(): Stmt;
|
|
8
|
+
parseGlobal(): Stmt;
|
|
9
|
+
parsePersistent(): Stmt;
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser - Main entry point
|
|
3
|
+
*
|
|
4
|
+
* This parser has been split into multiple modules for better maintainability:
|
|
5
|
+
* - ParserBase: Core state and utility methods
|
|
6
|
+
* - ExpressionParser: Expression and matrix/cell parsing
|
|
7
|
+
* - CommandParser: Command-form syntax parsing
|
|
8
|
+
* - ControlFlowParser: Control flow constructs (if/while/for/switch/try-catch)
|
|
9
|
+
* - FunctionParser: Function and global/persistent declarations
|
|
10
|
+
* - ClassParser: Class and import definitions
|
|
11
|
+
* - StatementParser: Top-level statement parsing and program entry
|
|
12
|
+
*
|
|
13
|
+
* All functionality is composed through class inheritance.
|
|
14
|
+
*/
|
|
15
|
+
import { StatementParser } from "./StatementParser.js";
|
|
16
|
+
export declare class Parser extends StatementParser {
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParserBase - Core parser state and utility methods
|
|
3
|
+
*/
|
|
4
|
+
import { Token } from "../lexer/index.js";
|
|
5
|
+
import { Span, TokenInfo, Expr, BinaryOperation, UnaryOperation } from "./types.js";
|
|
6
|
+
import { SyntaxError } from "./errors.js";
|
|
7
|
+
export declare class ParserBase {
|
|
8
|
+
protected tokens: TokenInfo[];
|
|
9
|
+
protected pos: number;
|
|
10
|
+
protected input: string;
|
|
11
|
+
protected fileName: string;
|
|
12
|
+
protected inMatrixExpr: boolean;
|
|
13
|
+
constructor(tokens: TokenInfo[], input: string, fileName?: string);
|
|
14
|
+
protected peek(): TokenInfo | undefined;
|
|
15
|
+
protected currentPosition(): number;
|
|
16
|
+
protected peekToken(): Token | undefined;
|
|
17
|
+
protected peekTokenAt(offset: number): Token | undefined;
|
|
18
|
+
protected next(): TokenInfo | undefined;
|
|
19
|
+
protected consume(t: Token): boolean;
|
|
20
|
+
protected skipNewlines(): void;
|
|
21
|
+
protected tokensAdjacent(left: number, right: number): boolean;
|
|
22
|
+
protected spanFrom(start: number, end: number): Span;
|
|
23
|
+
protected spanBetween(start: Span, end: Span): Span;
|
|
24
|
+
protected lastTokenEnd(): number;
|
|
25
|
+
protected makeBinary(left: Expr, op: BinaryOperation, right: Expr): Expr;
|
|
26
|
+
protected makeUnary(op: UnaryOperation, operand: Expr, opStart: number): Expr;
|
|
27
|
+
protected isSimpleAssignmentAhead(): boolean;
|
|
28
|
+
protected error(message: string): SyntaxError;
|
|
29
|
+
protected errorWithExpected(message: string, expected: string): SyntaxError;
|
|
30
|
+
protected expectIdent(): string;
|
|
31
|
+
/** Accept an identifier or any keyword token as a member name (after '.') */
|
|
32
|
+
protected expectMemberName(): string;
|
|
33
|
+
protected expectIdentOrTilde(): string;
|
|
34
|
+
protected parseQualifiedName(): string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StatementParser - Statement parsing methods
|
|
3
|
+
*/
|
|
4
|
+
import { Stmt, AbstractSyntaxTree } from "./types.js";
|
|
5
|
+
import { ClassParser } from "./ClassParser.js";
|
|
6
|
+
export declare class StatementParser extends ClassParser {
|
|
7
|
+
parseProgram(): AbstractSyntaxTree;
|
|
8
|
+
private parseStmtWithSemicolon;
|
|
9
|
+
parseStmt(): Stmt;
|
|
10
|
+
private tryParseLValueAssign;
|
|
11
|
+
tryParseMultiAssign(): Stmt;
|
|
12
|
+
private parseMultiAssignLValue;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser error classes.
|
|
3
|
+
*/
|
|
4
|
+
export declare class SyntaxError extends Error {
|
|
5
|
+
position: number;
|
|
6
|
+
line: number | null;
|
|
7
|
+
/** Source file name (set when parsing workspace files, or resolved in prepare.ts) */
|
|
8
|
+
file: string | null;
|
|
9
|
+
foundToken: string | null;
|
|
10
|
+
expected: string | null;
|
|
11
|
+
/** 1-based column number (resolved in prepare.ts for non-workspace-file errors) */
|
|
12
|
+
column: number | undefined;
|
|
13
|
+
constructor(message: string, position: number, foundToken?: string | null, expected?: string | null, line?: number | null);
|
|
14
|
+
toString(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { Token } from "../lexer/index.js";
|
|
2
|
+
export interface Span {
|
|
3
|
+
file: string;
|
|
4
|
+
start: number;
|
|
5
|
+
end: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TokenInfo {
|
|
8
|
+
token: Token;
|
|
9
|
+
lexeme: string;
|
|
10
|
+
position: number;
|
|
11
|
+
end: number;
|
|
12
|
+
}
|
|
13
|
+
export declare enum BinaryOperation {
|
|
14
|
+
Add = "Add",
|
|
15
|
+
Sub = "Sub",
|
|
16
|
+
Mul = "Mul",
|
|
17
|
+
ElemMul = "ElemMul",
|
|
18
|
+
Div = "Div",
|
|
19
|
+
ElemDiv = "ElemDiv",
|
|
20
|
+
LeftDiv = "LeftDiv",
|
|
21
|
+
ElemLeftDiv = "ElemLeftDiv",
|
|
22
|
+
Pow = "Pow",
|
|
23
|
+
ElemPow = "ElemPow",
|
|
24
|
+
Equal = "Equal",
|
|
25
|
+
NotEqual = "NotEqual",
|
|
26
|
+
Less = "Less",
|
|
27
|
+
LessEqual = "LessEqual",
|
|
28
|
+
Greater = "Greater",
|
|
29
|
+
GreaterEqual = "GreaterEqual",
|
|
30
|
+
OrOr = "OrOr",
|
|
31
|
+
AndAnd = "AndAnd",
|
|
32
|
+
BitOr = "BitOr",
|
|
33
|
+
BitAnd = "BitAnd"
|
|
34
|
+
}
|
|
35
|
+
export declare enum UnaryOperation {
|
|
36
|
+
Plus = "Plus",
|
|
37
|
+
Minus = "Minus",
|
|
38
|
+
Not = "Not",
|
|
39
|
+
Transpose = "Transpose",
|
|
40
|
+
NonConjugateTranspose = "NonConjugateTranspose"
|
|
41
|
+
}
|
|
42
|
+
export type Expr = {
|
|
43
|
+
type: "Number";
|
|
44
|
+
value: string;
|
|
45
|
+
span: Span;
|
|
46
|
+
} | {
|
|
47
|
+
type: "Char";
|
|
48
|
+
value: string;
|
|
49
|
+
span: Span;
|
|
50
|
+
} | {
|
|
51
|
+
type: "String";
|
|
52
|
+
value: string;
|
|
53
|
+
span: Span;
|
|
54
|
+
} | {
|
|
55
|
+
type: "Ident";
|
|
56
|
+
name: string;
|
|
57
|
+
span: Span;
|
|
58
|
+
} | {
|
|
59
|
+
type: "EndKeyword";
|
|
60
|
+
span: Span;
|
|
61
|
+
} | {
|
|
62
|
+
type: "ImagUnit";
|
|
63
|
+
span: Span;
|
|
64
|
+
} | {
|
|
65
|
+
type: "Colon";
|
|
66
|
+
span: Span;
|
|
67
|
+
} | {
|
|
68
|
+
type: "MetaClass";
|
|
69
|
+
name: string;
|
|
70
|
+
span: Span;
|
|
71
|
+
} | {
|
|
72
|
+
type: "Binary";
|
|
73
|
+
left: Expr;
|
|
74
|
+
op: BinaryOperation;
|
|
75
|
+
right: Expr;
|
|
76
|
+
span: Span;
|
|
77
|
+
} | {
|
|
78
|
+
type: "Unary";
|
|
79
|
+
op: UnaryOperation;
|
|
80
|
+
operand: Expr;
|
|
81
|
+
span: Span;
|
|
82
|
+
} | {
|
|
83
|
+
type: "Range";
|
|
84
|
+
start: Expr;
|
|
85
|
+
step: Expr | null;
|
|
86
|
+
end: Expr;
|
|
87
|
+
span: Span;
|
|
88
|
+
} | {
|
|
89
|
+
type: "FuncCall";
|
|
90
|
+
name: string;
|
|
91
|
+
args: Expr[];
|
|
92
|
+
span: Span;
|
|
93
|
+
} | {
|
|
94
|
+
type: "Index";
|
|
95
|
+
base: Expr;
|
|
96
|
+
indices: Expr[];
|
|
97
|
+
span: Span;
|
|
98
|
+
} | {
|
|
99
|
+
type: "IndexCell";
|
|
100
|
+
base: Expr;
|
|
101
|
+
indices: Expr[];
|
|
102
|
+
span: Span;
|
|
103
|
+
} | {
|
|
104
|
+
type: "Member";
|
|
105
|
+
base: Expr;
|
|
106
|
+
name: string;
|
|
107
|
+
span: Span;
|
|
108
|
+
} | {
|
|
109
|
+
type: "MemberDynamic";
|
|
110
|
+
base: Expr;
|
|
111
|
+
nameExpr: Expr;
|
|
112
|
+
span: Span;
|
|
113
|
+
} | {
|
|
114
|
+
type: "MethodCall";
|
|
115
|
+
base: Expr;
|
|
116
|
+
name: string;
|
|
117
|
+
args: Expr[];
|
|
118
|
+
span: Span;
|
|
119
|
+
} | {
|
|
120
|
+
type: "SuperMethodCall";
|
|
121
|
+
methodName: string;
|
|
122
|
+
superClassName: string;
|
|
123
|
+
args: Expr[];
|
|
124
|
+
span: Span;
|
|
125
|
+
} | {
|
|
126
|
+
type: "AnonFunc";
|
|
127
|
+
params: string[];
|
|
128
|
+
body: Expr;
|
|
129
|
+
span: Span;
|
|
130
|
+
} | {
|
|
131
|
+
type: "FuncHandle";
|
|
132
|
+
name: string;
|
|
133
|
+
span: Span;
|
|
134
|
+
} | {
|
|
135
|
+
type: "Tensor";
|
|
136
|
+
rows: Expr[][];
|
|
137
|
+
span: Span;
|
|
138
|
+
} | {
|
|
139
|
+
type: "Cell";
|
|
140
|
+
rows: Expr[][];
|
|
141
|
+
span: Span;
|
|
142
|
+
} | {
|
|
143
|
+
type: "ClassInstantiation";
|
|
144
|
+
className: string;
|
|
145
|
+
args: Expr[];
|
|
146
|
+
span: Span;
|
|
147
|
+
};
|
|
148
|
+
export type LValue = {
|
|
149
|
+
type: "Var";
|
|
150
|
+
name: string;
|
|
151
|
+
} | {
|
|
152
|
+
type: "Ignore";
|
|
153
|
+
} | {
|
|
154
|
+
type: "Index";
|
|
155
|
+
base: Expr;
|
|
156
|
+
indices: Expr[];
|
|
157
|
+
} | {
|
|
158
|
+
type: "IndexCell";
|
|
159
|
+
base: Expr;
|
|
160
|
+
indices: Expr[];
|
|
161
|
+
} | {
|
|
162
|
+
type: "Member";
|
|
163
|
+
base: Expr;
|
|
164
|
+
name: string;
|
|
165
|
+
} | {
|
|
166
|
+
type: "MemberDynamic";
|
|
167
|
+
base: Expr;
|
|
168
|
+
nameExpr: Expr;
|
|
169
|
+
};
|
|
170
|
+
export interface Attr {
|
|
171
|
+
name: string;
|
|
172
|
+
value: string | null;
|
|
173
|
+
}
|
|
174
|
+
export interface MethodSignature {
|
|
175
|
+
name: string;
|
|
176
|
+
params: string[];
|
|
177
|
+
outputs: string[];
|
|
178
|
+
span: Span;
|
|
179
|
+
}
|
|
180
|
+
export type ClassMember = {
|
|
181
|
+
type: "Properties";
|
|
182
|
+
attributes: Attr[];
|
|
183
|
+
names: string[];
|
|
184
|
+
defaultValues: (Expr | null)[];
|
|
185
|
+
} | {
|
|
186
|
+
type: "Methods";
|
|
187
|
+
attributes: Attr[];
|
|
188
|
+
body: Stmt[];
|
|
189
|
+
signatures?: MethodSignature[];
|
|
190
|
+
} | {
|
|
191
|
+
type: "Events";
|
|
192
|
+
attributes: Attr[];
|
|
193
|
+
names: string[];
|
|
194
|
+
} | {
|
|
195
|
+
type: "Enumeration";
|
|
196
|
+
attributes: Attr[];
|
|
197
|
+
names: string[];
|
|
198
|
+
} | {
|
|
199
|
+
type: "Arguments";
|
|
200
|
+
attributes: Attr[];
|
|
201
|
+
names: string[];
|
|
202
|
+
};
|
|
203
|
+
export type ArgumentsBlockKind = "Input" | "Output" | "Repeating" | "OutputRepeating";
|
|
204
|
+
export interface ArgumentEntry {
|
|
205
|
+
name: string;
|
|
206
|
+
dimensions: string[] | null;
|
|
207
|
+
className: string | null;
|
|
208
|
+
validators: string[];
|
|
209
|
+
defaultValue: Expr | null;
|
|
210
|
+
}
|
|
211
|
+
export interface ArgumentsBlock {
|
|
212
|
+
kind: ArgumentsBlockKind;
|
|
213
|
+
entries: ArgumentEntry[];
|
|
214
|
+
}
|
|
215
|
+
export type Stmt = {
|
|
216
|
+
type: "ExprStmt";
|
|
217
|
+
expr: Expr;
|
|
218
|
+
suppressed: boolean;
|
|
219
|
+
span: Span;
|
|
220
|
+
} | {
|
|
221
|
+
type: "Assign";
|
|
222
|
+
name: string;
|
|
223
|
+
expr: Expr;
|
|
224
|
+
suppressed: boolean;
|
|
225
|
+
span: Span;
|
|
226
|
+
} | {
|
|
227
|
+
type: "MultiAssign";
|
|
228
|
+
lvalues: LValue[];
|
|
229
|
+
expr: Expr;
|
|
230
|
+
suppressed: boolean;
|
|
231
|
+
span: Span;
|
|
232
|
+
} | {
|
|
233
|
+
type: "AssignLValue";
|
|
234
|
+
lvalue: LValue;
|
|
235
|
+
expr: Expr;
|
|
236
|
+
suppressed: boolean;
|
|
237
|
+
span: Span;
|
|
238
|
+
} | {
|
|
239
|
+
type: "If";
|
|
240
|
+
cond: Expr;
|
|
241
|
+
thenBody: Stmt[];
|
|
242
|
+
elseifBlocks: Array<{
|
|
243
|
+
cond: Expr;
|
|
244
|
+
body: Stmt[];
|
|
245
|
+
}>;
|
|
246
|
+
elseBody: Stmt[] | null;
|
|
247
|
+
span: Span;
|
|
248
|
+
} | {
|
|
249
|
+
type: "While";
|
|
250
|
+
cond: Expr;
|
|
251
|
+
body: Stmt[];
|
|
252
|
+
span: Span;
|
|
253
|
+
} | {
|
|
254
|
+
type: "For";
|
|
255
|
+
varName: string;
|
|
256
|
+
expr: Expr;
|
|
257
|
+
body: Stmt[];
|
|
258
|
+
span: Span;
|
|
259
|
+
} | {
|
|
260
|
+
type: "Switch";
|
|
261
|
+
expr: Expr;
|
|
262
|
+
cases: Array<{
|
|
263
|
+
value: Expr;
|
|
264
|
+
body: Stmt[];
|
|
265
|
+
}>;
|
|
266
|
+
otherwise: Stmt[] | null;
|
|
267
|
+
span: Span;
|
|
268
|
+
} | {
|
|
269
|
+
type: "TryCatch";
|
|
270
|
+
tryBody: Stmt[];
|
|
271
|
+
catchVar: string | null;
|
|
272
|
+
catchBody: Stmt[];
|
|
273
|
+
span: Span;
|
|
274
|
+
} | {
|
|
275
|
+
type: "Function";
|
|
276
|
+
name: string;
|
|
277
|
+
functionId: string;
|
|
278
|
+
params: string[];
|
|
279
|
+
outputs: string[];
|
|
280
|
+
body: Stmt[];
|
|
281
|
+
argumentsBlocks: ArgumentsBlock[];
|
|
282
|
+
isFileLocalSubfunction?: boolean;
|
|
283
|
+
span: Span;
|
|
284
|
+
} | {
|
|
285
|
+
type: "Global";
|
|
286
|
+
names: string[];
|
|
287
|
+
span: Span;
|
|
288
|
+
} | {
|
|
289
|
+
type: "Persistent";
|
|
290
|
+
names: string[];
|
|
291
|
+
span: Span;
|
|
292
|
+
} | {
|
|
293
|
+
type: "Break";
|
|
294
|
+
span: Span;
|
|
295
|
+
} | {
|
|
296
|
+
type: "Continue";
|
|
297
|
+
span: Span;
|
|
298
|
+
} | {
|
|
299
|
+
type: "Return";
|
|
300
|
+
span: Span;
|
|
301
|
+
} | {
|
|
302
|
+
type: "Import";
|
|
303
|
+
path: string[];
|
|
304
|
+
wildcard: boolean;
|
|
305
|
+
span: Span;
|
|
306
|
+
} | {
|
|
307
|
+
type: "ClassDef";
|
|
308
|
+
name: string;
|
|
309
|
+
classAttributes: Attr[];
|
|
310
|
+
superClass: string | null;
|
|
311
|
+
members: ClassMember[];
|
|
312
|
+
span: Span;
|
|
313
|
+
};
|
|
314
|
+
export interface AbstractSyntaxTree {
|
|
315
|
+
body: Stmt[];
|
|
316
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RuntimeValue constructor helpers (the MV namespace).
|
|
3
|
+
*/
|
|
4
|
+
import { ItemType } from "../lowering/itemTypes.js";
|
|
5
|
+
import { type RuntimeNumber, type RuntimeTensor, type RuntimeString, type RuntimeChar, type RuntimeLogical, type RuntimeCell, type RuntimeStruct, type RuntimeFunction, type RuntimeClassInstance, type RuntimeComplexNumber, type RuntimeDummyHandle, type RuntimeStructArray, type RuntimeSparseMatrix, type RuntimeDictionary, type RuntimeValue, type FloatXArrayType } from "./types.js";
|
|
6
|
+
export declare const RTV: {
|
|
7
|
+
num(value: number): RuntimeNumber;
|
|
8
|
+
tensor(data: FloatXArrayType | number[], shape: number[], imag?: FloatXArrayType | number[]): RuntimeTensor;
|
|
9
|
+
/** Fast tensor constructor — data must be FloatXArray, shape already normalized (no trailing singletons). */
|
|
10
|
+
tensorRaw(data: FloatXArrayType, shape: number[]): RuntimeTensor;
|
|
11
|
+
/** Create a scalar tensor (1x1) */
|
|
12
|
+
scalar(value: number): RuntimeNumber;
|
|
13
|
+
/** Create a row vector [1 x n] */
|
|
14
|
+
row(data: number[], imag?: number[]): RuntimeTensor;
|
|
15
|
+
/** Create a column vector [n x 1] */
|
|
16
|
+
col(data: number[], imag?: number[]): RuntimeTensor;
|
|
17
|
+
/** Create a matrix from row-major data */
|
|
18
|
+
matrix(rows: number, cols: number, data: number[] | FloatXArrayType, imag?: number[] | FloatXArrayType): RuntimeTensor;
|
|
19
|
+
string(value: string): RuntimeString;
|
|
20
|
+
char(value: string): RuntimeChar;
|
|
21
|
+
logical(value: boolean): RuntimeLogical;
|
|
22
|
+
cell(data: RuntimeValue[], shape: number[]): RuntimeCell;
|
|
23
|
+
struct(fields: Map<string, RuntimeValue> | Record<string, RuntimeValue>): RuntimeStruct;
|
|
24
|
+
func(name: string, impl: "builtin" | "user", captures?: RuntimeValue[]): RuntimeFunction;
|
|
25
|
+
classInstance(className: string, propertyNames: string[], isHandleClass?: boolean, defaults?: Map<string, RuntimeValue>): RuntimeClassInstance;
|
|
26
|
+
complex(re: number, im: number): RuntimeComplexNumber;
|
|
27
|
+
dummyHandle(): RuntimeDummyHandle;
|
|
28
|
+
structArray(fieldNames: string[], elements: RuntimeStruct[]): RuntimeStructArray;
|
|
29
|
+
sparseMatrix(m: number, n: number, ir: Int32Array, jc: Int32Array, pr: Float64Array, pi?: Float64Array): RuntimeSparseMatrix;
|
|
30
|
+
dictionary(entries?: Map<string, {
|
|
31
|
+
key: RuntimeValue;
|
|
32
|
+
value: RuntimeValue;
|
|
33
|
+
}>, keyType?: string, valueType?: string): RuntimeDictionary;
|
|
34
|
+
};
|
|
35
|
+
export declare const getItemTypeFromRuntimeValue: (value: RuntimeValue) => ItemType;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value conversion helpers and equality.
|
|
3
|
+
*/
|
|
4
|
+
import { type RuntimeValue } from "./types.js";
|
|
5
|
+
/** Extract a JS number from an RuntimeValue (scalar num, logical, or 1x1 tensor) */
|
|
6
|
+
export declare function toNumber(v: RuntimeValue): number;
|
|
7
|
+
/** Extract a boolean from an RuntimeValue */
|
|
8
|
+
export declare function toBool(v: RuntimeValue): boolean;
|
|
9
|
+
/** Extract a string from an RuntimeValue */
|
|
10
|
+
export declare function toString(v: RuntimeValue): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime error type and source location utilities.
|
|
3
|
+
*/
|
|
4
|
+
export interface Span {
|
|
5
|
+
file: string;
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
}
|
|
9
|
+
export type CallFrame = {
|
|
10
|
+
name: string;
|
|
11
|
+
callerFile: string | null;
|
|
12
|
+
callerLine: number;
|
|
13
|
+
/** Trimmed source text at callerLine (populated during error enrichment) */
|
|
14
|
+
callerSourceLine?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare class RuntimeError extends Error {
|
|
17
|
+
/** Source span where the error occurred (carries file name + per-file offsets) */
|
|
18
|
+
span: Span | null;
|
|
19
|
+
/** 1-based line number (set when source is available) */
|
|
20
|
+
line: number | null;
|
|
21
|
+
/** 1-based column number (set when source is available) */
|
|
22
|
+
column: number | null;
|
|
23
|
+
/** Source file name (set from span or by error handler) */
|
|
24
|
+
file: string | null;
|
|
25
|
+
/** Code snippet showing error context */
|
|
26
|
+
snippet: string | null;
|
|
27
|
+
/** Underlying cause (for chained errors) */
|
|
28
|
+
cause?: Error;
|
|
29
|
+
/** Call stack at the time of the error (null = not yet captured) */
|
|
30
|
+
callStack: CallFrame[] | null;
|
|
31
|
+
/** Error identifier (e.g. 'myid:myerr') */
|
|
32
|
+
identifier: string;
|
|
33
|
+
/** File sources for resolving source lines in call stack display */
|
|
34
|
+
fileSources: Map<string, string> | null;
|
|
35
|
+
constructor(message: string, span?: Span | null);
|
|
36
|
+
/**
|
|
37
|
+
* Attach source location span to this error.
|
|
38
|
+
*/
|
|
39
|
+
withSpan(span: Span): RuntimeError;
|
|
40
|
+
/**
|
|
41
|
+
* Enrich error with line/column/snippet from the file's source text.
|
|
42
|
+
* The fileSources map provides filename → source text lookups.
|
|
43
|
+
*/
|
|
44
|
+
withContext(fileSources: Map<string, string>): RuntimeError;
|
|
45
|
+
/**
|
|
46
|
+
* Format error with location and snippet context.
|
|
47
|
+
*/
|
|
48
|
+
toString(): string;
|
|
49
|
+
/** Look up a single trimmed source line from fileSources. */
|
|
50
|
+
private _getSourceLine;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Compute 1-based line number from a character offset in source text.
|
|
54
|
+
*/
|
|
55
|
+
export declare function offsetToLine(source: string, offset: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* Build an array of newline character positions for fast offset→line lookup.
|
|
58
|
+
* Returns a sorted array where lineBreaks[i] is the offset of the (i+1)th '\n'.
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildLineTable(source: string): number[];
|
|
61
|
+
/**
|
|
62
|
+
* Compute 1-based line number from a character offset using a pre-built line table.
|
|
63
|
+
* Uses binary search — O(log n) instead of O(n).
|
|
64
|
+
*/
|
|
65
|
+
export declare function offsetToLineFast(lineBreaks: number[], offset: number): number;
|
|
66
|
+
/**
|
|
67
|
+
* Compute 1-based column number from a character offset in source text.
|
|
68
|
+
*/
|
|
69
|
+
export declare function offsetToColumn(source: string, offset: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* Extract code snippet with context lines around the error location.
|
|
72
|
+
*/
|
|
73
|
+
export declare function extractSnippet(source: string, offset: number, contextLines?: number): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type { RuntimeValue, RuntimeTensor, RuntimeString, RuntimeLogical, RuntimeCell, RuntimeStruct, RuntimeFunction, RuntimeDictionary, } from "./types.js";
|
|
2
|
+
export { RuntimeError, offsetToLine, offsetToColumn } from "./error.js";
|
|
3
|
+
export type { CallFrame } from "./error.js";
|
|
4
|
+
export { tensorSize2D, numel, colMajorIndex, shareRuntimeValue, } from "./utils.js";
|
|
5
|
+
export { toNumber, toBool, toString } from "./convert.js";
|
|
6
|
+
export { valuesAreEqual } from "./compare.js";
|
|
7
|
+
export { displayValue } from "./display.js";
|
|
8
|
+
export { RTV } from "./constructors.js";
|
|
9
|
+
export { mAdd, mSub, mMul, mElemMul, mDiv, mElemDiv, mPow, mElemPow, mNeg, mTranspose, mConjugateTranspose, mEqual, mNotEqual, mLess, mLessEqual, mGreater, mGreaterEqual, } from "../helpers/arithmetic.js";
|
|
10
|
+
export { COLON_INDEX, indexIntoRTValue as mIndex, storeIntoRTValueIndex as mIndexStore, } from "./indexing.js";
|
|
11
|
+
export { getRTValueField as mGetField, setRTValueField as mSetField, } from "./struct-access.js";
|
|
12
|
+
export { makeRangeTensor as mRange, horzcat, vertcat, } from "./tensor-construction.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indexing, struct field access, range creation, and tensor concatenation.
|
|
3
|
+
*/
|
|
4
|
+
import { type RuntimeValue } from "./types.js";
|
|
5
|
+
/** Sentinel marker for colon (:) indexing — means "all indices in this dimension" */
|
|
6
|
+
export declare const COLON_INDEX: RuntimeValue;
|
|
7
|
+
/** Index into a value: v(i1, i2, ...) */
|
|
8
|
+
export declare function indexIntoRTValue(base: RuntimeValue, indices: RuntimeValue[]): RuntimeValue;
|
|
9
|
+
/** Store into indexed position: base(indices) = rhs — uses copy-on-write for shared data */
|
|
10
|
+
export declare function storeIntoRTValueIndex(base: RuntimeValue, indices: RuntimeValue[], rhs: RuntimeValue, parenAssign?: boolean): RuntimeValue;
|