@cortex-js/compute-engine 0.4.2 → 0.5.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 +4 -5
- package/dist/compute-engine.esm.js +16755 -10484
- package/dist/compute-engine.min.esm.js +2 -7
- package/dist/compute-engine.min.js +2 -7
- package/dist/math-json.esm.js +148 -12472
- package/dist/math-json.min.esm.js +2 -7
- package/dist/math-json.min.js +2 -7
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +90 -0
- package/dist/types/compute-engine/assume.d.ts +21 -6
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +107 -0
- package/dist/types/compute-engine/boxed-expression/box.d.ts +56 -0
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +39 -0
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +8 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -0
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +95 -0
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +83 -0
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +21 -0
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +23 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +98 -0
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +74 -0
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +12 -0
- package/dist/types/compute-engine/boxed-expression/order.d.ts +53 -0
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +15 -0
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +37 -0
- package/dist/types/compute-engine/compute-engine.d.ts +284 -99
- package/dist/types/compute-engine/cost-function.d.ts +3 -0
- package/dist/types/compute-engine/dictionary/arithmetic-add.d.ts +11 -0
- package/dist/types/compute-engine/dictionary/arithmetic-divide.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic-multiply.d.ts +17 -0
- package/dist/types/compute-engine/dictionary/arithmetic-power.d.ts +9 -0
- package/dist/types/compute-engine/dictionary/arithmetic.d.ts +2 -12
- package/dist/types/compute-engine/dictionary/collections.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/core.d.ts +2 -2
- package/dist/types/compute-engine/dictionary/dictionary.d.ts +18 -11
- package/dist/types/compute-engine/dictionary/logic.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/polynomials.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/relational-operator.d.ts +2 -0
- package/dist/types/compute-engine/dictionary/sets.d.ts +1 -1
- package/dist/types/compute-engine/dictionary/trigonometry.d.ts +2 -2
- package/dist/types/compute-engine/domain-utils.d.ts +30 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +4 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +2 -0
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +57 -0
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +23 -0
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +198 -0
- package/dist/types/compute-engine/latex-syntax/public.d.ts +576 -0
- package/dist/types/{common → compute-engine/latex-syntax}/serialize-number.d.ts +4 -5
- package/dist/types/{latex-syntax → compute-engine/latex-syntax}/serializer-style.d.ts +2 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +41 -0
- package/dist/types/{latex-syntax/core → compute-engine/latex-syntax}/tokenizer.d.ts +2 -2
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +3 -0
- package/dist/types/compute-engine/numerics/numeric-decimal.d.ts +12 -0
- package/dist/types/compute-engine/numerics/numeric.d.ts +35 -0
- package/dist/types/compute-engine/numerics/primes.d.ts +2 -0
- package/dist/types/compute-engine/public.d.ts +1416 -447
- package/dist/types/compute-engine/rules.d.ts +16 -6
- package/dist/types/compute-engine/simplify-rules.d.ts +17 -0
- package/dist/types/compute-engine/symbolic/expand.d.ts +11 -0
- package/dist/types/compute-engine/symbolic/flatten.d.ts +7 -0
- package/dist/types/compute-engine/symbolic/negate.d.ts +12 -0
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +52 -0
- package/dist/types/compute-engine/symbolic/product.d.ts +45 -0
- package/dist/types/compute-engine/symbolic/sum.d.ts +25 -0
- package/dist/types/compute-engine/symbolic/utils.d.ts +47 -0
- package/dist/types/compute-engine.d.ts +3 -5
- package/dist/types/math-json/math-json-format.d.ts +101 -0
- package/dist/types/math-json/utils.d.ts +97 -0
- package/dist/types/math-json.d.ts +4 -3
- package/package.json +29 -28
- package/dist/compute-engine.js +0 -17296
- package/dist/cortex.esm.js +0 -20989
- package/dist/cortex.js +0 -21011
- package/dist/cortex.min.esm.js +0 -7
- package/dist/cortex.min.js +0 -7
- package/dist/math-json.js +0 -12517
- package/dist/types/common/debug.d.ts +0 -28
- package/dist/types/common/utils.d.ts +0 -153
- package/dist/types/compute-engine/canonical-forms.d.ts +0 -74
- package/dist/types/compute-engine/dictionary/domains.d.ts +0 -26
- package/dist/types/compute-engine/dictionary/utils.d.ts +0 -5
- package/dist/types/compute-engine/domains.d.ts +0 -4
- package/dist/types/compute-engine/evaluate.d.ts +0 -13
- package/dist/types/compute-engine/expression-map.d.ts +0 -11
- package/dist/types/compute-engine/internal-compute-engine.d.ts +0 -108
- package/dist/types/compute-engine/numeric-complex.d.ts +0 -2
- package/dist/types/compute-engine/numeric-decimal.d.ts +0 -12
- package/dist/types/compute-engine/numeric.d.ts +0 -21
- package/dist/types/compute-engine/numerical-eval.d.ts +0 -5
- package/dist/types/compute-engine/order.d.ts +0 -18
- package/dist/types/compute-engine/patterns.d.ts +0 -22
- package/dist/types/compute-engine/predicates.d.ts +0 -42
- package/dist/types/compute-engine/simplify.d.ts +0 -6
- package/dist/types/compute-engine/utils.d.ts +0 -15
- package/dist/types/cortex/formatter.d.ts +0 -165
- package/dist/types/cortex/parse-cortex.d.ts +0 -5
- package/dist/types/cortex/reserved-words.d.ts +0 -1
- package/dist/types/cortex/serialize-cortex.d.ts +0 -14
- package/dist/types/cortex.d.ts +0 -8
- package/dist/types/latex-syntax/definitions-algebra.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-arithmetic.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-calculus.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-core.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-inequalities.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-other.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-sets.d.ts +0 -2
- package/dist/types/latex-syntax/definitions-symbols.d.ts +0 -3
- package/dist/types/latex-syntax/definitions-trigonometry.d.ts +0 -3
- package/dist/types/latex-syntax/definitions.d.ts +0 -40
- package/dist/types/latex-syntax/latex-syntax.d.ts +0 -27
- package/dist/types/latex-syntax/parse.d.ts +0 -138
- package/dist/types/latex-syntax/public.d.ts +0 -456
- package/dist/types/latex-syntax/serializer.d.ts +0 -26
- package/dist/types/latex-syntax/utils.d.ts +0 -10
- package/dist/types/point-free-parser/characters.d.ts +0 -25
- package/dist/types/point-free-parser/combinators.d.ts +0 -46
- package/dist/types/point-free-parser/core-combinators.d.ts +0 -78
- package/dist/types/point-free-parser/grammar.d.ts +0 -12
- package/dist/types/point-free-parser/identifier-parsers.d.ts +0 -7
- package/dist/types/point-free-parser/numeric-parsers.d.ts +0 -8
- package/dist/types/point-free-parser/parsers.d.ts +0 -130
- package/dist/types/point-free-parser/string-parsers.d.ts +0 -29
- package/dist/types/point-free-parser/whitespace-parsers.d.ts +0 -17
- package/dist/types/public.d.ts +0 -163
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
indentChar: string;
|
|
3
|
-
indentCharWidth: number;
|
|
4
|
-
indentWidth: number;
|
|
5
|
-
margin: number;
|
|
6
|
-
softMargin: number;
|
|
7
|
-
aroundInfixOperator: string;
|
|
8
|
-
aroundRelationalOperator: string;
|
|
9
|
-
afterSeparator: string;
|
|
10
|
-
cost: FormattingCosts;
|
|
11
|
-
};
|
|
12
|
-
export declare type FormattingCosts = {
|
|
13
|
-
softMargin: number;
|
|
14
|
-
margin: number;
|
|
15
|
-
linebreak: number;
|
|
16
|
-
commentLinebreak: number;
|
|
17
|
-
flowLinebreak: number;
|
|
18
|
-
callLinebreak: number;
|
|
19
|
-
argLinebreak: number;
|
|
20
|
-
};
|
|
21
|
-
export declare abstract class FormattingBlock {
|
|
22
|
-
protected fmt: Formatter;
|
|
23
|
-
/** Return a printable string representing this block */
|
|
24
|
-
abstract serialize(offset: number): string;
|
|
25
|
-
/** When starting at `offset`, what is the cost of this block */
|
|
26
|
-
abstract cost(offset: number): number;
|
|
27
|
-
/** When starting at `offset`, what is the column after this block */
|
|
28
|
-
abstract nextCol(offset: number): number;
|
|
29
|
-
/** Output debug representation of the block */
|
|
30
|
-
abstract debug(): string;
|
|
31
|
-
constructor(fmt: Formatter);
|
|
32
|
-
}
|
|
33
|
-
export declare class EmptyBlock extends FormattingBlock {
|
|
34
|
-
constructor(fmt: Formatter);
|
|
35
|
-
debug(): string;
|
|
36
|
-
serialize(_offset: number): string;
|
|
37
|
-
nextCol(offset: number): number;
|
|
38
|
-
cost(_offset: number): number;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* | | |
|
|
43
|
-
*
|
|
44
|
-
* | [--------]* | |
|
|
45
|
-
*
|
|
46
|
-
* | [------------|---]* |
|
|
47
|
-
*
|
|
48
|
-
* | [------------|--------|---]*
|
|
49
|
-
*
|
|
50
|
-
* | | |
|
|
51
|
-
* 0 margin
|
|
52
|
-
* soft-margin
|
|
53
|
-
*
|
|
54
|
-
*/
|
|
55
|
-
export declare class TextBlock extends FormattingBlock {
|
|
56
|
-
s: string;
|
|
57
|
-
constructor(fmt: Formatter, s: string);
|
|
58
|
-
debug(): string;
|
|
59
|
-
serialize(_offset: number): string;
|
|
60
|
-
nextCol(offset: number): number;
|
|
61
|
-
cost(offset: number): number;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* A block that places its elements in a single line
|
|
65
|
-
*
|
|
66
|
-
* 0 offset
|
|
67
|
-
* |
|
|
68
|
-
* | [--------][-----------][------][----------]*
|
|
69
|
-
* |
|
|
70
|
-
*/
|
|
71
|
-
export declare class LineBlock extends FormattingBlock {
|
|
72
|
-
private blocks;
|
|
73
|
-
constructor(fmt: Formatter, ...blocks: FormattingBlock[]);
|
|
74
|
-
debug(): string;
|
|
75
|
-
serialize(offset: number): string;
|
|
76
|
-
nextCol(offset: number): number;
|
|
77
|
-
cost(offset: number): number;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* A block that arranges its elements vertically, separated by line breaks.
|
|
81
|
-
*
|
|
82
|
-
* 0 offset
|
|
83
|
-
* |
|
|
84
|
-
* | [---1----]
|
|
85
|
-
* | [-----2------]
|
|
86
|
-
* | [--3--]
|
|
87
|
-
* | [----4----]
|
|
88
|
-
* | *
|
|
89
|
-
* |
|
|
90
|
-
*/
|
|
91
|
-
export declare class StackBlock extends FormattingBlock {
|
|
92
|
-
private blocks;
|
|
93
|
-
constructor(fmt: Formatter, ...blocks: FormattingBlock[]);
|
|
94
|
-
debug(): string;
|
|
95
|
-
serialize(offset: number): string;
|
|
96
|
-
nextCol(offset: number): number;
|
|
97
|
-
cost(offset: number): number;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* A block that arranges its elements like a justified paragraph
|
|
101
|
-
*
|
|
102
|
-
* | |
|
|
103
|
-
* | [---1----][----2------] |
|
|
104
|
-
* | [--3---][----4-----] |
|
|
105
|
-
* | [--5--][--6---][--7--] |
|
|
106
|
-
* | [---8----]* |
|
|
107
|
-
* | |
|
|
108
|
-
*
|
|
109
|
-
*/
|
|
110
|
-
export declare class WrapBlock extends FormattingBlock {
|
|
111
|
-
private blocks;
|
|
112
|
-
constructor(fmt: Formatter, ...blocks: FormattingBlock[]);
|
|
113
|
-
debug(): string;
|
|
114
|
-
solution(offset: number): FormattingBlock;
|
|
115
|
-
serialize(offset: number): string;
|
|
116
|
-
nextCol(offset: number): number;
|
|
117
|
-
cost(offset: number): number;
|
|
118
|
-
}
|
|
119
|
-
export declare class ChoiceBlock extends FormattingBlock {
|
|
120
|
-
private blocks;
|
|
121
|
-
constructor(fmt: Formatter, ...blocks: FormattingBlock[]);
|
|
122
|
-
debug(): string;
|
|
123
|
-
choice(offset: number): FormattingBlock;
|
|
124
|
-
serialize(offset: number): string;
|
|
125
|
-
nextCol(offset: number): number;
|
|
126
|
-
cost(offset: number): number;
|
|
127
|
-
}
|
|
128
|
-
export declare class Formatter {
|
|
129
|
-
private options;
|
|
130
|
-
constructor(options?: Partial<FormattingOptions>);
|
|
131
|
-
get cost(): FormattingCosts;
|
|
132
|
-
get margin(): number;
|
|
133
|
-
get softMargin(): number;
|
|
134
|
-
indentChars(n?: number): string;
|
|
135
|
-
indentLength(n?: number): number;
|
|
136
|
-
linebreak(a?: string, b?: string): string;
|
|
137
|
-
countLinebreaks(s: string): number;
|
|
138
|
-
normalizedBlocks(blocks: (string | FormattingBlock)[]): FormattingBlock[];
|
|
139
|
-
/** A binary or ternary operator: +, -, etc... */
|
|
140
|
-
infixOperator(op: string): TextBlock;
|
|
141
|
-
/** A relational operator: =, <=, etc.. */
|
|
142
|
-
relationalOperator(op: string): TextBlock;
|
|
143
|
-
separator(op: string): TextBlock;
|
|
144
|
-
fence(f: string): TextBlock;
|
|
145
|
-
/** A single line of unbroken text */
|
|
146
|
-
text(s?: string): EmptyBlock | TextBlock;
|
|
147
|
-
/** Horizontal juxtaposition of a list of blocks */
|
|
148
|
-
line(...inBlocks: (string | FormattingBlock)[]): FormattingBlock;
|
|
149
|
-
/** A list of block stacked on top of one another */
|
|
150
|
-
stack(...inBlocks: (string | FormattingBlock)[]): FormattingBlock;
|
|
151
|
-
/** Packs its constituent layouts horizontally, inserting line breaks
|
|
152
|
-
* between them so as to minimize the total cost of output, in a manner
|
|
153
|
-
* analogous to the composition of words in paragraph.
|
|
154
|
-
*
|
|
155
|
-
* Output after line breaks begins at the starting column of the entire
|
|
156
|
-
* block.
|
|
157
|
-
* */
|
|
158
|
-
wrap(...inBlocks: (string | FormattingBlock)[]): FormattingBlock;
|
|
159
|
-
/** Indent a block by `indent` units. The value of a unit is specified in the options */
|
|
160
|
-
indent(block: FormattingBlock, indent?: number): FormattingBlock;
|
|
161
|
-
choice(...inBlocks: (string | FormattingBlock)[]): FormattingBlock;
|
|
162
|
-
fencedBlock(open: string, block: FormattingBlock, close: string): FormattingBlock;
|
|
163
|
-
fencedList(open: string, sep: string | FormattingBlock, close: string, blocks: FormattingBlock[]): FormattingBlock;
|
|
164
|
-
list(sep: string | FormattingBlock, blocks: FormattingBlock[]): FormattingBlock;
|
|
165
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
import { ParsingDiagnostic } from '../point-free-parser/parsers';
|
|
3
|
-
/** Analyze the reported errors and combine them when possible */
|
|
4
|
-
export declare function analyzeErrors(errors: ParsingDiagnostic[]): ParsingDiagnostic[];
|
|
5
|
-
export declare function parseCortex(source: string, url?: string): [Expression, ParsingDiagnostic[]];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
import { Expression } from '../public';
|
|
3
|
-
import { FormattingOptions } from './formatter';
|
|
4
|
-
export declare const NUMBER_FORMATTING_OPTIONS: Required<NumberFormattingOptions>;
|
|
5
|
-
/**
|
|
6
|
-
* Serialize a MathJSON expression to Cortex.
|
|
7
|
-
*
|
|
8
|
-
* @param options.fancySymbols - If true, some operators are replaced
|
|
9
|
-
* with an equivalent Unicode character, for example: `*` -> `×`.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
export declare function serializeCortex(expr: Expression, options?: FormattingOptions & {
|
|
13
|
-
fancySymbols?: boolean;
|
|
14
|
-
}): string;
|
package/dist/types/cortex.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
export { LatexSyntax, parse, serialize } from './latex-syntax/latex-syntax';
|
|
3
|
-
export { ExpressionMap } from './compute-engine/expression-map';
|
|
4
|
-
export { ComputeEngine, format, evaluate, } from './compute-engine/compute-engine';
|
|
5
|
-
export { match, substitute, count } from './compute-engine/patterns';
|
|
6
|
-
export { parseCortex } from './cortex/parse-cortex';
|
|
7
|
-
export { serializeCortex } from './cortex/serialize-cortex';
|
|
8
|
-
export declare const version = "0.4.2";
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
import { LatexDictionary, LatexString, LatexToken, ParserFunction, SerializerFunction, LatexDictionaryEntry } from './public';
|
|
3
|
-
import { Numeric } from '../compute-engine/public';
|
|
4
|
-
export declare type IndexedLatexDictionaryEntry<T extends number = number> = {
|
|
5
|
-
name: string;
|
|
6
|
-
trigger?: {
|
|
7
|
-
symbol?: LatexToken | LatexToken[];
|
|
8
|
-
matchfix?: LatexToken | LatexToken[];
|
|
9
|
-
infix?: LatexToken | LatexToken[];
|
|
10
|
-
prefix?: LatexToken | LatexToken[];
|
|
11
|
-
postfix?: LatexToken | LatexToken[];
|
|
12
|
-
superfix?: LatexToken | LatexToken[];
|
|
13
|
-
subfix?: LatexToken | LatexToken[];
|
|
14
|
-
};
|
|
15
|
-
parse: Expression<T> | ParserFunction<T>;
|
|
16
|
-
serialize: SerializerFunction<T> | LatexString;
|
|
17
|
-
associativity: 'right' | 'left' | 'non' | 'both';
|
|
18
|
-
precedence: number;
|
|
19
|
-
arguments: 'group' | 'implicit' | '';
|
|
20
|
-
optionalLatexArg: number;
|
|
21
|
-
requiredLatexArg: number;
|
|
22
|
-
separator: LatexString;
|
|
23
|
-
closeFence: LatexString;
|
|
24
|
-
};
|
|
25
|
-
export declare type IndexedLatexDictionary<T extends number = number> = {
|
|
26
|
-
lookahead: number;
|
|
27
|
-
name: Map<string, IndexedLatexDictionaryEntry<T>>;
|
|
28
|
-
prefix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
29
|
-
infix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
30
|
-
postfix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
31
|
-
matchfix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
32
|
-
superfix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
33
|
-
subfix: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
34
|
-
symbol: (Map<LatexString, IndexedLatexDictionaryEntry<T>> | null)[];
|
|
35
|
-
environment: Map<string, IndexedLatexDictionaryEntry<T>>;
|
|
36
|
-
};
|
|
37
|
-
export declare function indexLatexDictionary<T extends number = number>(dic: readonly LatexDictionaryEntry<T>[], onError: ErrorListener<ErrorCode>): IndexedLatexDictionary<T>;
|
|
38
|
-
export declare const DEFAULT_LATEX_DICTIONARY: {
|
|
39
|
-
[category in DictionaryCategory]?: LatexDictionary<Numeric>;
|
|
40
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
import { DictionaryCategory, Expression, ErrorCode, ErrorListener } from '../public';
|
|
3
|
-
import { Numeric } from '../compute-engine/public';
|
|
4
|
-
export declare class LatexSyntax<T extends number = number> {
|
|
5
|
-
onError: ErrorListener<ErrorCode>;
|
|
6
|
-
options: Required<NumberFormattingOptions> & Required<ParseLatexOptions> & Required<SerializeLatexOptions>;
|
|
7
|
-
private dictionary;
|
|
8
|
-
constructor(options?: NumberFormattingOptions & ParseLatexOptions & SerializeLatexOptions & {
|
|
9
|
-
dictionary?: readonly LatexDictionaryEntry<T>[];
|
|
10
|
-
onError?: ErrorListener<ErrorCode>;
|
|
11
|
-
});
|
|
12
|
-
static getDictionary(domain?: DictionaryCategory | 'all'): Readonly<LatexDictionary<any>>;
|
|
13
|
-
parse(latex: LatexString): Expression;
|
|
14
|
-
serialize(expr: Expression<T>): LatexString;
|
|
15
|
-
}
|
|
16
|
-
export declare function parse<T extends number = Numeric>(latex: LatexString, options?: NumberFormattingOptions & ParseLatexOptions & {
|
|
17
|
-
dictionary?: Readonly<LatexDictionary<T>>;
|
|
18
|
-
onError?: ErrorListener<ErrorCode>;
|
|
19
|
-
}): Expression;
|
|
20
|
-
/**
|
|
21
|
-
* Serialize a MathJSON expression as a Latex string.
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
export declare function serialize<T extends number = number>(expr: Expression<T>, options?: NumberFormattingOptions & SerializeLatexOptions & {
|
|
25
|
-
dictionary?: Readonly<LatexDictionary<T>>;
|
|
26
|
-
onError?: ErrorListener<ErrorCode>;
|
|
27
|
-
}): LatexString;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
import { ParseLatexOptions, LatexDictionaryEntry, LatexToken, NumberFormattingOptions } from './public';
|
|
3
|
-
import { IndexedLatexDictionary } from './definitions';
|
|
4
|
-
export declare class Scanner<T extends number = number> implements Scanner<T> {
|
|
5
|
-
index: number;
|
|
6
|
-
readonly tokens: LatexToken[];
|
|
7
|
-
readonly onError: ErrorListener<ErrorCode>;
|
|
8
|
-
readonly dictionary: IndexedLatexDictionary<T>;
|
|
9
|
-
readonly options: Required<NumberFormattingOptions> & Required<ParseLatexOptions>;
|
|
10
|
-
private invisibleOperatorPrecedence;
|
|
11
|
-
constructor(tokens: LatexToken[], options: Required<NumberFormattingOptions> & Required<ParseLatexOptions>, dictionary: IndexedLatexDictionary<T>, onError: ErrorListener<ErrorCode>);
|
|
12
|
-
clone(start: number, end: number): Scanner<T>;
|
|
13
|
-
balancedClone(open: LatexToken | LatexToken[], close: LatexToken | LatexToken[], silentError?: boolean): Scanner<T> | null;
|
|
14
|
-
get atEnd(): boolean;
|
|
15
|
-
get peek(): LatexToken;
|
|
16
|
-
latex(start: number, end?: number): string;
|
|
17
|
-
latexAhead(n: number): string;
|
|
18
|
-
latexBefore(): string;
|
|
19
|
-
latexAfter(): string;
|
|
20
|
-
/**
|
|
21
|
-
* Return at most `maxLookahead` strings made from the tokens
|
|
22
|
-
* ahead.
|
|
23
|
-
*
|
|
24
|
-
* The index in the returned array correspond to the number of tokens.
|
|
25
|
-
* Note that since a token can be longer than one char ('\\pi', but also
|
|
26
|
-
* some astral plane unicode characters), the length of the string
|
|
27
|
-
* does not match that index. However, knowing the index is important
|
|
28
|
-
* to know by how many tokens to advance.
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
lookAhead(): string[];
|
|
32
|
-
peekDefinition(kind: 'symbol' | 'infix' | 'matchfix' | 'prefix' | 'postfix' | 'superfix' | 'subfix' | 'operator'): [LatexDictionaryEntry<T> | null, number];
|
|
33
|
-
next(): LatexToken;
|
|
34
|
-
skipSpace(): boolean;
|
|
35
|
-
match(target: LatexToken): boolean;
|
|
36
|
-
matchAll(target: LatexToken | LatexToken[]): boolean;
|
|
37
|
-
matchAny(targets: LatexToken[]): LatexToken;
|
|
38
|
-
matchWhile(targets: LatexToken[]): LatexToken[];
|
|
39
|
-
matchSign(): string;
|
|
40
|
-
matchDecimalDigits(): string;
|
|
41
|
-
matchSignedInteger(): string;
|
|
42
|
-
matchExponent(): string;
|
|
43
|
-
matchNumber(): string;
|
|
44
|
-
matchOperator(kind: 'infix' | 'prefix' | 'postfix', lhs?: Expression<T> | null, minPrec?: number): Expression<T> | null;
|
|
45
|
-
matchArguments(kind: undefined | '' | 'group' | 'implicit'): Expression<T>[] | null;
|
|
46
|
-
matchMatchfixOperator(): Expression<T> | null;
|
|
47
|
-
matchDefinition(kind: 'symbol' | 'infix' | 'matchfix' | 'prefix' | 'postfix' | 'superfix' | 'subfix' | 'operator'): [LatexDictionaryEntry<T> | null, Expression<T> | null];
|
|
48
|
-
/**
|
|
49
|
-
* A symbol can be:
|
|
50
|
-
* - a constant: `\pi`
|
|
51
|
-
* - a variable: `x`
|
|
52
|
-
* - a function with explicit arguments `f(x)`
|
|
53
|
-
* - a function with implicit arguments: `\cos x`
|
|
54
|
-
* - a command: `\frac{2}{3}`
|
|
55
|
-
*/
|
|
56
|
-
matchSymbol(): Expression<T> | null;
|
|
57
|
-
matchOptionalLatexArgument(): Expression<T> | null;
|
|
58
|
-
/**
|
|
59
|
-
* Match a required latex argument:
|
|
60
|
-
* - either enclosed in `{}`
|
|
61
|
-
* - or a single token.
|
|
62
|
-
*
|
|
63
|
-
* Return null if an argument was not found
|
|
64
|
-
* Return '' if an empty argument `{}` was found
|
|
65
|
-
*/
|
|
66
|
-
matchRequiredLatexArgument(): Expression<T> | null;
|
|
67
|
-
/**
|
|
68
|
-
* Match a superfix/subfix operator, e.g. `^{*}`
|
|
69
|
-
*/
|
|
70
|
-
matchSupsub(lhs: Expression<T> | null): Expression<T> | null;
|
|
71
|
-
matchPostfix(lhs: Expression<T> | null): Expression<T> | null;
|
|
72
|
-
matchString(): string;
|
|
73
|
-
matchEnvironmentName(command: '\\begin' | '\\end', envName: string): boolean;
|
|
74
|
-
/**
|
|
75
|
-
* Match an expression in a tabular format,
|
|
76
|
-
* where row are separated by `\\` and columns by `&`
|
|
77
|
-
*
|
|
78
|
-
* Return rows of sparse columns as a list: empty rows are indicated with NOTHING,
|
|
79
|
-
* and empty cells are also indicated with NOTHING.
|
|
80
|
-
*/
|
|
81
|
-
matchTabular(): null | Expression<T>;
|
|
82
|
-
matchEnvironment(): Expression<T> | null;
|
|
83
|
-
/**
|
|
84
|
-
* Apply the operator `op` to the left-hand-side and right-hand-side
|
|
85
|
-
* expression. Applies the associativity rule specified by the definition,
|
|
86
|
-
* i.e. 'op(a, op(b, c))` -> `op(a, b, c)`, etc...
|
|
87
|
-
*
|
|
88
|
-
* `op` is the name of the operator which should have a corresponding
|
|
89
|
-
* definition.
|
|
90
|
-
*
|
|
91
|
-
* If `op` is an infix operator, it should have both a lhs and rhs.
|
|
92
|
-
* If `op` is a postfix operator, it should only have a lhs.
|
|
93
|
-
* If `op` is a prefix operator, the lhs is returned as the first element
|
|
94
|
-
* of the return tuple.
|
|
95
|
-
*
|
|
96
|
-
* @return a tuple: [lhs, rhs]
|
|
97
|
-
*/
|
|
98
|
-
applyOperator(op: string, lhs: Expression<T> | null, rhs: Expression<T> | null): NonNullable<[Expression<T> | null, Expression<T> | null]>;
|
|
99
|
-
/**
|
|
100
|
-
* Apply an invisible operator between two expressions.
|
|
101
|
-
*
|
|
102
|
-
* If no `invisibleOperator` was specified, use the `latex` operator.
|
|
103
|
-
*
|
|
104
|
-
* If the lhs is a number and the rhs is a fraction of integers,
|
|
105
|
-
* assume an 'invisible plus', that is '2 3/4' -> ['add', 2, [divide, 3, 4]]
|
|
106
|
-
* unless `invisiblePlusOperator` is empty
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
applyInvisibleOperator(lhs: Expression<T> | null, rhs: Expression<T> | null): Expression<T> | null;
|
|
110
|
-
matchUnknownLatexCommand(): Expression<T> | null;
|
|
111
|
-
/**
|
|
112
|
-
* <primary> :=
|
|
113
|
-
* (<number> | <symbol> | <environment> | <matchfix-expr>) <subsup>* <postfix-operator>*
|
|
114
|
-
*
|
|
115
|
-
* <symbol> ::= (<symbol-id> | (<latex-command><latex-arguments>)) <arguments>
|
|
116
|
-
*
|
|
117
|
-
* <matchfix-expr> :=
|
|
118
|
-
* <matchfix-op-open> <expression> [<matchfix-op-separator> <expression>] <matchfix-op-close>
|
|
119
|
-
*
|
|
120
|
-
*/
|
|
121
|
-
matchPrimary(_minPrec?: number): Expression<T> | null;
|
|
122
|
-
matchBalancedExpression(open: LatexToken | LatexToken[], close: LatexToken | LatexToken[], onError?: ErrorListener<ErrorCode>): Expression<T> | null;
|
|
123
|
-
/**
|
|
124
|
-
* Parse an expression:
|
|
125
|
-
*
|
|
126
|
-
* <expression> ::=
|
|
127
|
-
* | <primary>
|
|
128
|
-
* | <prefix-op> <primary>
|
|
129
|
-
* | <primary> <infix-op> <expression>
|
|
130
|
-
*
|
|
131
|
-
* Stop when an operator of precedence less than `minPrec` is encountered
|
|
132
|
-
*/
|
|
133
|
-
matchExpression(minPrec?: number): Expression<T> | null;
|
|
134
|
-
/**
|
|
135
|
-
* Add latex or other requested metadata to the expression
|
|
136
|
-
*/
|
|
137
|
-
decorate(expr: Expression<T> | null, start: number): Expression<T> | null;
|
|
138
|
-
}
|