@cortex-js/compute-engine 0.4.2 → 0.4.3
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 -2
- package/dist/compute-engine.esm.js +22446 -16214
- package/dist/compute-engine.js +22449 -16222
- package/dist/compute-engine.min.esm.js +2 -7
- package/dist/compute-engine.min.js +2 -7
- package/dist/math-json.esm.js +4336 -10528
- package/dist/math-json.js +4353 -10531
- 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 +93 -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 +52 -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 +233 -97
- 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 +550 -0
- package/dist/types/{common → compute-engine/latex-syntax}/serialize-number.d.ts +2 -3
- 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 +43 -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 +1076 -434
- 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 +5 -3
- package/package.json +27 -26
- 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/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,130 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
export declare type DiagnosticMessage = DiagnosticCode | [DiagnosticCode, ...any];
|
|
3
|
-
/**
|
|
4
|
-
* The parser will attempt to continue parsing even when an error is
|
|
5
|
-
* encountered.
|
|
6
|
-
*
|
|
7
|
-
* However, in the rare cases where parsing cannot proceed, this
|
|
8
|
-
* error will be thrown.
|
|
9
|
-
*
|
|
10
|
-
* This would happen if a `#error` directive is encountered.
|
|
11
|
-
*/
|
|
12
|
-
export declare class FatalParsingError extends Error {
|
|
13
|
-
constructor(msg: string);
|
|
14
|
-
}
|
|
15
|
-
export declare type Fixit = [start: number, end: number, value: string];
|
|
16
|
-
export declare type ParsingDiagnostic = {
|
|
17
|
-
severity: 'warning' | 'error';
|
|
18
|
-
message: DiagnosticMessage;
|
|
19
|
-
range: [start: number, end: number, position?: number];
|
|
20
|
-
fixits?: Fixit[];
|
|
21
|
-
};
|
|
22
|
-
export interface Rules {
|
|
23
|
-
parse<T = any>(name: string, parser: Parser | string, url?: string): Result<T>;
|
|
24
|
-
has(name: string): boolean;
|
|
25
|
-
}
|
|
26
|
-
export declare type Combinator<T = any> = [
|
|
27
|
-
label: string,
|
|
28
|
-
parser: (parser: Parser) => Result<T>
|
|
29
|
-
];
|
|
30
|
-
/**
|
|
31
|
-
* The `Parser` keeps track of what we are parsing (the source) and what we have
|
|
32
|
-
* parsed so far (the offset).
|
|
33
|
-
*/
|
|
34
|
-
export declare class Parser {
|
|
35
|
-
private rules;
|
|
36
|
-
readonly url: string;
|
|
37
|
-
readonly source: string;
|
|
38
|
-
protected _offset: number;
|
|
39
|
-
length: number;
|
|
40
|
-
private _trace;
|
|
41
|
-
constructor(rules: Rules, source: string, url: string);
|
|
42
|
-
get(offset: number): number;
|
|
43
|
-
atEnd(): boolean;
|
|
44
|
-
atLinebreak(): boolean;
|
|
45
|
-
atString(s: string): boolean;
|
|
46
|
-
slice(start: number, end?: number): string;
|
|
47
|
-
get offset(): number;
|
|
48
|
-
trace(rule: string | Combinator | ((parser: Parser) => Result)): string[];
|
|
49
|
-
skipTo(offset: number): Parser;
|
|
50
|
-
fatalError(msg: string): void;
|
|
51
|
-
hasRule(rule: string): boolean;
|
|
52
|
-
parse<T>(rule: string | Combinator<T> | ((parser: Parser) => Result<T>), fromOffset?: number): Result<T>;
|
|
53
|
-
parseWhitespace(): Result<boolean>;
|
|
54
|
-
ignore(): Result;
|
|
55
|
-
failure(): Result;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The result of applying a parsing rule:
|
|
59
|
-
* - `Ignore`: the rule matched and the result can be ignored
|
|
60
|
-
* - `Failure`: the rule did not match at all. Maybe try something else?
|
|
61
|
-
* - `Success`: the rule matched and generated a value that can be passed on.
|
|
62
|
-
* - `Error`: the rule matched, then something went wrong. Probably a
|
|
63
|
-
* syntax error. It still produced a value so the parsing can attempt to
|
|
64
|
-
* recover and continue (Panic Mode).
|
|
65
|
-
*/
|
|
66
|
-
export declare class Result<IR = any> {
|
|
67
|
-
readonly _parser: Parser;
|
|
68
|
-
_value: undefined | null | IR;
|
|
69
|
-
_diagnostics?: ParsingDiagnostic[];
|
|
70
|
-
_range: [start: number, end: number];
|
|
71
|
-
constructor(parser: Parser);
|
|
72
|
-
copyDiagnostics(from: Result<any>): void;
|
|
73
|
-
get parser(): Parser;
|
|
74
|
-
get diagnostics(): ParsingDiagnostic[];
|
|
75
|
-
get isFailure(): boolean;
|
|
76
|
-
get isEmpty(): boolean;
|
|
77
|
-
get isSuccess(): boolean;
|
|
78
|
-
get isError(): boolean;
|
|
79
|
-
get start(): number;
|
|
80
|
-
get end(): number;
|
|
81
|
-
set end(val: number);
|
|
82
|
-
set range(val: [start: number, end: number]);
|
|
83
|
-
get value(): IR | undefined | null;
|
|
84
|
-
set value(val: IR | undefined | null);
|
|
85
|
-
/**
|
|
86
|
-
* Use when a portion of the source has been successfully parsed.
|
|
87
|
-
*/
|
|
88
|
-
success(val: IR): Result<IR>;
|
|
89
|
-
/**
|
|
90
|
-
* A `failure` indicates a failed attempt to parse, with no presumption
|
|
91
|
-
* of success, for example when exploring multiple alternatives.
|
|
92
|
-
*
|
|
93
|
-
* `state` indicate where to restart parsing from.
|
|
94
|
-
*
|
|
95
|
-
* The `error` includes the origin (offset) of the failure. It could be after
|
|
96
|
-
* the `state`.
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
failure(): Result;
|
|
100
|
-
/**
|
|
101
|
-
* An `ignore` result indicates success in parsing, but with a result that
|
|
102
|
-
* can be ignored.
|
|
103
|
-
*
|
|
104
|
-
* This is useful for whitespace, keywords, braces and other similar syntactic
|
|
105
|
-
* constructs.
|
|
106
|
-
*
|
|
107
|
-
* `next` is the offset from which parsing can continue.
|
|
108
|
-
* `start` is the offset in the source where the element was first ignored.
|
|
109
|
-
*
|
|
110
|
-
*/
|
|
111
|
-
ignore(): Result;
|
|
112
|
-
ignoreUntil(offset: number): Result;
|
|
113
|
-
/**
|
|
114
|
-
* An `error` is used when an unexpected failure was encountered.
|
|
115
|
-
* It typically indicates a syntax error.
|
|
116
|
-
*
|
|
117
|
-
* Nonetheless, an attempt is made to recover.
|
|
118
|
-
*
|
|
119
|
-
* The range indicate the portion of the source covered by this result.
|
|
120
|
-
* The optional `pos` indicate where the error occurred. It's the `end`
|
|
121
|
-
* by default.
|
|
122
|
-
*
|
|
123
|
-
*/
|
|
124
|
-
error(value: IR, msg: DiagnosticMessage | ((Parser: any) => DiagnosticMessage), fixits?: Fixit[]): Result<IR>;
|
|
125
|
-
errorAt(value: IR | null, msg: DiagnosticMessage | ((Parser: any) => DiagnosticMessage), pos: number, fixits?: Fixit[]): Result<IR>;
|
|
126
|
-
errorFrom(result: Result, value: IR): Result<IR>;
|
|
127
|
-
warning(msg: DiagnosticMessage, fixits?: Fixit[]): Result;
|
|
128
|
-
}
|
|
129
|
-
export declare function skipUntil(parser: Parser, value: number): number;
|
|
130
|
-
export declare function skipUntilString(parser: Parser, pattern: string): number;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
/** Parse an escape sequence such as `\n` or `\u0041`*/
|
|
3
|
-
export declare function parseEscapeSequence(parser: Parser): Result<string>;
|
|
4
|
-
/** A key string is a sequence of non-White_Space, non-Syntax characters */
|
|
5
|
-
export declare function parseKeyString(parser: Parser): Result<string>;
|
|
6
|
-
/** An extended string is surrounded by `###"..."###` or `#"..."#` and
|
|
7
|
-
* contains no escape sequence. Convenient for strings that contain lots
|
|
8
|
-
* of characters that would otherwise need to be escaped: quotation marks,
|
|
9
|
-
* backslash, etc...
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
export declare function parseExtendedString(parser: Parser): Result<string>;
|
|
13
|
-
/** At the `\` of a `\(...)` expression */
|
|
14
|
-
export declare function parseInterpolation<IR>(parser: Parser, expression?: string | ((parser: Parser) => Result<IR>)): Result<IR>;
|
|
15
|
-
/** A single line string is surrounded by quotation mark and may include escape sequences.
|
|
16
|
-
*
|
|
17
|
-
* @param expression - a function that parses an expression inside a `\()` escape sequence
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
export declare function parseSingleLineString<T>(parser: Parser, expression?: string | ((parser: Parser) => Result<T>)): Result<(string | T)[]>;
|
|
21
|
-
/**
|
|
22
|
-
* A multiline line string begins and end with a triple quotation mark """
|
|
23
|
-
* It can span multiple lines and contain escape sequences.
|
|
24
|
-
*
|
|
25
|
-
* @param expression - a function that parses an expresion inside a `\()`
|
|
26
|
-
* escape sequence
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
export declare function parseMultilineString<T>(parser: Parser, expression: string): Result<(string | T)[]>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
export declare function skipInlineSpaces(parser: Parser): void;
|
|
3
|
-
/**
|
|
4
|
-
* Skip all characters until a linebreak
|
|
5
|
-
*/
|
|
6
|
-
export declare function skipUntilLinebreak(parser: Parser): void;
|
|
7
|
-
/**
|
|
8
|
-
* If we are on a linebreak, skip it
|
|
9
|
-
*/
|
|
10
|
-
export declare function skipLinebreak(parser: Parser): void;
|
|
11
|
-
/**
|
|
12
|
-
* Whitespace includes space, tab, mathematical space, and comments.
|
|
13
|
-
*/
|
|
14
|
-
export declare function parseWhitespace(parser: Parser): Result<boolean>;
|
|
15
|
-
export declare function parseLineComment(parser: Parser): Result<boolean>;
|
|
16
|
-
export declare function parseBlockComment(parser: Parser): Result<boolean>;
|
|
17
|
-
export declare function parseShebang(parser: Parser): Result<boolean>;
|
package/dist/types/public.d.ts
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/* 0.4.2 */
|
|
2
|
-
export declare type SignalCode = RuntimeSignalCode | ('syntax-error' | 'invalid-name' | 'expected-predicate' | 'expected-symbol' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry');
|
|
3
|
-
export declare type SignalMessage = SignalCode | [SignalCode, ...any[]];
|
|
4
|
-
export declare type SignalOrigin = {
|
|
5
|
-
url?: string;
|
|
6
|
-
source?: string;
|
|
7
|
-
offset?: number;
|
|
8
|
-
line?: number;
|
|
9
|
-
column?: number;
|
|
10
|
-
around?: string;
|
|
11
|
-
};
|
|
12
|
-
export declare type Signal = {
|
|
13
|
-
severity?: 'warning' | 'error';
|
|
14
|
-
message: SignalMessage;
|
|
15
|
-
head?: string;
|
|
16
|
-
origin?: SignalOrigin;
|
|
17
|
-
};
|
|
18
|
-
export declare type ErrorSignal = Signal & {
|
|
19
|
-
severity: 'error';
|
|
20
|
-
};
|
|
21
|
-
export declare class CortexError extends Error {
|
|
22
|
-
constructor(errorSignal: Signal);
|
|
23
|
-
toString(): string;
|
|
24
|
-
}
|
|
25
|
-
export declare type WarningSignal = Signal & {
|
|
26
|
-
severity: 'warning';
|
|
27
|
-
};
|
|
28
|
-
export declare type ErrorSignalHandler = (error: ErrorSignal) => void;
|
|
29
|
-
export declare type WarningSignalHandler = (warnings: WarningSignal[]) => void;
|
|
30
|
-
export declare type ErrorListener<T> = (err: {
|
|
31
|
-
code: T;
|
|
32
|
-
arg?: string;
|
|
33
|
-
latex?: string;
|
|
34
|
-
before?: string;
|
|
35
|
-
after?: string;
|
|
36
|
-
}) => void;
|
|
37
|
-
/**
|
|
38
|
-
* * `unknown-symbol`: a symbol was encountered which does not have a
|
|
39
|
-
* definition.
|
|
40
|
-
*
|
|
41
|
-
* * `unknown-operator`: a presumed operator was encountered which does not
|
|
42
|
-
* have a definition.
|
|
43
|
-
*
|
|
44
|
-
* * `unknown-function`: a Latex command was encountered which does not
|
|
45
|
-
* have a definition.
|
|
46
|
-
*
|
|
47
|
-
* * `unexpected-command`: a Latex command was encountered when only a string
|
|
48
|
-
* was expected
|
|
49
|
-
*
|
|
50
|
-
* * `unexpected-superscript`: a superscript was encountered in an unexpected
|
|
51
|
-
* context, or no `powerFunction` was defined. By default, superscript can
|
|
52
|
-
* be applied to numbers, symbols or expressions, but not to operators (e.g.
|
|
53
|
-
* `2+^34`) or to punctuation.
|
|
54
|
-
*
|
|
55
|
-
* * `unexpected-subscript`: a subscript was encountered in an unexpected
|
|
56
|
-
* context or no 'subscriptFunction` was defined. By default, subscripts
|
|
57
|
-
* are not expected on numbers, operators or symbols. Some commands (e.g. `\sum`)
|
|
58
|
-
* do expected a subscript.
|
|
59
|
-
*
|
|
60
|
-
* * `unexpected-sequence`: some adjacent elements were encountered (for
|
|
61
|
-
* example `xy`), but no `invisibleOperator` is defined, therefore the elements
|
|
62
|
-
* can't be combined. The default `invisibleOperator` is `multiply`, but you
|
|
63
|
-
* can also use `list`.
|
|
64
|
-
*
|
|
65
|
-
* * `expected-argument`: a Latex command that requires one or more argument
|
|
66
|
-
* was encountered without the required arguments.
|
|
67
|
-
*
|
|
68
|
-
* * `expected-operand`: an operator was encountered without its required
|
|
69
|
-
* operands.
|
|
70
|
-
*
|
|
71
|
-
* * `non-associative-operator`: an operator which is not associative was
|
|
72
|
-
* encountered in an associative context, for example: `a < b < c` (assuming
|
|
73
|
-
* `<` is defined as non-associative)
|
|
74
|
-
*
|
|
75
|
-
* * `postfix-operator-requires-one-operand`: a postfix operator which requires
|
|
76
|
-
* a single argument was encountered with no arguments or more than one argument
|
|
77
|
-
*
|
|
78
|
-
* * `prefix-operator-requires-one-operand`: a prefix operator which requires
|
|
79
|
-
* a single argument was encountered with no arguments or more than one argument
|
|
80
|
-
*
|
|
81
|
-
* * `base-out-of-range`: The base is expected to be between 2 and 36.
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
export declare type ErrorCode = 'expected-argument' | 'unexpected-argument' | 'expected-operator' | 'expected-operand' | 'invalid-name' | 'invalid-dictionary-entry' | 'unknown-symbol' | 'unknown-operator' | 'unknown-function' | 'unknown-command' | 'unexpected-command' | 'unbalanced-symbols' | 'unexpected-superscript' | 'unexpected-subscript' | 'unexpected-sequence' | 'non-associative-operator' | 'function-has-too-many-arguments' | 'function-has-too-few-arguments' | 'operator-requires-one-operand' | 'infix-operator-requires-two-operands' | 'prefix-operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'associative-function-has-too-few-arguments' | 'commutative-function-has-too-few-arguments' | 'threadable-function-has-too-few-arguments' | 'hold-first-function-has-too-few-arguments' | 'hold-rest-function-has-too-few-arguments' | 'base-out-of-range' | 'syntax-error';
|
|
85
|
-
export declare type Attributes = {
|
|
86
|
-
/** A human readable string to annotate an expression, since JSON does not
|
|
87
|
-
* allow comments in its encoding */
|
|
88
|
-
comment?: string;
|
|
89
|
-
/** A Markdown-encoded string providing documentation about this expression.
|
|
90
|
-
*/
|
|
91
|
-
documentation?: string;
|
|
92
|
-
/** A human readable string to indicate a syntax error or
|
|
93
|
-
* other problem when parsing or evaluating an expression.
|
|
94
|
-
*/
|
|
95
|
-
error?: string;
|
|
96
|
-
/** A visual representation in LaTeX of the expression.
|
|
97
|
-
*
|
|
98
|
-
* This can be useful to preserve non-semantic details, for example
|
|
99
|
-
* parentheses in an expression or styling attributes
|
|
100
|
-
*/
|
|
101
|
-
latex?: string;
|
|
102
|
-
/**
|
|
103
|
-
* A short string indicating an entry in a wikibase.
|
|
104
|
-
*
|
|
105
|
-
* For example
|
|
106
|
-
* `"Q167"` is the [wikidata entry](https://www.wikidata.org/wiki/Q167)
|
|
107
|
-
* for the Pi constant.
|
|
108
|
-
*/
|
|
109
|
-
wikidata?: string;
|
|
110
|
-
/** A base URL for the `wikidata` key.
|
|
111
|
-
*
|
|
112
|
-
* A full URL can be produced by concatenating this key with the `wikidata`
|
|
113
|
-
* key. This key applies to this node and all its children.
|
|
114
|
-
*
|
|
115
|
-
* The default value is "https://www.wikidata.org/wiki/"
|
|
116
|
-
*/
|
|
117
|
-
wikibase?: string;
|
|
118
|
-
/** A short string indicating an entry in an OpenMath Content Dictionary.
|
|
119
|
-
*
|
|
120
|
-
* For example: `arith1/#abs`.
|
|
121
|
-
*
|
|
122
|
-
*/
|
|
123
|
-
openmathSymbol?: string;
|
|
124
|
-
/** A base URL for an OpenMath content dictionary. This key applies to this
|
|
125
|
-
* node and all its children.
|
|
126
|
-
*
|
|
127
|
-
* The default value is "http://www.openmath.org/cd".
|
|
128
|
-
*/
|
|
129
|
-
openmathCd?: string;
|
|
130
|
-
/** A url to the source of this expression.
|
|
131
|
-
*/
|
|
132
|
-
sourceUrl?: string;
|
|
133
|
-
/** The source from which this expression was generated.
|
|
134
|
-
*
|
|
135
|
-
* It could be a Latex expression, or some other source language
|
|
136
|
-
*/
|
|
137
|
-
sourceContent?: string;
|
|
138
|
-
/**
|
|
139
|
-
* A character offset in `sourceContent` or `sourceUrl` from which this
|
|
140
|
-
* expression was generated
|
|
141
|
-
*/
|
|
142
|
-
sourceOffsets?: [start: number, end: number];
|
|
143
|
-
};
|
|
144
|
-
export declare type MathJsonBasicNumber = 'NaN' | '-Infinity' | '+Infinity' | string;
|
|
145
|
-
export declare type MathJsonRealNumber = {
|
|
146
|
-
num: MathJsonBasicNumber;
|
|
147
|
-
} & Attributes;
|
|
148
|
-
export declare type MathJsonSymbol = {
|
|
149
|
-
sym: string;
|
|
150
|
-
} & Attributes;
|
|
151
|
-
export declare type MathJsonString = {
|
|
152
|
-
str: string;
|
|
153
|
-
} & Attributes;
|
|
154
|
-
export declare type MathJsonFunction<T extends number = number> = {
|
|
155
|
-
fn: Expression<T>[];
|
|
156
|
-
} & Attributes;
|
|
157
|
-
export declare type MathJsonDictionary<T extends number = number> = {
|
|
158
|
-
dict: {
|
|
159
|
-
[key: string]: Expression<T>;
|
|
160
|
-
};
|
|
161
|
-
} & Attributes;
|
|
162
|
-
export declare type Expression<T extends number = number> = T | MathJsonRealNumber | MathJsonString | MathJsonSymbol | string | MathJsonFunction<T> | MathJsonDictionary<T> | Expression<T>[];
|
|
163
|
-
export declare type DictionaryCategory = 'algebra' | 'arithmetic' | 'calculus' | 'collections' | 'complex' | 'combinatorics' | 'core' | 'dimensions' | 'domains' | 'inequalities' | 'intervals' | 'linear-algebra' | 'logic' | 'numeric' | 'other' | 'physics' | 'polynomials' | 'relations' | 'rounding' | 'sets' | 'statistics' | 'symbols' | 'transcendentals' | 'trigonometry' | 'units';
|