@cortex-js/compute-engine 0.31.0 → 0.32.0
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/package.json +1 -1
- package/dist/compute-engine.esm.js +0 -41311
- package/dist/compute-engine.min.esm.js +0 -125
- package/dist/compute-engine.min.umd.js +0 -127
- package/dist/compute-engine.umd.js +0 -41336
- package/dist/math-json.esm.js +0 -130
- package/dist/math-json.min.esm.js +0 -130
- package/dist/math-json.min.umd.js +0 -4
- package/dist/math-json.umd.js +0 -155
- package/dist/types/common/ansi-codes.d.ts +0 -41
- package/dist/types/common/configuration-change.d.ts +0 -28
- package/dist/types/common/fuzzy-string-match.d.ts +0 -2
- package/dist/types/common/grapheme-splitter.d.ts +0 -15
- package/dist/types/common/interruptible.d.ts +0 -20
- package/dist/types/common/one-of.d.ts +0 -10
- package/dist/types/common/signals.d.ts +0 -96
- package/dist/types/common/type/ast-nodes.d.ts +0 -146
- package/dist/types/common/type/boxed-type.d.ts +0 -30
- package/dist/types/common/type/lexer.d.ts +0 -51
- package/dist/types/common/type/parse.d.ts +0 -211
- package/dist/types/common/type/parser.d.ts +0 -45
- package/dist/types/common/type/primitive.d.ts +0 -10
- package/dist/types/common/type/serialize.d.ts +0 -2
- package/dist/types/common/type/subtype.d.ts +0 -6
- package/dist/types/common/type/type-builder.d.ts +0 -32
- package/dist/types/common/type/types.d.ts +0 -300
- package/dist/types/common/type/utils.d.ts +0 -36
- package/dist/types/common/utils.d.ts +0 -23
- package/dist/types/compute-engine/assume.d.ts +0 -26
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +0 -165
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +0 -5
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +0 -16
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +0 -27
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +0 -38
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +0 -11
- package/dist/types/compute-engine/boxed-expression/box.d.ts +0 -47
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +0 -44
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +0 -136
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +0 -103
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +0 -53
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +0 -107
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +0 -27
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +0 -170
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +0 -83
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +0 -46
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +0 -7
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +0 -5
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +0 -2
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +0 -13
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +0 -20
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +0 -12
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +0 -10
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +0 -25
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +0 -10
- package/dist/types/compute-engine/boxed-expression/match.d.ts +0 -19
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +0 -11
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +0 -34
- package/dist/types/compute-engine/boxed-expression/order.d.ts +0 -71
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +0 -105
- package/dist/types/compute-engine/boxed-expression/product.d.ts +0 -66
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +0 -129
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +0 -3
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +0 -46
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +0 -6
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +0 -20
- package/dist/types/compute-engine/boxed-expression/terms.d.ts +0 -10
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +0 -9
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +0 -64
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +0 -58
- package/dist/types/compute-engine/collection-utils.d.ts +0 -35
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +0 -31
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +0 -68
- package/dist/types/compute-engine/compilation/types.d.ts +0 -83
- package/dist/types/compute-engine/cost-function.d.ts +0 -13
- package/dist/types/compute-engine/function-utils.d.ts +0 -120
- package/dist/types/compute-engine/global-types.d.ts +0 -2930
- package/dist/types/compute-engine/index.d.ts +0 -660
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +0 -27
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +0 -3
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +0 -2
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +0 -88
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +0 -21
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +0 -303
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +0 -29
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +0 -10
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +0 -37
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +0 -18
- package/dist/types/compute-engine/latex-syntax/types.d.ts +0 -845
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +0 -5
- package/dist/types/compute-engine/library/arithmetic.d.ts +0 -4
- package/dist/types/compute-engine/library/calculus.d.ts +0 -2
- package/dist/types/compute-engine/library/collections.d.ts +0 -27
- package/dist/types/compute-engine/library/combinatorics.d.ts +0 -2
- package/dist/types/compute-engine/library/complex.d.ts +0 -2
- package/dist/types/compute-engine/library/control-structures.d.ts +0 -2
- package/dist/types/compute-engine/library/core.d.ts +0 -2
- package/dist/types/compute-engine/library/invisible-operator.d.ts +0 -4
- package/dist/types/compute-engine/library/library.d.ts +0 -17
- package/dist/types/compute-engine/library/linear-algebra.d.ts +0 -2
- package/dist/types/compute-engine/library/logic.d.ts +0 -6
- package/dist/types/compute-engine/library/number-theory.d.ts +0 -2
- package/dist/types/compute-engine/library/polynomials.d.ts +0 -2
- package/dist/types/compute-engine/library/random-expression.d.ts +0 -2
- package/dist/types/compute-engine/library/relational-operator.d.ts +0 -2
- package/dist/types/compute-engine/library/sets.d.ts +0 -2
- package/dist/types/compute-engine/library/statistics.d.ts +0 -2
- package/dist/types/compute-engine/library/trigonometry.d.ts +0 -2
- package/dist/types/compute-engine/library/utils.d.ts +0 -77
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +0 -57
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +0 -75
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +0 -56
- package/dist/types/compute-engine/numeric-value/types.d.ts +0 -116
- package/dist/types/compute-engine/numerics/bigint.d.ts +0 -2
- package/dist/types/compute-engine/numerics/expression.d.ts +0 -4
- package/dist/types/compute-engine/numerics/interval.d.ts +0 -12
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +0 -4
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +0 -18
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +0 -9
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +0 -3
- package/dist/types/compute-engine/numerics/numeric.d.ts +0 -60
- package/dist/types/compute-engine/numerics/primes.d.ts +0 -7
- package/dist/types/compute-engine/numerics/rationals.d.ts +0 -43
- package/dist/types/compute-engine/numerics/richardson.d.ts +0 -80
- package/dist/types/compute-engine/numerics/special-functions.d.ts +0 -28
- package/dist/types/compute-engine/numerics/statistics.d.ts +0 -24
- package/dist/types/compute-engine/numerics/strings.d.ts +0 -2
- package/dist/types/compute-engine/numerics/types.d.ts +0 -30
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +0 -3
- package/dist/types/compute-engine/symbolic/derivative.d.ts +0 -18
- package/dist/types/compute-engine/symbolic/distribute.d.ts +0 -5
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +0 -27
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +0 -128
- package/dist/types/compute-engine/tensor/tensors.d.ts +0 -93
- package/dist/types/compute-engine/types.d.ts +0 -8
- package/dist/types/compute-engine.d.ts +0 -3
- package/dist/types/math-json/symbols.d.ts +0 -11
- package/dist/types/math-json/types.d.ts +0 -122
- package/dist/types/math-json/utils.d.ts +0 -87
- package/dist/types/math-json.d.ts +0 -3
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/* 0.31.0 */
|
|
2
|
-
import { Delimiter, EnvironmentParseHandler, ExpressionParseHandler, InfixParseHandler, LatexDictionary, LatexDictionaryEntry, LatexString, LatexToken, LibraryCategory, MatchfixParseHandler, PostfixParseHandler, Precedence, SerializeHandler } from '../types';
|
|
3
|
-
export type CommonEntry = {
|
|
4
|
-
/** Note: a name is required if a serialize handler is provided */
|
|
5
|
-
name?: string;
|
|
6
|
-
serialize?: SerializeHandler;
|
|
7
|
-
/** Note: not all kinds have a `latexTrigger` or `symbolTrigger`.
|
|
8
|
-
* For example, matchfix operators use `openTrigger`/`closeTrigger`
|
|
9
|
-
*/
|
|
10
|
-
latexTrigger?: LatexString;
|
|
11
|
-
symbolTrigger?: string;
|
|
12
|
-
};
|
|
13
|
-
export type IndexedSymbolEntry = CommonEntry & {
|
|
14
|
-
kind: 'symbol';
|
|
15
|
-
precedence: Precedence;
|
|
16
|
-
parse: ExpressionParseHandler;
|
|
17
|
-
};
|
|
18
|
-
/** @internal */
|
|
19
|
-
export declare function isIndexedSymbolEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedSymbolEntry;
|
|
20
|
-
export type IndexedExpressionEntry = CommonEntry & {
|
|
21
|
-
kind: 'expression';
|
|
22
|
-
precedence: Precedence;
|
|
23
|
-
parse: ExpressionParseHandler;
|
|
24
|
-
};
|
|
25
|
-
/** @internal */
|
|
26
|
-
export declare function isIndexedExpressionEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedExpressionEntry;
|
|
27
|
-
/**
|
|
28
|
-
* A function has the following form:
|
|
29
|
-
* - a prefix such as `\mathrm` or `\operatorname`
|
|
30
|
-
* - a trigger string, such as `gcd`
|
|
31
|
-
* - some postfix operators such as `\prime`
|
|
32
|
-
* - an optional list of arguments in an enclosure (parentheses)
|
|
33
|
-
*
|
|
34
|
-
* Functions of this type are indexed in the dictionary by their trigger string.
|
|
35
|
-
*/
|
|
36
|
-
export type IndexedFunctionEntry = CommonEntry & {
|
|
37
|
-
kind: 'function';
|
|
38
|
-
parse: ExpressionParseHandler;
|
|
39
|
-
};
|
|
40
|
-
/** @internal */
|
|
41
|
-
export declare function isIndexedFunctionEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedFunctionEntry;
|
|
42
|
-
export type IndexedMatchfixEntry = CommonEntry & {
|
|
43
|
-
kind: 'matchfix';
|
|
44
|
-
openTrigger: Delimiter | LatexToken[];
|
|
45
|
-
closeTrigger: Delimiter | LatexToken[];
|
|
46
|
-
parse: MatchfixParseHandler;
|
|
47
|
-
};
|
|
48
|
-
/** @internal */
|
|
49
|
-
export declare function isIndexedMatchfixEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedMatchfixEntry;
|
|
50
|
-
export type IndexedInfixEntry = CommonEntry & {
|
|
51
|
-
kind: 'infix';
|
|
52
|
-
associativity: 'right' | 'left' | 'none' | 'any';
|
|
53
|
-
precedence: Precedence;
|
|
54
|
-
parse: InfixParseHandler;
|
|
55
|
-
};
|
|
56
|
-
/** @internal */
|
|
57
|
-
export declare function isIndexedInfixdEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedInfixEntry;
|
|
58
|
-
export type IndexedPrefixEntry = CommonEntry & {
|
|
59
|
-
kind: 'prefix';
|
|
60
|
-
precedence: Precedence;
|
|
61
|
-
parse: ExpressionParseHandler;
|
|
62
|
-
};
|
|
63
|
-
/** @internal */
|
|
64
|
-
export declare function isIndexedPrefixedEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedPostfixEntry;
|
|
65
|
-
export type IndexedPostfixEntry = CommonEntry & {
|
|
66
|
-
kind: 'postfix';
|
|
67
|
-
precedence: Precedence;
|
|
68
|
-
parse: PostfixParseHandler;
|
|
69
|
-
};
|
|
70
|
-
/** @internal */
|
|
71
|
-
export declare function isIndexedPostfixEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedPostfixEntry;
|
|
72
|
-
export type IndexedEnvironmentEntry = CommonEntry & {
|
|
73
|
-
kind: 'environment';
|
|
74
|
-
parse: EnvironmentParseHandler;
|
|
75
|
-
};
|
|
76
|
-
/** @internal */
|
|
77
|
-
export declare function isIndexedEnvironmentEntry(entry: IndexedLatexDictionaryEntry): entry is IndexedEnvironmentEntry;
|
|
78
|
-
export type IndexedLatexDictionaryEntry = IndexedExpressionEntry | IndexedFunctionEntry | IndexedSymbolEntry | IndexedMatchfixEntry | IndexedInfixEntry | IndexedPrefixEntry | IndexedPostfixEntry | IndexedEnvironmentEntry;
|
|
79
|
-
export type IndexedLatexDictionary = {
|
|
80
|
-
ids: Map<string, IndexedLatexDictionaryEntry>;
|
|
81
|
-
lookahead: number;
|
|
82
|
-
defs: IndexedLatexDictionaryEntry[];
|
|
83
|
-
};
|
|
84
|
-
export declare function indexLatexDictionary(dic: Readonly<Partial<LatexDictionaryEntry>[]>, onError: (sig: WarningSignal) => void): IndexedLatexDictionary;
|
|
85
|
-
export declare const DEFAULT_LATEX_DICTIONARY: {
|
|
86
|
-
[category in LibraryCategory]?: LatexDictionary;
|
|
87
|
-
};
|
|
88
|
-
export declare function getLatexDictionary(category?: LibraryCategory | 'all'): readonly Readonly<LatexDictionaryEntry>[];
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/* 0.31.0 */
|
|
2
|
-
import { Parser } from './types';
|
|
3
|
-
/** For error handling, if we have a symbol prefix, assume
|
|
4
|
-
* the symbol is invalid (it would have been captured by
|
|
5
|
-
* `matchSymbol()` otherwise) and return an error expression */
|
|
6
|
-
export declare function parseInvalidSymbol(parser: Parser): Expression | null;
|
|
7
|
-
/**
|
|
8
|
-
* Match a symbol.
|
|
9
|
-
*
|
|
10
|
-
* It can be:
|
|
11
|
-
* - a sequence of emojis: `👍🏻👍🏻👍🏻`
|
|
12
|
-
* - a single-letter: `a`
|
|
13
|
-
* - some LaTeX commands: `\alpha`
|
|
14
|
-
* - a multi-letter id with a prefix: `\operatorname{speed}`
|
|
15
|
-
* - an id with multiple prefixes:
|
|
16
|
-
* `\mathbin{\mathsf{T}}`
|
|
17
|
-
* - an id with modifiers:
|
|
18
|
-
* - `\mathrm{\alpha_{12}}` or
|
|
19
|
-
* - `\mathit{speed\unicode{"2012}of\unicode{"2012}sound}`
|
|
20
|
-
*/
|
|
21
|
-
export declare function parseSymbol(parser: Parser): MathJsonSymbol | null;
|
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
/* 0.31.0 */
|
|
2
|
-
import { ParseLatexOptions, LatexToken, Terminator, Parser, SymbolTable } from './types';
|
|
3
|
-
import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry, IndexedInfixEntry, IndexedPostfixEntry, IndexedPrefixEntry, IndexedSymbolEntry, IndexedExpressionEntry, IndexedFunctionEntry } from './dictionary/definitions';
|
|
4
|
-
import { BoxedType } from '../../common/type/boxed-type';
|
|
5
|
-
import { TypeString } from '../types';
|
|
6
|
-
/**
|
|
7
|
-
* ## THEORY OF OPERATIONS
|
|
8
|
-
*
|
|
9
|
-
* The parser is a recursive descent parser that uses a dictionary of
|
|
10
|
-
* LaTeX commands to parse a LaTeX string into a MathJSON expression.
|
|
11
|
-
*
|
|
12
|
-
* The parser is a stateful object that keeps track of the current position
|
|
13
|
-
* in the token stream, and the boundaries of the current parsing operation.
|
|
14
|
-
*
|
|
15
|
-
* To parse correctly some constructs, the parser needs to know the context
|
|
16
|
-
* in which it is parsing. For example, parsing `k(2+x)` can be interpreted
|
|
17
|
-
* as a function `k` applied to the sum of `2` and `x`, or as the product
|
|
18
|
-
* of `k` and the sum of `2` and `x`. The parser needs to know that `k` is
|
|
19
|
-
* a function to interpret the expression as a function application.
|
|
20
|
-
*
|
|
21
|
-
* The parser uses the current state of the compute engine, and any
|
|
22
|
-
* symbol that may have been declared, to determine the correct
|
|
23
|
-
* interpretation.
|
|
24
|
-
*
|
|
25
|
-
* Some constructs declare variables or functions while parsing. For example,
|
|
26
|
-
* `\sum_{i=1}^n i` declares the variable `i` as the index of the sum.
|
|
27
|
-
*
|
|
28
|
-
* The parser keeps track of the parsing state with a stack of symbol tables.
|
|
29
|
-
*
|
|
30
|
-
* In addition, the handler `getSymbolType()` is called when the parser
|
|
31
|
-
* encounters an unknown symbol. This handler can be used to declare the
|
|
32
|
-
* symbol, or to return `unknown` if the symbol is not known.
|
|
33
|
-
*
|
|
34
|
-
* Some functions affect the state of the parser:
|
|
35
|
-
* - `Declare`, `Assign` modify the symbol table
|
|
36
|
-
* - `Block` create a new symbol table (local scope)
|
|
37
|
-
* - `Function` create a new symbol table with named arguments
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
export declare class _Parser implements Parser {
|
|
42
|
-
readonly options: Readonly<ParseLatexOptions>;
|
|
43
|
-
_index: number;
|
|
44
|
-
symbolTable: SymbolTable;
|
|
45
|
-
pushSymbolTable(): void;
|
|
46
|
-
popSymbolTable(): void;
|
|
47
|
-
addSymbol(id: string, type: BoxedType | TypeString): void;
|
|
48
|
-
get index(): number;
|
|
49
|
-
set index(val: number);
|
|
50
|
-
private _tokens;
|
|
51
|
-
private _positiveInfinityTokens;
|
|
52
|
-
private _negativeInfinityTokens;
|
|
53
|
-
private _notANumberTokens;
|
|
54
|
-
private _decimalSeparatorTokens;
|
|
55
|
-
private _wholeDigitGroupSeparatorTokens;
|
|
56
|
-
private _fractionalDigitGroupSeparatorTokens;
|
|
57
|
-
private _exponentProductTokens;
|
|
58
|
-
private _beginExponentMarkerTokens;
|
|
59
|
-
private _endExponentMarkerTokens;
|
|
60
|
-
private _truncationMarkerTokens;
|
|
61
|
-
private _imaginaryUnitTokens;
|
|
62
|
-
private readonly _dictionary;
|
|
63
|
-
private _boundaries;
|
|
64
|
-
private _lastPeek;
|
|
65
|
-
private _peekCounter;
|
|
66
|
-
constructor(tokens: LatexToken[], dictionary: IndexedLatexDictionary, options: Readonly<ParseLatexOptions>);
|
|
67
|
-
getSymbolType(id: MathJsonSymbol): BoxedType;
|
|
68
|
-
get peek(): LatexToken;
|
|
69
|
-
nextToken(): LatexToken;
|
|
70
|
-
get atEnd(): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Return true if
|
|
73
|
-
* - at end of the token stream
|
|
74
|
-
* - the `t.condition` function returns true
|
|
75
|
-
* Note: the `minPrec` condition is not checked. It should be checked separately.
|
|
76
|
-
*/
|
|
77
|
-
atTerminator(t?: Readonly<Terminator>): boolean;
|
|
78
|
-
/**
|
|
79
|
-
* True if the current token matches any of the boundaries we are
|
|
80
|
-
* waiting for.
|
|
81
|
-
*/
|
|
82
|
-
get atBoundary(): boolean;
|
|
83
|
-
addBoundary(boundary: LatexToken[]): void;
|
|
84
|
-
removeBoundary(): void;
|
|
85
|
-
matchBoundary(): boolean;
|
|
86
|
-
boundaryError(msg: string | [string, ...Expression[]]): Expression;
|
|
87
|
-
latex(start: number, end?: number): string;
|
|
88
|
-
private latexAhead;
|
|
89
|
-
/**
|
|
90
|
-
* Return at most `this._dictionary.lookahead` LaTeX tokens.
|
|
91
|
-
*
|
|
92
|
-
* The index in the returned array correspond to the number of tokens.
|
|
93
|
-
* Note that since a token can be longer than one char ('\\pi', but also
|
|
94
|
-
* some astral plane unicode characters), the length of the string
|
|
95
|
-
* does not match that index. However, knowing the index is important
|
|
96
|
-
* to know by how many tokens to advance.
|
|
97
|
-
*
|
|
98
|
-
* For example:
|
|
99
|
-
*
|
|
100
|
-
* `[empty, '\\sqrt', '\\sqrt{', '\\sqrt{2', '\\sqrt{2}']`
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
lookAhead(): [count: number, tokens: string][];
|
|
104
|
-
/** Return all the definitions that match the tokens ahead
|
|
105
|
-
*
|
|
106
|
-
* The return value is an array of pairs `[def, n]` where `def` is the
|
|
107
|
-
* definition that matches the tokens ahead, and `n` is the number of tokens
|
|
108
|
-
* that matched.
|
|
109
|
-
*
|
|
110
|
-
* Note the 'operator' kind matches both infix, prefix and postfix operators.
|
|
111
|
-
*
|
|
112
|
-
*/
|
|
113
|
-
peekDefinitions(kind: 'expression'): [IndexedExpressionEntry, number][];
|
|
114
|
-
peekDefinitions(kind: 'function'): [IndexedFunctionEntry, number][];
|
|
115
|
-
peekDefinitions(kind: 'symbol'): [IndexedSymbolEntry, number][];
|
|
116
|
-
peekDefinitions(kind: 'postfix'): [IndexedPostfixEntry, number][];
|
|
117
|
-
peekDefinitions(kind: 'infix'): [IndexedInfixEntry, number][];
|
|
118
|
-
peekDefinitions(kind: 'prefix'): [IndexedPrefixEntry, number][];
|
|
119
|
-
peekDefinitions(kind: 'operator'): [IndexedInfixEntry | IndexedPrefixEntry | IndexedPostfixEntry, number][];
|
|
120
|
-
/** Skip strictly `<space>` tokens.
|
|
121
|
-
* To also skip `{}` see `skipSpace()`.
|
|
122
|
-
* To skip visual space (e.g. `\,`) see `skipVisualSpace()`.
|
|
123
|
-
*/
|
|
124
|
-
skipSpaceTokens(): void;
|
|
125
|
-
/** While parsing in math mode, skip applicable spaces, which includes `{}`.
|
|
126
|
-
* Do not use to skip spaces while parsing a string. See `skipSpaceTokens()`
|
|
127
|
-
* instead.
|
|
128
|
-
*/
|
|
129
|
-
skipSpace(): boolean;
|
|
130
|
-
skipVisualSpace(): void;
|
|
131
|
-
match(token: LatexToken): boolean;
|
|
132
|
-
matchAll(tokens: LatexToken[]): boolean;
|
|
133
|
-
matchAny(tokens: LatexToken[]): LatexToken;
|
|
134
|
-
/**
|
|
135
|
-
* A Latex number can be a decimal, hex or octal number.
|
|
136
|
-
* It is used in some Latex commands, such as `\char`
|
|
137
|
-
*
|
|
138
|
-
* From TeX:8695 (scan_int):
|
|
139
|
-
* > An integer number can be preceded by any number of spaces and `+' or
|
|
140
|
-
* > `-' signs. Then comes either a decimal constant (i.e., radix 10), an
|
|
141
|
-
* > octal constant (i.e., radix 8, preceded by '), a hexadecimal constant
|
|
142
|
-
* > (radix 16, preceded by "), an alphabetic constant (preceded by `), or
|
|
143
|
-
* > an internal variable.
|
|
144
|
-
*/
|
|
145
|
-
parseLatexNumber(isInteger?: boolean): null | number;
|
|
146
|
-
parseChar(): string | null;
|
|
147
|
-
/**
|
|
148
|
-
*
|
|
149
|
-
* If the next token matches the open delimiter, set a boundary with
|
|
150
|
-
* the close token and return true.
|
|
151
|
-
*
|
|
152
|
-
* This method handles prefixes like `\left` and `\bigl`.
|
|
153
|
-
*
|
|
154
|
-
* It also handles "shorthand" delimiters, i.e. '(' will match both
|
|
155
|
-
* `(` and `\lparen`. If a shorthand is used for the open delimiter, the
|
|
156
|
-
* corresponding shorthand will be used for the close delimiter.
|
|
157
|
-
* See DELIMITER_SHORTHAND.
|
|
158
|
-
*
|
|
159
|
-
*/
|
|
160
|
-
private matchDelimiter;
|
|
161
|
-
parseGroup(): Expression | null;
|
|
162
|
-
parseOptionalGroup(): Expression | null;
|
|
163
|
-
parseToken(): Expression | null;
|
|
164
|
-
/**
|
|
165
|
-
* Parse an expression in a tabular format, where rows are separated by `\\`
|
|
166
|
-
* and columns by `&`.
|
|
167
|
-
*
|
|
168
|
-
* Return rows of sparse columns: empty rows are indicated with `Nothing`,
|
|
169
|
-
* and empty cells are also indicated with `Nothing`.
|
|
170
|
-
*/
|
|
171
|
-
parseTabular(): null | Expression[][];
|
|
172
|
-
/** Match a string used as a LaTeX symbol, for example an environment
|
|
173
|
-
* name.
|
|
174
|
-
* Not suitable for general purpose text, e.g. argument of a `\text{}
|
|
175
|
-
* command. See `matchChar()` instead.
|
|
176
|
-
*/
|
|
177
|
-
private parseStringGroupContent;
|
|
178
|
-
/** Parse a group as a a string, for example for `\operatorname` or `\begin` */
|
|
179
|
-
parseStringGroup(optional?: boolean): string | null;
|
|
180
|
-
/** Parse an environment: `\begin{env}...\end{end}`
|
|
181
|
-
*/
|
|
182
|
-
private parseEnvironment;
|
|
183
|
-
/** If the next token matches a `-` sign, return '-', otherwise return '+'
|
|
184
|
-
*
|
|
185
|
-
*/
|
|
186
|
-
private parseOptionalSign;
|
|
187
|
-
/** Parse a sequence of decimal digits. The part indicates which
|
|
188
|
-
* grouping separator should be expected.
|
|
189
|
-
*/
|
|
190
|
-
private parseDecimalDigits;
|
|
191
|
-
/** The 'part' argument is used to dermine what grouping separator
|
|
192
|
-
* should be expected.
|
|
193
|
-
*/
|
|
194
|
-
private parseSignedInteger;
|
|
195
|
-
private parseExponent;
|
|
196
|
-
parseRepeatingDecimal(): string;
|
|
197
|
-
/**
|
|
198
|
-
* Parse a number, with an optional sign, exponent, decimal marker,
|
|
199
|
-
* repeating decimals, etc...
|
|
200
|
-
*/
|
|
201
|
-
parseNumber(): Expression | null;
|
|
202
|
-
private parsePrefixOperator;
|
|
203
|
-
private parseInfixOperator;
|
|
204
|
-
/**
|
|
205
|
-
* This returns an array of arguments (as in a function application),
|
|
206
|
-
* or null if there is no match.
|
|
207
|
-
*
|
|
208
|
-
* - 'enclosure' : will look for an argument inside an enclosure
|
|
209
|
-
* (open/close fence)
|
|
210
|
-
* - 'implicit': either an expression inside a pair of `()`, or just a product
|
|
211
|
-
* (i.e. we interpret `\cos 2x + 1` as `\cos(2x) + 1`)
|
|
212
|
-
*
|
|
213
|
-
*/
|
|
214
|
-
parseArguments(kind?: 'enclosure' | 'implicit', until?: Readonly<Terminator>): ReadonlyArray<Expression> | null;
|
|
215
|
-
/**
|
|
216
|
-
* An enclosure is an opening matchfix operator, an optional expression,
|
|
217
|
-
* optionally followed multiple times by a separator and another expression,
|
|
218
|
-
* and finally a closing matching operator.
|
|
219
|
-
*/
|
|
220
|
-
parseEnclosure(): Expression | null;
|
|
221
|
-
/**
|
|
222
|
-
* A generic expression is used for dictionary entries that do
|
|
223
|
-
* some complex (non-standard) parsing. This includes trig functions (to
|
|
224
|
-
* parse implicit arguments), and integrals (to parse the integrand and
|
|
225
|
-
* limits and the "dx" terminator).
|
|
226
|
-
*/
|
|
227
|
-
private parseGenericExpression;
|
|
228
|
-
/**
|
|
229
|
-
* A function is an symbol followed by postfix operators
|
|
230
|
-
* (`\prime`...) and some arguments.
|
|
231
|
-
*/
|
|
232
|
-
private parseFunction;
|
|
233
|
-
parseSymbol(until?: Readonly<Terminator>): Expression | null;
|
|
234
|
-
/**
|
|
235
|
-
* Parse a sequence superfix/subfix operator, e.g. `^{*}`
|
|
236
|
-
*
|
|
237
|
-
* Superfix and subfix need special handling:
|
|
238
|
-
*
|
|
239
|
-
* - they act mostly like an infix operator, but they are commutative, i.e.
|
|
240
|
-
* `x_a^b` should be parsed identically to `x^b_a`.
|
|
241
|
-
*
|
|
242
|
-
* - furthermore, in LaTeX `x^a^b` parses the same as `x^a{}^b`.
|
|
243
|
-
*
|
|
244
|
-
*/
|
|
245
|
-
private parseSupsub;
|
|
246
|
-
parsePostfixOperator(lhs: Expression | null, until?: Readonly<Terminator>): Expression | null;
|
|
247
|
-
/**
|
|
248
|
-
* This method can be invoked when we know we're in an error situation,
|
|
249
|
-
* for example when there are tokens remaining after we've finished parsing.
|
|
250
|
-
*
|
|
251
|
-
* In general, if a context does not apply, we return `null` to give
|
|
252
|
-
* the chance to some other option to be considered. However, in some cases
|
|
253
|
-
* we know we've exhausted all possibilities, and in this case this method
|
|
254
|
-
* will return an error expression as informative as possible.
|
|
255
|
-
*
|
|
256
|
-
* We've encountered a LaTeX command or symbol but were not able to match it
|
|
257
|
-
* to any entry in the LaTeX dictionary, or ran into it in an unexpected
|
|
258
|
-
* context (postfix operator lacking an argument, for example)
|
|
259
|
-
*/
|
|
260
|
-
parseSyntaxError(): Expression;
|
|
261
|
-
/**
|
|
262
|
-
* <primary> :=
|
|
263
|
-
* (<number> | <symbol> | <environment> | <matchfix-expr>)
|
|
264
|
-
* <subsup>* <postfix-operator>*
|
|
265
|
-
*
|
|
266
|
-
* <symbol> ::=
|
|
267
|
-
* (<symbol-id> | (<latex-command><latex-arguments>)) <arguments>
|
|
268
|
-
*
|
|
269
|
-
* <matchfix-expr> :=
|
|
270
|
-
* <matchfix-op-open>
|
|
271
|
-
* <expression>
|
|
272
|
-
* (<matchfix-op-separator> <expression>)*
|
|
273
|
-
* <matchfix-op-close>
|
|
274
|
-
*
|
|
275
|
-
*/
|
|
276
|
-
private parsePrimary;
|
|
277
|
-
/**
|
|
278
|
-
* Parse an expression:
|
|
279
|
-
*
|
|
280
|
-
* <expression> ::=
|
|
281
|
-
* | <primary>
|
|
282
|
-
* | <prefix-op> <primary>
|
|
283
|
-
* | <primary> <infix-op> <expression>
|
|
284
|
-
*
|
|
285
|
-
* Stop when an operator of precedence less than `until.minPrec`
|
|
286
|
-
* is encountered
|
|
287
|
-
*/
|
|
288
|
-
parseExpression(until?: Readonly<Terminator>): Expression | null;
|
|
289
|
-
/**
|
|
290
|
-
* Add LaTeX or other requested metadata to the expression
|
|
291
|
-
*/
|
|
292
|
-
decorate(expr: Expression | null, start: number): Expression | null;
|
|
293
|
-
error(code: string | [string, ...Expression[]], fromToken: number): Expression;
|
|
294
|
-
private isFunctionOperator;
|
|
295
|
-
/** Return all defs of the specified kind.
|
|
296
|
-
* The defs at the end of the dictionary have priority, since they may
|
|
297
|
-
* override previous definitions. (For example, there is a core definition
|
|
298
|
-
* for matchfix[], which maps to a List, and a logic definition which
|
|
299
|
-
* matches to Boole. The logic definition should take precedence.)
|
|
300
|
-
*/
|
|
301
|
-
getDefs(kind: string): Iterable<IndexedLatexDictionaryEntry>;
|
|
302
|
-
}
|
|
303
|
-
export declare function parse(latex: string, dictionary: IndexedLatexDictionary, options: Readonly<ParseLatexOptions>): Expression | null;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/* 0.31.0 */
|
|
2
|
-
import { NumberSerializationFormat } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* @param expr - A number, can be represented as a string
|
|
5
|
-
* (particularly useful for arbitrary precision numbers) or a number (-12.45)
|
|
6
|
-
* @return A textual representation of the number, formatted according to the
|
|
7
|
-
* `options`
|
|
8
|
-
*/
|
|
9
|
-
export declare function serializeNumber(expr: Expression | null, options: NumberSerializationFormat): string;
|
|
10
|
-
/**
|
|
11
|
-
* `value` is a base-10 number, possibly a floating point number with an
|
|
12
|
-
* exponent, i.e. "0.31415e1"
|
|
13
|
-
*/
|
|
14
|
-
/**
|
|
15
|
-
* Return a C99 hex-float formated representation of the floating-point `value`.
|
|
16
|
-
*
|
|
17
|
-
* Does not handle integer and non-finite values.
|
|
18
|
-
*/
|
|
19
|
-
export declare function serializeHexFloat(value: number): string;
|
|
20
|
-
/**
|
|
21
|
-
* Given a correctly formatted float hex, return the corresponding number.
|
|
22
|
-
*
|
|
23
|
-
* - "0xc.3p0" -> 12.1875
|
|
24
|
-
* - "0x3.0Cp2" -> 12.1875
|
|
25
|
-
* - "0x1.91eb851eb851fp+1" -> 3.14
|
|
26
|
-
* - "0x3.23d70a3d70a3ep0" -> 3.14
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
export declare function deserializeHexFloat(value: string): number;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/* 0.31.0 */
|
|
2
|
-
import { DelimiterScale } from './types';
|
|
3
|
-
export declare function getApplyFunctionStyle(_expr: Expression, _level: number): DelimiterScale;
|
|
4
|
-
export declare function getGroupStyle(_expr: Expression, _level: number): DelimiterScale;
|
|
5
|
-
export declare function getRootStyle(_expr: Expression | null, level: number): 'radical' | 'quotient' | 'solidus';
|
|
6
|
-
export declare function getFractionStyle(expr: Expression, level: number): 'quotient' | 'block-quotient' | 'inline-quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
|
|
7
|
-
export declare function getLogicStyle(_expr: Expression, _level: number): 'word' | 'boolean' | 'uppercase-word' | 'punctuation';
|
|
8
|
-
export declare function getPowerStyle(_expr: Expression, _level: number): 'root' | 'solidus' | 'quotient';
|
|
9
|
-
export declare function getNumericSetStyle(_expr: Expression, _level: number): 'compact' | 'regular' | 'interval' | 'set-builder';
|
|
10
|
-
export declare function latexTemplate(s: string, lhs: string, rhs: string): string;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/* 0.31.0 */
|
|
2
|
-
import { LatexString, SerializeLatexOptions, DelimiterScale } from './types';
|
|
3
|
-
import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
|
|
4
|
-
export declare class Serializer {
|
|
5
|
-
options: Readonly<SerializeLatexOptions>;
|
|
6
|
-
readonly dictionary: IndexedLatexDictionary;
|
|
7
|
-
level: number;
|
|
8
|
-
constructor(dictionary: IndexedLatexDictionary, options: SerializeLatexOptions);
|
|
9
|
-
/**
|
|
10
|
-
* Serialize the expression, and if the expression is an operator
|
|
11
|
-
* of precedence less than or equal to prec, wrap it in some parens.
|
|
12
|
-
* @todo: don't wrap Abs, Floor, Ceil, Delimiter
|
|
13
|
-
*/
|
|
14
|
-
wrap(expr: Expression | null | undefined, prec?: number): string;
|
|
15
|
-
/**
|
|
16
|
-
* If this is a "short" expression, wrap it.
|
|
17
|
-
* Do not wrap symbols, positive numbers or functions.
|
|
18
|
-
*
|
|
19
|
-
* This is called by the serializer for power and division (i.e. "(a+1)/b")
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
wrapShort(expr: Expression | null | undefined): string;
|
|
23
|
-
wrapString(s: string, style: DelimiterScale, fence?: string): string;
|
|
24
|
-
wrapArguments(expr: Expression): string;
|
|
25
|
-
serializeSymbol(expr: Expression, def?: IndexedLatexDictionaryEntry): LatexString;
|
|
26
|
-
serializeFunction(expr: Expression, def?: IndexedLatexDictionaryEntry): LatexString;
|
|
27
|
-
serialize(expr: Expression | null | undefined): LatexString;
|
|
28
|
-
applyFunctionStyle(expr: Expression, level: number): DelimiterScale;
|
|
29
|
-
groupStyle(expr: Expression, level: number): DelimiterScale;
|
|
30
|
-
rootStyle(expr: Expression, level: number): 'radical' | 'quotient' | 'solidus';
|
|
31
|
-
fractionStyle(expr: Expression, level: number): 'quotient' | 'block-quotient' | 'inline-quotient' | 'inline-solidus' | 'nice-solidus' | 'reciprocal' | 'factor';
|
|
32
|
-
logicStyle(expr: Expression, level: number): 'word' | 'boolean' | 'uppercase-word' | 'punctuation';
|
|
33
|
-
powerStyle(expr: Expression, level: number): 'root' | 'solidus' | 'quotient';
|
|
34
|
-
numericSetStyle(expr: Expression, level: number): 'compact' | 'regular' | 'interval' | 'set-builder';
|
|
35
|
-
}
|
|
36
|
-
export declare function appendLatex(src: string, s: string): string;
|
|
37
|
-
export declare function serializeLatex(expr: Expression | null, dict: IndexedLatexDictionary, options: Readonly<SerializeLatexOptions>): string;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/* 0.31.0 */
|
|
2
|
-
* ## Reference
|
|
3
|
-
* TeX source code:
|
|
4
|
-
* {@link http://tug.org/texlive/devsrc/Build/source/texk/web2c/tex.web | Tex.web}
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
export type Token = string;
|
|
8
|
-
/**
|
|
9
|
-
* Create Tokens from a stream of LaTeX
|
|
10
|
-
*
|
|
11
|
-
* @param s - A string of LaTeX. It can include comments (with the `%`
|
|
12
|
-
* marker) and multiple lines.
|
|
13
|
-
*/
|
|
14
|
-
export declare function tokenize(s: string, args?: string[]): Token[];
|
|
15
|
-
export declare function countTokens(s: string): number;
|
|
16
|
-
export declare function joinLatex(segments: Iterable<string>): string;
|
|
17
|
-
export declare function supsub(c: '_' | '^', body: string, x: string): string;
|
|
18
|
-
export declare function tokensToString(tokens: Token | Token[] | [Token[] | Token][]): string;
|