@cortex-js/compute-engine 0.4.3 → 0.6.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/README.md +2 -3
- package/dist/compute-engine.esm.js +18900 -18332
- package/dist/compute-engine.min.esm.js +2 -2
- package/dist/compute-engine.min.js +2 -2
- package/dist/math-json.esm.js +44 -6141
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +8 -7
- package/dist/types/compute-engine/boxed-expression/box.d.ts +3 -5
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +32 -6
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +7 -3
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +6 -6
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +5 -5
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +2 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +3 -3
- package/dist/types/compute-engine/compute-engine.d.ts +101 -50
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +2 -2
- package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/core.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -2
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +3 -3
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +14 -13
- package/dist/types/compute-engine/latex-syntax/public.d.ts +69 -44
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +3 -3
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +3 -5
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +2 -2
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +551 -228
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +3 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +3 -4
- package/dist/types/math-json.d.ts +3 -4
- package/package.json +17 -18
- package/dist/compute-engine.js +0 -23523
- package/dist/math-json.js +0 -6339
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare const DEFINITIONS_LOGIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare const DEFINITIONS_OTHERS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare const DEFINITIONS_SETS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare const DEFINITIONS_SYMBOLS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { WarningSignal } from '../../../common/signals';
|
|
3
3
|
export declare type CommonEntry = {
|
|
4
4
|
name?: string;
|
|
@@ -7,7 +7,6 @@ export declare type CommonEntry = {
|
|
|
7
7
|
export declare type SymbolEntry = CommonEntry & {
|
|
8
8
|
kind: 'symbol';
|
|
9
9
|
precedence: number;
|
|
10
|
-
arguments: 'group' | 'implicit' | '';
|
|
11
10
|
optionalLatexArg: number;
|
|
12
11
|
requiredLatexArg: number;
|
|
13
12
|
parse: SymbolParseHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { Serializer } from './serializer';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
4
|
import { WarningSignalHandler } from '../../common/signals';
|
|
@@ -6,7 +6,7 @@ import { IComputeEngine } from '../public';
|
|
|
6
6
|
export declare const DEFAULT_SERIALIZE_LATEX_OPTIONS: Required<SerializeLatexOptions>;
|
|
7
7
|
export declare class LatexSyntax {
|
|
8
8
|
onError: WarningSignalHandler;
|
|
9
|
-
options:
|
|
9
|
+
options: NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions;
|
|
10
10
|
readonly computeEngine: IComputeEngine;
|
|
11
11
|
private dictionary;
|
|
12
12
|
private _serializer?;
|
|
@@ -16,7 +16,7 @@ export declare class LatexSyntax {
|
|
|
16
16
|
onError?: WarningSignalHandler;
|
|
17
17
|
});
|
|
18
18
|
updateOptions(opt: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions> & Partial<SerializeLatexOptions>): void;
|
|
19
|
-
static getDictionary(
|
|
19
|
+
static getDictionary(category?: DictionaryCategory | 'all'): Readonly<LatexDictionary>;
|
|
20
20
|
parse(latex: LatexString): Expression;
|
|
21
21
|
serialize(expr: Expression): LatexString;
|
|
22
22
|
get serializer(): Serializer;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { ParseLatexOptions, LatexToken, NumberFormattingOptions, Delimiter, Terminator, Parser } from './public';
|
|
3
3
|
import { IndexedLatexDictionary, InfixEntry, PostfixEntry, PrefixEntry, SymbolEntry } from './dictionary/definitions';
|
|
4
4
|
import { WarningSignalHandler } from '../../common/signals';
|
|
5
5
|
import { IComputeEngine } from '../public';
|
|
6
|
-
export declare const DEFAULT_LATEX_NUMBER_OPTIONS:
|
|
7
|
-
export declare const DEFAULT_PARSE_LATEX_OPTIONS:
|
|
6
|
+
export declare const DEFAULT_LATEX_NUMBER_OPTIONS: NumberFormattingOptions;
|
|
7
|
+
export declare const DEFAULT_PARSE_LATEX_OPTIONS: ParseLatexOptions;
|
|
8
8
|
export declare class _Parser implements Parser {
|
|
9
9
|
readonly onError: WarningSignalHandler;
|
|
10
|
-
readonly options:
|
|
10
|
+
readonly options: NumberFormattingOptions & ParseLatexOptions;
|
|
11
11
|
readonly engine: IComputeEngine;
|
|
12
12
|
readonly _dictionary: IndexedLatexDictionary;
|
|
13
13
|
index: number;
|
|
14
14
|
_lastPeek: string;
|
|
15
15
|
_peekCounter: number;
|
|
16
16
|
readonly _tokens: LatexToken[];
|
|
17
|
-
constructor(tokens: LatexToken[], options:
|
|
17
|
+
constructor(tokens: LatexToken[], options: NumberFormattingOptions & ParseLatexOptions, dictionary: IndexedLatexDictionary, computeEngine: IComputeEngine, onError: WarningSignalHandler);
|
|
18
18
|
updateOptions(opt: Partial<NumberFormattingOptions> & Partial<ParseLatexOptions>): void;
|
|
19
19
|
clone(start: number, end: number): Parser;
|
|
20
20
|
get atEnd(): boolean;
|
|
@@ -79,11 +79,13 @@ export declare class _Parser implements Parser {
|
|
|
79
79
|
matchPrefixOperator(until?: Terminator): Expression | null;
|
|
80
80
|
matchInfixOperator(lhs: Expression, until?: Terminator): Expression | null;
|
|
81
81
|
/**
|
|
82
|
-
* '
|
|
83
|
-
* 'implicit': either an expression inside a pair of `()`, or just a primary
|
|
82
|
+
* - 'enclosure' : will look for an argument inside an enclosure (open/close fence)
|
|
83
|
+
* - 'implicit': either an expression inside a pair of `()`, or just a primary
|
|
84
84
|
* (i.e. we interpret `\cos x + 1` as `\cos(x) + 1`)
|
|
85
|
+
* - 'group': the arguments follow until an end of group, `<}>`. This is the
|
|
86
|
+
* case for example for `\displaystyle`
|
|
85
87
|
*/
|
|
86
|
-
matchArguments(kind: undefined | '' | '
|
|
88
|
+
matchArguments(kind: undefined | '' | 'enclosure' | 'implicit' | 'group'): Expression[] | null;
|
|
87
89
|
/** If matches the normalized open delimiter, returns the
|
|
88
90
|
* expected closing delimiter.
|
|
89
91
|
*
|
|
@@ -103,7 +105,8 @@ export declare class _Parser implements Parser {
|
|
|
103
105
|
/**
|
|
104
106
|
* A symbol can be:
|
|
105
107
|
* - a constant: `\pi`
|
|
106
|
-
* - a variable: `x`
|
|
108
|
+
* - a single-letter variable: `x`
|
|
109
|
+
* - a multi-letter variable: `\mathit{speed}` or `\mathrm{speed}`
|
|
107
110
|
* - a function with explicit arguments `f(x)`
|
|
108
111
|
* - a function with implicit arguments: `\cos x`
|
|
109
112
|
* - a command: `\frac{2}{3}`
|
|
@@ -133,9 +136,7 @@ export declare class _Parser implements Parser {
|
|
|
133
136
|
*/
|
|
134
137
|
matchSupsub(lhs: Expression | null): Expression | null;
|
|
135
138
|
matchPostfix(lhs: Expression | null): Expression | null;
|
|
136
|
-
matchString(until:
|
|
137
|
-
tokens: LatexToken[];
|
|
138
|
-
} & Partial<Terminator>): string;
|
|
139
|
+
matchString(until: Partial<Terminator>): string;
|
|
139
140
|
matchEnvironmentName(command: '\\begin' | '\\end', envName: string): boolean;
|
|
140
141
|
/**
|
|
141
142
|
* Match an expression in a tabular format,
|
|
@@ -192,7 +193,7 @@ export declare class _Parser implements Parser {
|
|
|
192
193
|
*/
|
|
193
194
|
matchExpression(until?: Partial<Terminator>): Expression | null;
|
|
194
195
|
/**
|
|
195
|
-
* Add
|
|
196
|
+
* Add LaTeX or other requested metadata to the expression
|
|
196
197
|
*/
|
|
197
198
|
decorate(expr: Expression | null, start: number): Expression | null;
|
|
198
199
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
|
-
import { IComputeEngine } from '../public';
|
|
3
|
+
import type { IComputeEngine } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* A `LatexToken` is a token as returned by `Scanner.peek`.
|
|
6
6
|
*
|
|
@@ -13,7 +13,11 @@ export declare type LatexToken = string | '<{>' | '<}>' | '<space>' | '<$>' | '<
|
|
|
13
13
|
* `\frac{\pi}{2}`
|
|
14
14
|
*/
|
|
15
15
|
export declare type LatexString = string;
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Open and close delimiters that can be used with {@link MatchfixEntry}
|
|
18
|
+
* record to define new LaTeX dictionary entries.
|
|
19
|
+
*/
|
|
20
|
+
export declare type Delimiter = ')' | '(' | ']' | '[' | '{' /** \lbrace */ | '}' /** \rbrace */ | '<' /** \langle */ | '>' /** \rangle */ | '|' | '||' | '\\lceil' | '\\rceil' | '\\lfloor' | '\\rfloor';
|
|
17
21
|
export declare type DictionaryCategory = 'algebra' | 'arithmetic' | 'calculus' | 'collections' | 'combinatorics' | 'core' | 'dimensions' | 'domains' | 'linear-algebra' | 'logic' | 'numeric' | 'other' | 'physics' | 'polynomials' | 'relop' | 'sets' | 'statistics' | 'symbols' | 'trigonometry' | 'units';
|
|
18
22
|
/**
|
|
19
23
|
* This indicates a condition under which parsing should stop:
|
|
@@ -108,11 +112,11 @@ export declare type InfixEntry = BaseEntry & {
|
|
|
108
112
|
/**
|
|
109
113
|
* Infix position, with an operand before and an operand after: `a ⊛ b`.
|
|
110
114
|
*
|
|
111
|
-
*
|
|
115
|
+
* Example: `+`, `\times`.
|
|
112
116
|
*/
|
|
113
117
|
kind: 'infix';
|
|
114
118
|
/**
|
|
115
|
-
* - **`both`**: a + b + c
|
|
119
|
+
* - **`both`**: a + b + c +(a, b, c)
|
|
116
120
|
* - **`left`**: a / b / c -> /(/(a, b), c)
|
|
117
121
|
* - **`right`**: a = b = c -> =(a, =(b, c))
|
|
118
122
|
* - **`non`**: a < b < c -> syntax error
|
|
@@ -131,7 +135,7 @@ export declare type PostfixEntry = BaseEntry & {
|
|
|
131
135
|
/**
|
|
132
136
|
* Postfix position, with an operand before: `a ⊛`
|
|
133
137
|
*
|
|
134
|
-
*
|
|
138
|
+
* Example: `!`.
|
|
135
139
|
*/
|
|
136
140
|
kind: 'postfix';
|
|
137
141
|
precedence?: number;
|
|
@@ -141,25 +145,27 @@ export declare type PrefixEntry = BaseEntry & {
|
|
|
141
145
|
/**
|
|
142
146
|
* Prefix position, with an operand after: `⊛ a`
|
|
143
147
|
*
|
|
144
|
-
*
|
|
148
|
+
* Example: `-`, `\not`.
|
|
145
149
|
*/
|
|
146
150
|
kind: 'prefix';
|
|
147
151
|
precedence: number;
|
|
148
152
|
parse: PrefixParseHandler;
|
|
149
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* A LaTeX dictionary entry for an environment, that is a LaTeX
|
|
156
|
+
* construct using `\begin{...}...\end{...}`.
|
|
157
|
+
*/
|
|
150
158
|
export declare type EnvironmentEntry = BaseEntry & {
|
|
151
|
-
/**
|
|
152
|
-
* The name of an environment, as used in `\begin{matrix}` where
|
|
153
|
-
* `"matrix"` is the name of the environment.
|
|
154
|
-
*/
|
|
155
159
|
kind: 'environment';
|
|
156
160
|
parse: EnvironmentParseHandler;
|
|
157
161
|
};
|
|
158
162
|
export declare type SymbolEntry = BaseEntry & {
|
|
159
163
|
kind: 'symbol';
|
|
164
|
+
/** Used for appropriate wrapping (i.e. when to surround it with parens) */
|
|
160
165
|
precedence?: number;
|
|
161
166
|
/**
|
|
162
167
|
* Indicate if this symbol can be followed by arguments.
|
|
168
|
+
*
|
|
163
169
|
* The presence of arguments will indicate that the arguments should be
|
|
164
170
|
* applied to the symbol. Otherwise, the invisible operator is applied
|
|
165
171
|
* to the symbol and the arguments.
|
|
@@ -167,14 +173,14 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
167
173
|
* If `arguments` is `"group"`:
|
|
168
174
|
*
|
|
169
175
|
* "f(x)" -> `["f", "x"]`
|
|
170
|
-
* "f x" -> `["
|
|
176
|
+
* "f x" -> `["Multiply", "f", "x"]`
|
|
171
177
|
*
|
|
172
178
|
* If `arguments` is `""`:
|
|
173
179
|
*
|
|
174
|
-
* "f(x)" -> `["
|
|
175
|
-
* "f x" -> `["
|
|
180
|
+
* "f(x)" -> `["Multiply", "f", "x"]`
|
|
181
|
+
* "f x" -> `["Multiply", "f", "x"]`
|
|
176
182
|
*
|
|
177
|
-
* If `arguments` is `"
|
|
183
|
+
* If `arguments` is `"implicit"` and the symbol is followed either
|
|
178
184
|
* by a group or by a primary (prefix + symbol + subsupfix + postfix).
|
|
179
185
|
* Used for trig functions. i.e. `\sin x` vs `\sin(x)`:
|
|
180
186
|
*
|
|
@@ -182,9 +188,7 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
182
188
|
* "f x" -> `["f", "x"]`
|
|
183
189
|
*
|
|
184
190
|
*/
|
|
185
|
-
arguments?: 'group' | 'implicit' | '';
|
|
186
191
|
/**
|
|
187
|
-
* Applicable when `kind` is `"symbol"`.
|
|
188
192
|
*
|
|
189
193
|
* If a LaTeX command (i.e. the trigger starts with `\`, e.g. `\sqrt`)
|
|
190
194
|
* indicates the number of optional arguments expected (indicate with
|
|
@@ -195,7 +199,6 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
195
199
|
*/
|
|
196
200
|
optionalLatexArg?: number;
|
|
197
201
|
/**
|
|
198
|
-
* Applicable when `kind` is `"symbol"`.
|
|
199
202
|
*
|
|
200
203
|
* If a LaTeX command (i.e. the trigger starts with `\`, e.g. `\frac`)
|
|
201
204
|
* indicates the number of required arguments expected (indicated with
|
|
@@ -207,19 +210,27 @@ export declare type SymbolEntry = BaseEntry & {
|
|
|
207
210
|
requiredLatexArg?: number;
|
|
208
211
|
parse: Expression | SymbolParseHandler;
|
|
209
212
|
};
|
|
213
|
+
/**
|
|
214
|
+
* A simple LaTeX dictionary entry, for example for a command like `\pi`.
|
|
215
|
+
*/
|
|
210
216
|
export declare type DefaultEntry = BaseEntry & {
|
|
211
217
|
precedence?: number;
|
|
212
|
-
arguments?: 'group' | 'implicit' | '';
|
|
213
218
|
optionalLatexArg?: number;
|
|
214
219
|
requiredLatexArg?: number;
|
|
215
220
|
parse?: Expression | SymbolParseHandler;
|
|
216
221
|
};
|
|
217
222
|
export declare type LatexDictionaryEntry = DefaultEntry | MatchfixEntry | InfixEntry | PostfixEntry | PrefixEntry | SymbolEntry | EnvironmentEntry;
|
|
223
|
+
/** @internal */
|
|
218
224
|
export declare function isSymbolEntry(entry: LatexDictionaryEntry): entry is SymbolEntry;
|
|
225
|
+
/** @internal */
|
|
219
226
|
export declare function isMatchfixEntry(entry: LatexDictionaryEntry): entry is MatchfixEntry;
|
|
227
|
+
/** @internal */
|
|
220
228
|
export declare function isInfixEntry(entry: LatexDictionaryEntry): entry is InfixEntry;
|
|
229
|
+
/** @internal */
|
|
221
230
|
export declare function isPrefixEntry(entry: LatexDictionaryEntry): entry is PrefixEntry;
|
|
231
|
+
/** @internal */
|
|
222
232
|
export declare function isPostfixEntry(entry: LatexDictionaryEntry): entry is PostfixEntry;
|
|
233
|
+
/** @internal */
|
|
223
234
|
export declare function isEnvironmentEntry(entry: LatexDictionaryEntry): entry is EnvironmentEntry;
|
|
224
235
|
export declare type LatexDictionary = LatexDictionaryEntry[];
|
|
225
236
|
export declare type ParseLatexOptions = {
|
|
@@ -266,25 +277,31 @@ export declare type ParseLatexOptions = {
|
|
|
266
277
|
*/
|
|
267
278
|
parseNumbers: boolean;
|
|
268
279
|
/**
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
280
|
+
* This handler is invoked when the parser encounter a set of tokens
|
|
281
|
+
* at a position that could be a symbol or function.
|
|
282
|
+
*
|
|
283
|
+
* The `symbol` argument is one or more tokens.
|
|
272
284
|
*
|
|
273
|
-
*
|
|
274
|
-
* or function, respectively.
|
|
285
|
+
* The handler can return:
|
|
275
286
|
*
|
|
276
|
-
*
|
|
277
|
-
* (typically, parentheses), parse them as arguments to the function.
|
|
287
|
+
* - `symbol` to indicate the string represent a constant or variable.
|
|
278
288
|
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
289
|
+
* - `function` to indicate the string is a function name. If an apply
|
|
290
|
+
* function operator (typically, parentheses) follow, parse them as arguments
|
|
291
|
+
* to the function.
|
|
281
292
|
*
|
|
282
|
-
*
|
|
293
|
+
* - `error`, an error condition is raised.
|
|
283
294
|
*/
|
|
284
|
-
|
|
295
|
+
parseUnknownSymbol: (symbol: string, parser: Parser) => 'symbol' | 'function' | 'unknown';
|
|
285
296
|
/**
|
|
286
297
|
* If true, the expression will be decorated with the LaTeX
|
|
287
|
-
* fragments corresponding to each elements of the expression
|
|
298
|
+
* fragments corresponding to each elements of the expression.
|
|
299
|
+
*
|
|
300
|
+
* The top-level expression, that is the one returned by `parse()`, will
|
|
301
|
+
* include the verbatim LaTeX input that was parsed. The sub-expressions
|
|
302
|
+
* may contain a slightly different LaTeX, for example with consecutive spaces
|
|
303
|
+
* replaced by one, with comments removed and with some low-level LaTeX
|
|
304
|
+
* commands replaced, for example `\egroup` and `\bgroup`.
|
|
288
305
|
*/
|
|
289
306
|
preserveLatex: boolean;
|
|
290
307
|
};
|
|
@@ -447,7 +464,7 @@ export interface Parser {
|
|
|
447
464
|
readonly atEnd: boolean;
|
|
448
465
|
/** Return the next token, without advancing the index */
|
|
449
466
|
readonly peek: LatexToken;
|
|
450
|
-
/** Return true if the terminator
|
|
467
|
+
/** Return true if the terminator condition is met */
|
|
451
468
|
atTerminator(t: Terminator): boolean;
|
|
452
469
|
/** Return an array of string corresponding to tokens ahead.
|
|
453
470
|
* The index is unchanged.
|
|
@@ -495,16 +512,18 @@ export interface Parser {
|
|
|
495
512
|
/** If the next tokens correspond to an optional LaTeX argument,
|
|
496
513
|
* enclosed with `[` and `]` return the content of the argument
|
|
497
514
|
* as an expression and advance the index past the closing `]`.
|
|
515
|
+
*
|
|
498
516
|
* Otherwise, return `null`.
|
|
499
517
|
*/
|
|
500
518
|
matchOptionalLatexArgument(): Expression | null;
|
|
501
519
|
matchRequiredLatexArgument(): Expression | null;
|
|
502
520
|
/**
|
|
503
|
-
* '
|
|
504
|
-
* '
|
|
505
|
-
*
|
|
521
|
+
* - 'enclosure' : will look for an argument inside an enclosure (an open/close fence)
|
|
522
|
+
* - 'group': arguments follow directly the symbol, until an end of group token `<}>`
|
|
523
|
+
* - 'implicit': either an expression inside a pair of `()`, or just a primary
|
|
524
|
+
* (i.e. we interpret `\cos x + 1` as `\cos(x) + 1`)
|
|
506
525
|
*/
|
|
507
|
-
matchArguments(kind: '' | 'group' | 'implicit'): Expression[] | null;
|
|
526
|
+
matchArguments(kind: '' | 'group' | 'implicit' | 'enclosure'): Expression[] | null;
|
|
508
527
|
/** If matches the normalized open delimiter, returns the
|
|
509
528
|
* expected closing delimiter.
|
|
510
529
|
*
|
|
@@ -516,16 +535,22 @@ export interface Parser {
|
|
|
516
535
|
matchMiddleDelimiter(delimiter: '|' | ':' | LatexToken): boolean;
|
|
517
536
|
matchSupsub(lhs: Expression | null): Expression | null;
|
|
518
537
|
/**
|
|
519
|
-
* <primary> :=
|
|
520
|
-
* (<number> | <symbol> | <latex-command> | <function-call> | <matchfix-expr>)
|
|
521
|
-
* (<subsup> | <postfix-operator>)*
|
|
522
538
|
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
* <
|
|
527
|
-
*
|
|
539
|
+
* ```
|
|
540
|
+
* <primary> :=
|
|
541
|
+
* (<number> | <symbol> | <latex-command> | <function-call> | <matchfix-expr>)
|
|
542
|
+
* (<subsup> | <postfix-operator>)*
|
|
543
|
+
* ```
|
|
528
544
|
*
|
|
545
|
+
* ```
|
|
546
|
+
* <matchfix-expr> :=
|
|
547
|
+
* <matchfix-op-open> <expression> <matchfix-op-close>
|
|
548
|
+
*```
|
|
549
|
+
*
|
|
550
|
+
*```
|
|
551
|
+
* <function-call> ::=
|
|
552
|
+
* | <function><matchfix-op-group-open><expression>[',' <expression>]<matchfix-op-group-close>
|
|
553
|
+
*```
|
|
529
554
|
* If not a primary, return `null` and do not advance the index.
|
|
530
555
|
*/
|
|
531
556
|
matchPrimary(): Expression | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { NumberFormattingOptions } from './public';
|
|
3
|
-
export declare function serializeNumber(expr: Expression | null, options:
|
|
4
|
-
export declare function serializeEngineeringNotationNumber(value: number, options:
|
|
3
|
+
export declare function serializeNumber(expr: Expression | null, options: NumberFormattingOptions): string;
|
|
4
|
+
export declare function serializeEngineeringNotationNumber(value: number, options: NumberFormattingOptions): string;
|
|
5
5
|
/**
|
|
6
6
|
* `value` is a base-10 number, possibly a floating point number with an
|
|
7
7
|
* exponent, i.e. "0.31415e1"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare function getApplyFunctionStyle(_expr: Expression, _level: number): 'paren' | 'leftright' | 'big' | 'none';
|
|
3
3
|
export declare function getGroupStyle(_expr: Expression, _level: number): 'paren' | 'leftright' | 'big' | 'none';
|
|
4
4
|
export declare function getRootStyle(_expr: Expression | null, level: number): 'radical' | 'quotient' | 'solidus';
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
import { NumberFormattingOptions, LatexString, SerializeLatexOptions } from './public';
|
|
3
3
|
import { IndexedLatexDictionary, SymbolEntry } from './dictionary/definitions';
|
|
4
4
|
import { WarningSignalHandler } from '../../common/signals';
|
|
5
|
-
import { IComputeEngine } from '../public';
|
|
6
5
|
export declare class Serializer {
|
|
7
6
|
readonly onError: WarningSignalHandler;
|
|
8
|
-
options:
|
|
9
|
-
readonly computeEngine?: IComputeEngine;
|
|
7
|
+
options: NumberFormattingOptions & SerializeLatexOptions;
|
|
10
8
|
readonly dictionary: IndexedLatexDictionary;
|
|
11
9
|
level: number;
|
|
12
|
-
constructor(options:
|
|
10
|
+
constructor(options: NumberFormattingOptions & SerializeLatexOptions, dictionary: IndexedLatexDictionary, onError: WarningSignalHandler);
|
|
13
11
|
updateOptions(opt: Partial<NumberFormattingOptions> & Partial<SerializeLatexOptions>): void;
|
|
14
12
|
/**
|
|
15
13
|
* Serialize the expression, and if the expression is an operator
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare const MACHINE_PRECISION: number;
|
|
3
3
|
export declare const MACHINE_TOLERANCE_BITS = 7;
|
|
4
4
|
export declare const MACHINE_TOLERANCE: number;
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const NUMERIC_TOLERANCE: number;
|
|
6
6
|
export declare const SMALL_INTEGERS = 1000000;
|
|
7
7
|
/**
|
|
8
8
|
* Returns the smallest floating-point number greater than x.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.6.0 */
|
|
2
2
|
export declare function isPrime(n: number): boolean | undefined;
|