desmost 0.6.1 → 0.7.1
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/dist/compiler/compile.d.ts +1 -1
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/compile.js +34 -17
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/evaluate.js +3 -7
- package/dist/compiler/evaluate.js.map +1 -1
- package/dist/compiler/options.d.ts +4 -3
- package/dist/compiler/options.d.ts.map +1 -1
- package/dist/compiler/options.js +4 -3
- package/dist/compiler/options.js.map +1 -1
- package/dist/errors.d.ts +2 -3
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/magic/expr/text.d.ts +1 -0
- package/dist/magic/expr/text.d.ts.map +1 -1
- package/dist/magic/expr/text.js +1 -0
- package/dist/magic/expr/text.js.map +1 -1
- package/dist/magic/global/viewport.d.ts.map +1 -1
- package/dist/magic/global/viewport.js.map +1 -1
- package/dist/magic/local/label.js +1 -2
- package/dist/magic/local/label.js.map +1 -1
- package/dist/parser/desmost-parser.d.ts +5 -5
- package/dist/parser/desmost-parser.d.ts.map +1 -1
- package/dist/parser/desmost-parser.js +19 -19
- package/dist/parser/desmost-parser.js.map +1 -1
- package/dist/parser/generic-parser.d.ts +3 -3
- package/dist/parser/generic-parser.d.ts.map +1 -1
- package/dist/parser/generic-parser.js +5 -5
- package/dist/parser/generic-parser.js.map +1 -1
- package/package.json +1 -1
- package/src/compiler/compile.ts +55 -25
- package/src/compiler/evaluate.ts +3 -7
- package/src/compiler/options.ts +21 -13
- package/src/errors.ts +3 -10
- package/src/magic/expr/text.ts +1 -0
- package/src/magic/global/viewport.ts +1 -0
- package/src/magic/local/label.ts +1 -1
- package/src/parser/desmost-parser.ts +23 -27
- package/src/parser/generic-parser.ts +8 -8
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type DesmostOptions } from "./options.js";
|
|
2
2
|
import { Ast } from "../parser/index.js";
|
|
3
|
-
export declare function compile(desmos: Desmos.Calculator, source: string, options?: DesmostOptions): void | DesmostDebug;
|
|
4
3
|
export interface DesmostDebug {
|
|
5
4
|
duration: number;
|
|
6
5
|
num_blocks: number;
|
|
7
6
|
ast: Ast[];
|
|
8
7
|
}
|
|
8
|
+
export declare function compile(desmos: Desmos.Calculator, source: string, options?: DesmostOptions): void | DesmostDebug;
|
|
9
9
|
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAiB,GAAG,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAiB,GAAG,EAAE,MAAM,WAAW,CAAC;AAI/C,MAAM,WAAW,YAAY;IAE3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,GAAG,EAAE,CAAC;CACZ;AAoBD,wBAAgB,OAAO,CAErB,MAAM,EAAE,MAAM,CAAC,UAAU,EAGzB,MAAM,EAAE,MAAM,EAGd,OAAO,CAAC,EAAE,cAAc,GACvB,IAAI,GAAG,YAAY,CAkHrB"}
|
package/dist/compiler/compile.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { fill_defaults } from "./options.js";
|
|
2
2
|
import { evaluate_global_incantation, evaluate_expr, evaluate_error } from "./evaluate.js";
|
|
3
3
|
import { DesmostParser, Ast } from "../parser/index.js";
|
|
4
|
-
import { UnrecoverableError } from "../errors.js";
|
|
5
4
|
export function compile(desmos, source, options) {
|
|
6
5
|
if (desmos == undefined) {
|
|
7
6
|
console.error(`Desmost: No \`Desmos.Calculator\` instance provided, aborting compilation!`);
|
|
@@ -11,15 +10,19 @@ export function compile(desmos, source, options) {
|
|
|
11
10
|
console.error(`Desmost: No source code provided, aborting compilation!`);
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
14
|
-
let t_init = performance.now();
|
|
15
|
-
let num_blocks = 0;
|
|
16
|
-
let ast = [];
|
|
17
13
|
let opts = fill_defaults(options);
|
|
14
|
+
if (opts.debug) {
|
|
15
|
+
var t_init = performance.now();
|
|
16
|
+
var num_blocks = 0;
|
|
17
|
+
var ast = [];
|
|
18
|
+
}
|
|
18
19
|
let parser = new DesmostParser(source, opts);
|
|
20
|
+
let errors = [];
|
|
19
21
|
if (opts.place_errors === "start") {
|
|
20
|
-
desmos.setExpression({ id: "deferred-start", latex: "" });
|
|
22
|
+
desmos.setExpression({ id: "deferred-start", latex: " " });
|
|
21
23
|
}
|
|
22
|
-
let
|
|
24
|
+
let seen_non_blank = false;
|
|
25
|
+
let pending_blanks = 0;
|
|
23
26
|
try {
|
|
24
27
|
while (true) {
|
|
25
28
|
let r = parser.parse_next();
|
|
@@ -35,10 +38,21 @@ export function compile(desmos, source, options) {
|
|
|
35
38
|
defer = evaluate_global_incantation(r, desmos, opts);
|
|
36
39
|
break;
|
|
37
40
|
case Ast.Kind.EXPRESSION:
|
|
38
|
-
if (
|
|
41
|
+
if (r.data.latex === " ") {
|
|
42
|
+
if (opts.ignore_all_blanks)
|
|
43
|
+
break;
|
|
44
|
+
if (!seen_non_blank && !opts.keep_leading_blanks)
|
|
45
|
+
break;
|
|
46
|
+
pending_blanks++;
|
|
39
47
|
break;
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
flush_pending_blanks(desmos, pending_blanks);
|
|
51
|
+
pending_blanks = 0;
|
|
52
|
+
seen_non_blank = true;
|
|
53
|
+
defer = evaluate_expr(r, desmos, opts);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
42
56
|
case Ast.Kind.INVALID_INCANTATION:
|
|
43
57
|
defer = evaluate_error(r.error, desmos, opts);
|
|
44
58
|
break;
|
|
@@ -49,12 +63,10 @@ export function compile(desmos, source, options) {
|
|
|
49
63
|
}
|
|
50
64
|
}
|
|
51
65
|
catch (e) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw e;
|
|
57
|
-
}
|
|
66
|
+
errors.push(e.message);
|
|
67
|
+
}
|
|
68
|
+
if (opts.keep_trailing_blanks) {
|
|
69
|
+
flush_pending_blanks(desmos, pending_blanks);
|
|
58
70
|
}
|
|
59
71
|
if (errors.length > 0) {
|
|
60
72
|
let expr = {
|
|
@@ -74,9 +86,14 @@ export function compile(desmos, source, options) {
|
|
|
74
86
|
if (opts.debug) {
|
|
75
87
|
return {
|
|
76
88
|
duration: performance.now() - t_init,
|
|
77
|
-
num_blocks,
|
|
78
|
-
ast,
|
|
89
|
+
num_blocks: num_blocks,
|
|
90
|
+
ast: ast,
|
|
79
91
|
};
|
|
80
92
|
}
|
|
81
93
|
}
|
|
94
|
+
function flush_pending_blanks(desmos, count) {
|
|
95
|
+
for (let i = 0; i < count; i++) {
|
|
96
|
+
desmos.setExpression({ latex: ` ` });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
82
99
|
//# sourceMappingURL=compile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AA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AAoB,EAAE,CAAC;QAC9B,oBAAoB,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,IAAI,IAAI,GAA2B;YACjC,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;SAC1B,CAAC;QAEF,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;YAC1B,KAAK,OAAO;gBACV,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;gBACxD,MAAM;YACR,KAAK,KAAK,CAAC;YACX,KAAK,QAAQ;gBACX,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBAC3B,MAAM;QACV,CAAC;IACH,CAAC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,OAAO;YACL,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,MAAO;YACrC,UAAU,EAAE,UAAW;YACvB,GAAG,EAAE,GAAI;SACV,CAAC;IACJ,CAAC;AACH,CAAC;AAGD,SAAS,oBAAoB,CAAC,MAAyB,EAAE,KAAa;IAEpE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,MAAM,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IACvC,CAAC;AACH,CAAC"}
|
|
@@ -75,13 +75,9 @@ function normalise_latex(latex) {
|
|
|
75
75
|
return latex;
|
|
76
76
|
}
|
|
77
77
|
function prettify_latex(latex) {
|
|
78
|
-
latex = latex.replaceAll(/(?<!\\left)\(/g, "\\left
|
|
79
|
-
latex = latex.replaceAll(/(?<!\\right)\)/g, "\\right
|
|
80
|
-
latex = latex.replaceAll(/(
|
|
81
|
-
latex = latex.replaceAll(/(?<!\\right)\]/g, "\\right]");
|
|
82
|
-
latex = latex.replaceAll("\\{", "\\left\\{");
|
|
83
|
-
latex = latex.replaceAll("\\}", "\\right\\}");
|
|
84
|
-
latex = latex.replaceAll(/(?<=[^\w]|^)\\?(mean|median|count|total|repeat|join|sort|shuffle|unique|mod|ceil|floor|round|sign)(?=\(|\\left\()/g, "\\operatorname{$1}");
|
|
78
|
+
latex = latex.replaceAll(/(?<!\\left)(\(|\[|\\\{)/g, "\\left$1");
|
|
79
|
+
latex = latex.replaceAll(/(?<!\\right)(\)|\]|\\\})/g, "\\right$1");
|
|
80
|
+
latex = latex.replaceAll(/(?<=[^\w]|^)\\?(mean|median|count|total|repeat|join|sort|shuffle|unique|mod|ceil|floor|round|sign) ?(?=\(|\\left\()/g, "\\operatorname{$1}");
|
|
85
81
|
return latex;
|
|
86
82
|
}
|
|
87
83
|
//# sourceMappingURL=evaluate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/compiler/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAsB,MAAM,WAAW,CAAC;AAMnE,MAAM,UAAU,2BAA2B,CACzC,UAAqC,EACrC,MAAyB,EACzB,OAAiC;IAGjC,IAAI,IAAI,GAAG,SAAS,CAAC;IAErB,IAAI,SAAS,IAAI,UAAU,IAAI,UAAU,CAAC,OAAO,IAAI,SAAS,EAAE,CAAC;QAC/D,IAAI,CAAC;YACH,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,CAAC,EAAE,CAAC;YACT,IAAI,GAAG,GAAG,cAAc,CAAC,CAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;YACtD,IAAI,GA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C,IAAI,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAQD,MAAM,UAAU,cAAc,CAC5B,KAAyB,EACzB,MAAyB,EACzB,OAAiC;IAGjC,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;QACvB,KAAK,OAAO;YACV,MAAM,KAAK,CAAC;QAEd,KAAK,UAAU;YACb,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,MAAM;QAER,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC,YAAY,EAAE,CAAC;YACtC,KAAK,KAAK,CAAC;YACX,KAAK,OAAO;gBACV,OAAO,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAEtC;gBACE,MAAM,CAAC,aAAa,CAAC;oBACnB,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC;iBACnC,CAAC,CAAC;gBACH,MAAM;QACV,CAAC;IACH,CAAC;AACH,CAAC;AAMD,SAAS,eAAe,CAAC,KAAa;IAEpC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC;AACf,CAAC;AAWD,SAAS,cAAc,CAAC,KAAa;IAEnC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAC;IACjE,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAC;IAEnE,KAAK,GAAG,KAAK,CAAC,UAAU,CACtB,sHAAsH,EACtH,oBAAoB,CACrB,CAAC;IAEF,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -2,10 +2,11 @@ export interface DesmostOptions {
|
|
|
2
2
|
errors?: "surface" | "crash" | "suppress";
|
|
3
3
|
place_errors?: "inline" | "end" | "start";
|
|
4
4
|
error_prefix?: string;
|
|
5
|
-
ignore_comments?: boolean;
|
|
6
|
-
ignore_blank_lines?: boolean;
|
|
7
|
-
ignore_trailing_blanks?: boolean;
|
|
8
5
|
prettify?: boolean;
|
|
6
|
+
ignore_comments?: boolean;
|
|
7
|
+
ignore_all_blanks?: boolean;
|
|
8
|
+
keep_leading_blanks?: boolean;
|
|
9
|
+
keep_trailing_blanks?: boolean;
|
|
9
10
|
debug?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export declare function fill_defaults(options: Partial<DesmostOptions> | undefined): Required<DesmostOptions>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,cAAc;IAS7B,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;IASzC,YAAY,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;IASzC,YAAY,CAAC,EAAE,MAAM,CAAA;IAOrB,eAAe,CAAC,EAAE,OAAO,CAAA;IAOzB,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,cAAc;IAS7B,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;IASzC,YAAY,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;IASzC,YAAY,CAAC,EAAE,MAAM,CAAA;IAOrB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAOlB,eAAe,CAAC,EAAE,OAAO,CAAA;IAOzB,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAO3B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAO7B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAS9B,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAMD,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,CAiBpG"}
|
package/dist/compiler/options.js
CHANGED
|
@@ -3,10 +3,11 @@ export function fill_defaults(options) {
|
|
|
3
3
|
out.errors ??= "surface";
|
|
4
4
|
out.place_errors ??= "inline";
|
|
5
5
|
out.error_prefix ??= "[DESMOST ERROR]\n";
|
|
6
|
-
out.ignore_comments ??= false;
|
|
7
|
-
out.ignore_blank_lines ??= false;
|
|
8
|
-
out.ignore_trailing_blanks ??= false;
|
|
9
6
|
out.prettify ??= true;
|
|
7
|
+
out.ignore_comments ??= false;
|
|
8
|
+
out.ignore_all_blanks ??= false;
|
|
9
|
+
out.keep_leading_blanks ??= false;
|
|
10
|
+
out.keep_trailing_blanks ??= false;
|
|
10
11
|
out.debug ??= false;
|
|
11
12
|
return out;
|
|
12
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"AAuFA,MAAM,UAAU,aAAa,CAAC,OAA4C;IAExE,IAAI,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAErC,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC;IACzB,GAAG,CAAC,YAAY,KAAK,QAAQ,CAAC;IAC9B,GAAG,CAAC,YAAY,KAAK,mBAAmB,CAAC;IAEzC,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC;IAEtB,GAAG,CAAC,eAAe,KAAK,KAAK,CAAC;IAC9B,GAAG,CAAC,iBAAiB,KAAK,KAAK,CAAC;IAChC,GAAG,CAAC,mBAAmB,KAAK,KAAK,CAAC;IAClC,GAAG,CAAC,oBAAoB,KAAK,KAAK,CAAC;IACnC,GAAG,CAAC,KAAK,KAAK,KAAK,CAAC;IAEpB,OAAO,GAA+B,CAAC;AACzC,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -14,12 +14,11 @@ export declare namespace UnrecoverableError {
|
|
|
14
14
|
class InvalidArgument extends UnrecoverableError {
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
export declare const
|
|
18
|
-
export type
|
|
17
|
+
export declare const NO_MATCH: unique symbol;
|
|
18
|
+
export type NoMatch = typeof NO_MATCH & {
|
|
19
19
|
readonly __brand?: unique symbol;
|
|
20
20
|
};
|
|
21
21
|
export type Unrecoverable<Result> = Result | Result & {
|
|
22
22
|
readonly __brand?: unique symbol;
|
|
23
23
|
};
|
|
24
|
-
export type MaybeRecoverable<Result> = RecoverableFail | Unrecoverable<Result>;
|
|
25
24
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,yBAAiB,kBAAkB,CACnC;IAEE,MAAa,aAAc,SAAQ,kBAAkB;KAAG;IAGxD,MAAa,YAAa,SAAQ,kBAAkB;KAAG;IAGvD,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAG1D,MAAa,WAAY,SAAQ,kBAAkB;KAAG;IAItD,MAAa,kBAAmB,SAAQ,kBAAkB;KAAG;IAG7D,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;CAC3D;AAID,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,yBAAiB,kBAAkB,CACnC;IAEE,MAAa,aAAc,SAAQ,kBAAkB;KAAG;IAGxD,MAAa,YAAa,SAAQ,kBAAkB;KAAG;IAGvD,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAG1D,MAAa,WAAY,SAAQ,kBAAkB;KAAG;IAItD,MAAa,kBAAmB,SAAQ,kBAAkB;KAAG;IAG7D,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;CAC3D;AAID,eAAO,MAAM,QAAQ,eAAqB,CAAC;AAG3C,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAI7E,MAAM,MAAM,aAAa,CAAC,MAAM,IAAI,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -20,5 +20,5 @@ export class UnrecoverableError extends Error {
|
|
|
20
20
|
}
|
|
21
21
|
UnrecoverableError.InvalidArgument = InvalidArgument;
|
|
22
22
|
})(UnrecoverableError || (UnrecoverableError = {}));
|
|
23
|
-
export const
|
|
23
|
+
export const NO_MATCH = Symbol("no-match");
|
|
24
24
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,WAAiB,kBAAkB;IAGjC,MAAa,aAAc,SAAQ,kBAAkB;KAAG;IAA3C,gCAAa,gBAA8B,CAAA;IAGxD,MAAa,YAAa,SAAQ,kBAAkB;KAAG;IAA1C,+BAAY,eAA8B,CAAA;IAGvD,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAA7C,kCAAe,kBAA8B,CAAA;IAG1D,MAAa,WAAY,SAAQ,kBAAkB;KAAG;IAAzC,8BAAW,cAA8B,CAAA;IAItD,MAAa,kBAAmB,SAAQ,kBAAkB;KAAG;IAAhD,qCAAkB,qBAA8B,CAAA;IAG7D,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAA7C,kCAAe,kBAA8B,CAAA;AAC5D,CAAC,EApBgB,kBAAkB,KAAlB,kBAAkB,QAoBlC;AAID,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,WAAiB,kBAAkB;IAGjC,MAAa,aAAc,SAAQ,kBAAkB;KAAG;IAA3C,gCAAa,gBAA8B,CAAA;IAGxD,MAAa,YAAa,SAAQ,kBAAkB;KAAG;IAA1C,+BAAY,eAA8B,CAAA;IAGvD,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAA7C,kCAAe,kBAA8B,CAAA;IAG1D,MAAa,WAAY,SAAQ,kBAAkB;KAAG;IAAzC,8BAAW,cAA8B,CAAA;IAItD,MAAa,kBAAmB,SAAQ,kBAAkB;KAAG;IAAhD,qCAAkB,qBAA8B,CAAA;IAG7D,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAA7C,kCAAe,kBAA8B,CAAA;AAC5D,CAAC,EApBgB,kBAAkB,KAAlB,kBAAkB,QAoBlC;AAID,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { Incantation, ArgIncantation, type EXPR } from "../incantation.js";
|
|
|
2
2
|
export declare class TextIncantation extends ArgIncantation<EXPR> {
|
|
3
3
|
readonly description = "Produce a text expression (\u201CAdd Note\u201D in the Desmos GUI).";
|
|
4
4
|
readonly identifier = "text";
|
|
5
|
+
readonly alias = "note";
|
|
5
6
|
readonly requires_arg = true;
|
|
6
7
|
readonly arg_type = Incantation.ArgType.STRING;
|
|
7
8
|
apply(target: Desmos.ExpressionState, data: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/magic/expr/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGxE,qBAAa,eAAgB,SAAQ,cAAc,CAAC,IAAI,CAAC;IAEvD,SAAkB,WAAW,yEACkC;IAE/D,SAAkB,UAAU,UAAW;IACvC,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAElD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM;CAM5D"}
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/magic/expr/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGxE,qBAAa,eAAgB,SAAQ,cAAc,CAAC,IAAI,CAAC;IAEvD,SAAkB,WAAW,yEACkC;IAE/D,SAAkB,UAAU,UAAW;IACvC,SAAkB,KAAK,UAAgB;IACvC,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAElD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM;CAM5D"}
|
package/dist/magic/expr/text.js
CHANGED
|
@@ -2,6 +2,7 @@ import { Incantation, ArgIncantation } from "../incantation.js";
|
|
|
2
2
|
export class TextIncantation extends ArgIncantation {
|
|
3
3
|
description = "Produce a text expression (“Add Note” in the Desmos GUI).";
|
|
4
4
|
identifier = "text";
|
|
5
|
+
alias = "note";
|
|
5
6
|
requires_arg = true;
|
|
6
7
|
arg_type = Incantation.ArgType.STRING;
|
|
7
8
|
apply(target, data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/magic/expr/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAGxE,MAAM,OAAO,eAAgB,SAAQ,cAAoB;IAErC,WAAW,GACzB,2DAA2D,CAAA;IAE7C,UAAU,GAAK,MAAM,CAAA;IACrB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CAAC,MAA8B,EAAE,IAAY;QAEzD,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC;QAErB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACF"}
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/magic/expr/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAGxE,MAAM,OAAO,eAAgB,SAAQ,cAAoB;IAErC,WAAW,GACzB,2DAA2D,CAAA;IAE7C,UAAU,GAAK,MAAM,CAAA;IACrB,KAAK,GAAU,MAAM,CAAA;IACrB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CAAC,MAA8B,EAAE,IAAY;QAEzD,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC;QAErB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG1E,UAAU,cAAc;IAEtB,IAAI,EAAI,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAI,MAAM,CAAC;CAC/B;AAGD,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAE7D,SAAkB,WAAW,sEACyC;IAEtE,SAAkB,UAAU,cAAe;IAC3C,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAE3D,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG1E,UAAU,cAAc;IAEtB,IAAI,EAAI,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAI,MAAM,CAAC;CAC/B;AAGD,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAE7D,SAAkB,WAAW,sEACyC;IAEtE,SAAkB,UAAU,cAAe;IAC3C,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAE3D,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,cAAc;CAMtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAU1E,MAAM,OAAO,mBAAoB,SAAQ,cAAsB;IAE3C,WAAW,GACzB,kEAAkE,CAAA;IAEpD,UAAU,GAAK,UAAU,CAAA;IACzB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAE3D,KAAK,CAAC,MAAyB,EAAE,IAAoB;
|
|
1
|
+
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAU1E,MAAM,OAAO,mBAAoB,SAAQ,cAAsB;IAE3C,WAAW,GACzB,kEAAkE,CAAA;IAEpD,UAAU,GAAK,UAAU,CAAA;IACzB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAE3D,KAAK,CAAC,MAAyB,EAAE,IAAoB;QAInD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -8,8 +8,7 @@ export class LabelIncantation extends ArgIncantation {
|
|
|
8
8
|
apply(target, data) {
|
|
9
9
|
super.require_expr_type(target.type, "expression");
|
|
10
10
|
target.label = data.text;
|
|
11
|
-
|
|
12
|
-
target.showLabel = data.show;
|
|
11
|
+
target.showLabel = data.show ?? true;
|
|
13
12
|
if (data.size != undefined)
|
|
14
13
|
target.labelSize = data.size;
|
|
15
14
|
if (data.pos != undefined)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../../src/magic/local/label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAYzE,MAAM,OAAO,gBAAiB,SAAQ,cAAqB;IAEvC,WAAW,GACzB,6CAA6C,CAAA;IAE/B,UAAU,GAAK,OAAO,CAAA;IACtB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CAAC,MAA8B,EAAE,IAAkB;QAE/D,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;QACzB,
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../../src/magic/local/label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;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,CAAC;oBACd,MAAM;gBAER;oBACE,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAC1C,mCAAmC,GAAG,EAAE,CACzC,CAAC;YACN,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GenericParser } from "./generic-parser.js";
|
|
2
2
|
import { Ast } from "./ast.js";
|
|
3
3
|
import type { DesmostOptions } from "../compiler/index.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { NoMatch, Unrecoverable } from "../errors.js";
|
|
5
5
|
import { Incantation } from "../magic/index.js";
|
|
6
6
|
import type { GLOBAL, LOCAL } from "../magic/index.js";
|
|
7
7
|
export declare class DesmostParser extends GenericParser {
|
|
@@ -17,10 +17,10 @@ export declare class DesmostParser extends GenericParser {
|
|
|
17
17
|
parse_post_sep(): Unrecoverable<Ast.Expression>;
|
|
18
18
|
parse_comment(): Unrecoverable<Ast.Expression>;
|
|
19
19
|
parse_line(): Unrecoverable<string>;
|
|
20
|
-
try_parse_global_incantation(): Ast.IncantationInvocation<GLOBAL> | Ast.InvalidInvocation |
|
|
21
|
-
try_parse_local_incantation(): Ast.IncantationInvocation<LOCAL> | Ast.InvalidInvocation |
|
|
22
|
-
try_parse_expr_incantation():
|
|
23
|
-
try_parse_identifier<Effect extends Incantation.Effect>(incantations: Incantation<Effect>[]): Incantation<Effect> |
|
|
20
|
+
try_parse_global_incantation(): Ast.IncantationInvocation<GLOBAL> | Ast.InvalidInvocation | NoMatch;
|
|
21
|
+
try_parse_local_incantation(): Ast.IncantationInvocation<LOCAL> | Ast.InvalidInvocation | NoMatch;
|
|
22
|
+
try_parse_expr_incantation(): Unrecoverable<Ast.Expression | NoMatch>;
|
|
23
|
+
try_parse_identifier<Effect extends Incantation.Effect>(incantations: Incantation<Effect>[]): Incantation<Effect> | NoMatch;
|
|
24
24
|
parse_incantation_arg(arg_type: Incantation.ArgType): Unrecoverable<string>;
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=desmost-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desmost-parser.d.ts","sourceRoot":"","sources":["../../src/parser/desmost-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"desmost-parser.d.ts","sourceRoot":"","sources":["../../src/parser/desmost-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGxD,OAAO,EACL,WAAW,EAEZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAQ,MAAM,UAAU,CAAC;AAMpD,qBAAa,aAAc,SAAQ,aAAa;IAElB,SAAS,CAAC,OAAO,CAAC,EAAE,cAAc;gBAAlD,MAAM,EAAE,MAAM,EAAY,OAAO,CAAC,EAAE,cAAc,YAAA;IAWvD,UAAU,IAAI,GAAG,GAAG,IAAI;IAwD/B,aAAa,IACX,aAAa,CACX;QAAE,MAAM,EAAE,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,iBAAiB,CAAA;KAAE,GACrE;QAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAA;KAAE,CAC3E;IA4BH,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC;IAehC,cAAc,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC;IA6B/C,aAAa,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC;IAkB9C,UAAU,IAAI,aAAa,CAAC,MAAM,CAAC;IAcnC,4BAA4B,IACxB,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,GACjC,GAAG,CAAC,iBAAiB,GACrB,OAAO;IA0CX,2BAA2B,IACvB,GAAG,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAChC,GAAG,CAAC,iBAAiB,GACrB,OAAO;IAuCX,0BAA0B,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,GAAG,OAAO,CAAC;IA4BrE,oBAAoB,CAAC,MAAM,SAAS,WAAW,CAAC,MAAM,EACpD,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,GAClC,WAAW,CAAC,MAAM,CAAC,GAAG,OAAO;IAuEhC,qBAAqB,CASnB,QAAQ,EAAE,WAAW,CAAC,OAAO,GAC5B,aAAa,CAAC,MAAM,CAAC;CAyFzB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GenericParser } from "./generic-parser.js";
|
|
2
2
|
import { Ast } from "./ast.js";
|
|
3
|
-
import {
|
|
3
|
+
import { NO_MATCH, UnrecoverableError } from "../errors.js";
|
|
4
4
|
import * as utils from "../utils.js";
|
|
5
5
|
import { Incantation, ArgIncantation, GLOBAL_INCANTATIONS, LOCAL_INCANTATIONS, EXPR_INCANTATIONS } from "../magic/index.js";
|
|
6
6
|
export class DesmostParser extends GenericParser {
|
|
@@ -46,14 +46,14 @@ export class DesmostParser extends GenericParser {
|
|
|
46
46
|
}
|
|
47
47
|
parse_pre_sep() {
|
|
48
48
|
let r = this.try_parse_global_incantation();
|
|
49
|
-
if (r !==
|
|
49
|
+
if (r !== NO_MATCH) {
|
|
50
50
|
this.consume_end_of_block(`Received excess input after global incantation /${r.incantation.identifier}`);
|
|
51
51
|
return { global: r };
|
|
52
52
|
}
|
|
53
53
|
let incantations = [];
|
|
54
54
|
while (this.current === "/") {
|
|
55
55
|
let invocation = this.try_parse_local_incantation();
|
|
56
|
-
if (invocation ===
|
|
56
|
+
if (invocation === NO_MATCH)
|
|
57
57
|
break;
|
|
58
58
|
incantations.push(invocation);
|
|
59
59
|
}
|
|
@@ -75,7 +75,7 @@ export class DesmostParser extends GenericParser {
|
|
|
75
75
|
};
|
|
76
76
|
case "/":
|
|
77
77
|
let incantation = this.try_parse_expr_incantation();
|
|
78
|
-
if (incantation !==
|
|
78
|
+
if (incantation !== NO_MATCH)
|
|
79
79
|
return incantation;
|
|
80
80
|
default:
|
|
81
81
|
return {
|
|
@@ -103,12 +103,12 @@ export class DesmostParser extends GenericParser {
|
|
|
103
103
|
}
|
|
104
104
|
try_parse_global_incantation() {
|
|
105
105
|
let init = this.i;
|
|
106
|
-
if (this.try_consume("/") ===
|
|
107
|
-
return
|
|
106
|
+
if (this.try_consume("/") === NO_MATCH)
|
|
107
|
+
return NO_MATCH;
|
|
108
108
|
let incantation = this.try_parse_identifier(GLOBAL_INCANTATIONS);
|
|
109
|
-
if (incantation ===
|
|
109
|
+
if (incantation === NO_MATCH) {
|
|
110
110
|
this.i = init;
|
|
111
|
-
return
|
|
111
|
+
return NO_MATCH;
|
|
112
112
|
}
|
|
113
113
|
let data = undefined;
|
|
114
114
|
if (incantation instanceof ArgIncantation) {
|
|
@@ -132,12 +132,12 @@ export class DesmostParser extends GenericParser {
|
|
|
132
132
|
}
|
|
133
133
|
try_parse_local_incantation() {
|
|
134
134
|
let init = this.i;
|
|
135
|
-
if (this.try_consume("/") ===
|
|
136
|
-
return
|
|
135
|
+
if (this.try_consume("/") === NO_MATCH)
|
|
136
|
+
return NO_MATCH;
|
|
137
137
|
let incantation = this.try_parse_identifier(LOCAL_INCANTATIONS);
|
|
138
|
-
if (incantation ===
|
|
138
|
+
if (incantation === NO_MATCH) {
|
|
139
139
|
this.i = init;
|
|
140
|
-
return
|
|
140
|
+
return NO_MATCH;
|
|
141
141
|
}
|
|
142
142
|
let arg_raw = undefined;
|
|
143
143
|
if (incantation instanceof ArgIncantation) {
|
|
@@ -161,12 +161,12 @@ export class DesmostParser extends GenericParser {
|
|
|
161
161
|
}
|
|
162
162
|
try_parse_expr_incantation() {
|
|
163
163
|
let init = this.i;
|
|
164
|
-
if (this.try_consume("/") ===
|
|
165
|
-
return
|
|
164
|
+
if (this.try_consume("/") === NO_MATCH)
|
|
165
|
+
return NO_MATCH;
|
|
166
166
|
let incantation = this.try_parse_identifier(EXPR_INCANTATIONS);
|
|
167
|
-
if (incantation ===
|
|
167
|
+
if (incantation === NO_MATCH) {
|
|
168
168
|
this.i = init;
|
|
169
|
-
return
|
|
169
|
+
return NO_MATCH;
|
|
170
170
|
}
|
|
171
171
|
let arg_raw = this.parse_incantation_arg(incantation.arg_type);
|
|
172
172
|
let data = {};
|
|
@@ -180,15 +180,15 @@ export class DesmostParser extends GenericParser {
|
|
|
180
180
|
try_parse_identifier(incantations) {
|
|
181
181
|
for (let incantation of incantations) {
|
|
182
182
|
let r = this.try_consume(incantation.identifier);
|
|
183
|
-
if (r !==
|
|
183
|
+
if (r !== NO_MATCH)
|
|
184
184
|
return incantation;
|
|
185
185
|
if (incantation.alias != undefined) {
|
|
186
186
|
let r = this.try_consume(incantation.alias);
|
|
187
|
-
if (r !==
|
|
187
|
+
if (r !== NO_MATCH)
|
|
188
188
|
return incantation;
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
return
|
|
191
|
+
return NO_MATCH;
|
|
192
192
|
}
|
|
193
193
|
parse_incantation_arg(arg_type) {
|
|
194
194
|
let init = this.i;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desmost-parser.js","sourceRoot":"","sources":["../../src/parser/desmost-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,OAA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AAC,EANI,IAAI,KAAJ,IAAI,QAMR;AAED,IAAK,GAQJ;AARD,WAAK,GAAG;IACN,kBAAY,CAAA;IACZ,kBAAY,CAAA;IACZ,8BAAyB,CAAA;IACzB,kBAAqB,CAAA;IACrB,mBAAqB,CAAA;IACrB,kBAAsB,CAAA;IACtB,oBAAuB,CAAA;AACzB,CAAC,EARI,GAAG,KAAH,GAAG,QAQP"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NoMatch, Unrecoverable } from "../errors.js";
|
|
2
2
|
export declare class GenericParser {
|
|
3
3
|
#private;
|
|
4
4
|
protected source: string;
|
|
@@ -10,9 +10,9 @@ export declare class GenericParser {
|
|
|
10
10
|
protected next(): string | undefined;
|
|
11
11
|
preview(idx?: number): string;
|
|
12
12
|
protected advance(error_msg?: string): Unrecoverable<void>;
|
|
13
|
-
protected try_advance(): void |
|
|
13
|
+
protected try_advance(): void | NoMatch;
|
|
14
14
|
protected consume(raw: string, error_msg?: string): Unrecoverable<void>;
|
|
15
|
-
protected try_consume(raw: string): void |
|
|
15
|
+
protected try_consume(raw: string): void | NoMatch;
|
|
16
16
|
protected consume_spaces(): void;
|
|
17
17
|
protected consume_whitespace(): void;
|
|
18
18
|
protected consume_end_of_block(error_msg?: string): Unrecoverable<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic-parser.d.ts","sourceRoot":"","sources":["../../src/parser/generic-parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"generic-parser.d.ts","sourceRoot":"","sources":["../../src/parser/generic-parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAaxD,qBAAa,aAAa;;IAGxB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAGzB,SAAS,CAAC,CAAC,EAAE,MAAM,CAAK;IAGxB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAIb,MAAM,EAAE,MAAM;IAU1B,SAAS,CAAC,aAAa,IAAI,OAAO;IAQlC,SAAS,KAAK,OAAO,IAAI,MAAM,GAAG,SAAS,CAG1C;IAKD,SAAS,CAAC,IAAI,IAAI,MAAM,GAAG,SAAS;IAU7B,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM;IAWpC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC;IAc1D,SAAS,CAAC,WAAW,IAAI,IAAI,GAAG,OAAO;IAmBvC,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC;IA4BvE,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO;IAqBlD,SAAS,CAAC,cAAc,IAAI,IAAI;IAehC,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAUpC,SAAS,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC;CAUxE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_MATCH, UnrecoverableError } from "../errors.js";
|
|
2
2
|
const IGNORED_CHARACTERS = new Set([
|
|
3
3
|
"\r",
|
|
4
4
|
]);
|
|
@@ -31,7 +31,7 @@ export class GenericParser {
|
|
|
31
31
|
}
|
|
32
32
|
try_advance() {
|
|
33
33
|
if (this.out_of_bounds())
|
|
34
|
-
return
|
|
34
|
+
return NO_MATCH;
|
|
35
35
|
this.#advance();
|
|
36
36
|
}
|
|
37
37
|
#advance() {
|
|
@@ -59,8 +59,8 @@ export class GenericParser {
|
|
|
59
59
|
let ii = 0;
|
|
60
60
|
while (this.current === raw[ii]) {
|
|
61
61
|
let r = this.try_advance();
|
|
62
|
-
if (r ===
|
|
63
|
-
return
|
|
62
|
+
if (r === NO_MATCH)
|
|
63
|
+
return NO_MATCH;
|
|
64
64
|
ii++;
|
|
65
65
|
if (ii === raw.length)
|
|
66
66
|
return;
|
|
@@ -68,7 +68,7 @@ export class GenericParser {
|
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
this.i = init;
|
|
71
|
-
return
|
|
71
|
+
return NO_MATCH;
|
|
72
72
|
}
|
|
73
73
|
consume_spaces() {
|
|
74
74
|
if (this.out_of_bounds())
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic-parser.js","sourceRoot":"","sources":["../../src/parser/generic-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"generic-parser.js","sourceRoot":"","sources":["../../src/parser/generic-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAIzD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,IAAI;CACL,CAAC,CAAC;AAQH,MAAM,OAAO,aAAa;IAGd,MAAM,CAAS;IAGf,CAAC,GAAW,CAAC,CAAC;IAGd,MAAM,CAAS;IAIzB,YAAY,MAAc;QAExB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAMS,aAAa;QAErB,OAAO,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC;IAC/B,CAAC;IAKD,IAAc,OAAO;QAEnB,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAKS,IAAI;QAEZ,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACpC,CAAC;IAOM,OAAO,CAAC,GAAY;QAEzB,GAAG,KAAK,IAAI,CAA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O,EAAE,IAAI,CACvE,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/compiler/compile.ts
CHANGED
|
@@ -2,7 +2,15 @@ import { type DesmostOptions, fill_defaults } from "./options";
|
|
|
2
2
|
import { evaluate_global_incantation, evaluate_expr, evaluate_error } from "./evaluate";
|
|
3
3
|
|
|
4
4
|
import { DesmostParser, Ast } from "../parser";
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/** Debug diagnostics returned from `compile()`. */
|
|
8
|
+
export interface DesmostDebug
|
|
9
|
+
{
|
|
10
|
+
duration: number;
|
|
11
|
+
num_blocks: number;
|
|
12
|
+
ast: Ast[];
|
|
13
|
+
}
|
|
6
14
|
|
|
7
15
|
|
|
8
16
|
/**
|
|
@@ -43,31 +51,42 @@ export function compile(
|
|
|
43
51
|
return;
|
|
44
52
|
}
|
|
45
53
|
|
|
46
|
-
let t_init = performance.now();
|
|
47
|
-
let num_blocks = 0;
|
|
48
|
-
let ast = [];
|
|
49
|
-
|
|
50
54
|
let opts = fill_defaults(options);
|
|
55
|
+
|
|
56
|
+
if (opts.debug) {
|
|
57
|
+
var t_init = performance.now();
|
|
58
|
+
var num_blocks = 0;
|
|
59
|
+
var ast: Ast[] = [];
|
|
60
|
+
}
|
|
61
|
+
|
|
51
62
|
let parser = new DesmostParser(source, opts);
|
|
63
|
+
|
|
64
|
+
let errors: string[] = [];
|
|
52
65
|
|
|
53
66
|
/* To aggregate errors at the start, we need a target to retroactively inject errors into */
|
|
54
67
|
if (opts.place_errors === "start") {
|
|
55
|
-
desmos.setExpression({ id: "deferred-start", latex: "" });
|
|
68
|
+
desmos.setExpression({ id: "deferred-start", latex: " " }); // FIXME check if ` ` needed
|
|
56
69
|
}
|
|
57
70
|
|
|
58
|
-
|
|
71
|
+
/* Keep track of whether we're still evaluating leading blank expressions, which might be ignored. */
|
|
72
|
+
let seen_non_blank = false;
|
|
73
|
+
|
|
74
|
+
/** The number of pending blank expressions to add. */
|
|
75
|
+
let pending_blanks: number = 0;
|
|
59
76
|
|
|
60
|
-
/*
|
|
77
|
+
/* The compiler is lazy, parsing and evaluating one block at a time (as opposed to first parsing the entire AST). We don't need the whole AST, so this saves memory. */
|
|
78
|
+
/* NOTE: It also doesn't sacrifice performance, since `.setExpressions()` internally just calls `.setExpression()` in a loop anyway. Benchmarks in the frontend produce similar times for both, so there's no performance improvement. */
|
|
61
79
|
try {
|
|
62
80
|
while (true) {
|
|
63
81
|
let r = parser.parse_next();
|
|
64
82
|
if (r === null) break;
|
|
65
83
|
|
|
66
84
|
if (opts.debug) {
|
|
67
|
-
num_blocks
|
|
68
|
-
ast
|
|
85
|
+
num_blocks!++;
|
|
86
|
+
ast!.push(r);
|
|
69
87
|
}
|
|
70
88
|
|
|
89
|
+
/** An error message to leave for aggregation later. */
|
|
71
90
|
let defer: string | void = undefined;
|
|
72
91
|
|
|
73
92
|
switch (r.kind) {
|
|
@@ -77,9 +96,20 @@ export function compile(
|
|
|
77
96
|
|
|
78
97
|
case Ast.Kind.EXPRESSION:
|
|
79
98
|
// @ts-expect-error: outdated types
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
99
|
+
if (r.data.latex === " ") {
|
|
100
|
+
if (opts.ignore_all_blanks) break;
|
|
101
|
+
if (!seen_non_blank && !opts.keep_leading_blanks) break;
|
|
102
|
+
pending_blanks++;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
flush_pending_blanks(desmos, pending_blanks);
|
|
107
|
+
pending_blanks = 0;
|
|
108
|
+
|
|
109
|
+
seen_non_blank = true;
|
|
110
|
+
defer = evaluate_expr(r, desmos, opts);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
83
113
|
|
|
84
114
|
case Ast.Kind.INVALID_INCANTATION:
|
|
85
115
|
defer = evaluate_error(r.error, desmos, opts);
|
|
@@ -92,11 +122,11 @@ export function compile(
|
|
|
92
122
|
}
|
|
93
123
|
}
|
|
94
124
|
catch (e) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
125
|
+
errors.push((e as Error).message);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (opts.keep_trailing_blanks) {
|
|
129
|
+
flush_pending_blanks(desmos, pending_blanks);
|
|
100
130
|
}
|
|
101
131
|
|
|
102
132
|
if (errors.length > 0) {
|
|
@@ -118,17 +148,17 @@ export function compile(
|
|
|
118
148
|
|
|
119
149
|
if (opts.debug) {
|
|
120
150
|
return {
|
|
121
|
-
duration: performance.now() - t_init
|
|
122
|
-
num_blocks
|
|
123
|
-
ast
|
|
151
|
+
duration: performance.now() - t_init!,
|
|
152
|
+
num_blocks: num_blocks!,
|
|
153
|
+
ast: ast!,
|
|
124
154
|
};
|
|
125
155
|
}
|
|
126
156
|
}
|
|
127
157
|
|
|
128
158
|
|
|
129
|
-
|
|
159
|
+
function flush_pending_blanks(desmos: Desmos.Calculator, count: number)
|
|
130
160
|
{
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
161
|
+
for (let i = 0; i < count; i++) {
|
|
162
|
+
desmos.setExpression({ latex: ` ` });
|
|
163
|
+
}
|
|
134
164
|
}
|
package/src/compiler/evaluate.ts
CHANGED
|
@@ -141,15 +141,11 @@ function normalise_latex(latex: string): string
|
|
|
141
141
|
*/
|
|
142
142
|
function prettify_latex(latex: string): string
|
|
143
143
|
{
|
|
144
|
-
latex = latex.replaceAll(/(?<!\\left)\(/g, "\\left
|
|
145
|
-
latex = latex.replaceAll(/(?<!\\right)\)/g, "\\right
|
|
146
|
-
latex = latex.replaceAll(/(?<!\\left)\[/g, "\\left[");
|
|
147
|
-
latex = latex.replaceAll(/(?<!\\right)\]/g, "\\right]");
|
|
148
|
-
latex = latex.replaceAll("\\{", "\\left\\{");
|
|
149
|
-
latex = latex.replaceAll("\\}", "\\right\\}");
|
|
144
|
+
latex = latex.replaceAll(/(?<!\\left)(\(|\[|\\\{)/g, "\\left$1");
|
|
145
|
+
latex = latex.replaceAll(/(?<!\\right)(\)|\]|\\\})/g, "\\right$1");
|
|
150
146
|
|
|
151
147
|
latex = latex.replaceAll(
|
|
152
|
-
/(?<=[^\w]|^)\\?(mean|median|count|total|repeat|join|sort|shuffle|unique|mod|ceil|floor|round|sign)(?=\(|\\left\()/g,
|
|
148
|
+
/(?<=[^\w]|^)\\?(mean|median|count|total|repeat|join|sort|shuffle|unique|mod|ceil|floor|round|sign) ?(?=\(|\\left\()/g,
|
|
153
149
|
"\\operatorname{$1}"
|
|
154
150
|
);
|
|
155
151
|
|
package/src/compiler/options.ts
CHANGED
|
@@ -37,7 +37,14 @@ export interface DesmostOptions
|
|
|
37
37
|
error_prefix?: string
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Prettify LaTeX output so it renders nicely in the Desmos editor?
|
|
41
|
+
*
|
|
42
|
+
* Defaults to `true`, meaning LaTeX is prettified.
|
|
43
|
+
*/
|
|
44
|
+
prettify?: boolean
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Should `%` LaTeX comments be ignored, instead of turned into text expressions (notes)?
|
|
41
48
|
*
|
|
42
49
|
* Defaults to `false`, meaning comments are kept.
|
|
43
50
|
*/
|
|
@@ -48,26 +55,26 @@ export interface DesmostOptions
|
|
|
48
55
|
*
|
|
49
56
|
* Defaults to `false`, meaning all blank lines are kept.
|
|
50
57
|
*/
|
|
51
|
-
|
|
58
|
+
ignore_all_blanks?: boolean
|
|
52
59
|
|
|
53
60
|
/**
|
|
54
|
-
* Should trailing blank lines at the
|
|
61
|
+
* Should trailing blank lines at the start of the source be kept as blank expressions?
|
|
55
62
|
*
|
|
56
|
-
* Defaults to `false`, meaning
|
|
63
|
+
* Defaults to `false`, meaning leading blank lines are ignored.
|
|
57
64
|
*/
|
|
58
|
-
|
|
65
|
+
keep_leading_blanks?: boolean
|
|
59
66
|
|
|
60
67
|
/**
|
|
61
|
-
*
|
|
68
|
+
* Should trailing blank lines at the end of the source be kept as blank expressions?
|
|
62
69
|
*
|
|
63
|
-
* Defaults to `
|
|
70
|
+
* Defaults to `false`, meaning trailing blank lines are ignored.
|
|
64
71
|
*/
|
|
65
|
-
|
|
72
|
+
keep_trailing_blanks?: boolean
|
|
66
73
|
|
|
67
74
|
/**
|
|
68
75
|
* Return debug diagnostics?
|
|
69
76
|
*
|
|
70
|
-
* This includes the unevaluated AST
|
|
77
|
+
* This includes the unevaluated AST and performance diagnostics.
|
|
71
78
|
*
|
|
72
79
|
* Defaults to `false`, meaning `compile()` returns `void`.
|
|
73
80
|
*/
|
|
@@ -85,12 +92,13 @@ export function fill_defaults(options: Partial<DesmostOptions> | undefined): Req
|
|
|
85
92
|
out.errors ??= "surface";
|
|
86
93
|
out.place_errors ??= "inline";
|
|
87
94
|
out.error_prefix ??= "[DESMOST ERROR]\n";
|
|
88
|
-
|
|
89
|
-
out.ignore_comments ??= false;
|
|
90
|
-
out.ignore_blank_lines ??= false;
|
|
91
|
-
out.ignore_trailing_blanks ??= false;
|
|
92
95
|
|
|
93
96
|
out.prettify ??= true;
|
|
97
|
+
|
|
98
|
+
out.ignore_comments ??= false;
|
|
99
|
+
out.ignore_all_blanks ??= false;
|
|
100
|
+
out.keep_leading_blanks ??= false;
|
|
101
|
+
out.keep_trailing_blanks ??= false;
|
|
94
102
|
out.debug ??= false;
|
|
95
103
|
|
|
96
104
|
return out as Required<DesmostOptions>;
|
package/src/errors.ts
CHANGED
|
@@ -28,19 +28,12 @@ export namespace UnrecoverableError
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
/** The
|
|
32
|
-
export const
|
|
31
|
+
/** The parser failed to parse something (usually during speculative parsing), which only results in internal backtracking. */
|
|
32
|
+
export const NO_MATCH = Symbol("no-match");
|
|
33
33
|
|
|
34
34
|
/** The compiler encountered a non-fatal recoverable failure (usually during speculative parsing), which only results in internal backtracking. */
|
|
35
|
-
export type
|
|
35
|
+
export type NoMatch = typeof NO_MATCH & { readonly __brand?: unique symbol };
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
/** Indicates that a function may throw an `UnrecoverableError`. */
|
|
39
39
|
export type Unrecoverable<Result> = Result | Result & { readonly __brand?: unique symbol };
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Indicates that a function may either return a `RecoverableFail` *or* throw an `UnrecoverableError`.
|
|
43
|
-
*
|
|
44
|
-
* This is used in potentially ambiguous cases. For instance, the user might have invoked an unknown incantation, in which case we might want to `RecoverableFail` and fallback to parsing it as LaTeX; on the other hand, if they invoked a valid incantation, but did not supply the required argument, that's a definite `UnrecoverableError`.
|
|
45
|
-
*/
|
|
46
|
-
export type MaybeRecoverable<Result> = RecoverableFail | Unrecoverable<Result>;
|
package/src/magic/expr/text.ts
CHANGED
|
@@ -7,6 +7,7 @@ export class TextIncantation extends ArgIncantation<EXPR>
|
|
|
7
7
|
= "Produce a text expression (“Add Note” in the Desmos GUI)."
|
|
8
8
|
|
|
9
9
|
override readonly identifier = "text"
|
|
10
|
+
override readonly alias = "note"
|
|
10
11
|
override readonly requires_arg = true
|
|
11
12
|
override readonly arg_type = Incantation.ArgType.STRING
|
|
12
13
|
|
package/src/magic/local/label.ts
CHANGED
|
@@ -24,7 +24,7 @@ export class LabelIncantation extends ArgIncantation<LOCAL>
|
|
|
24
24
|
{
|
|
25
25
|
super.require_expr_type(target.type, "expression");
|
|
26
26
|
target.label = data.text;
|
|
27
|
-
|
|
27
|
+
target.showLabel = data.show ?? true;
|
|
28
28
|
// @ts-expect-error: outdated types TODO check
|
|
29
29
|
if (data.size != undefined) target.labelSize = data.size;
|
|
30
30
|
if (data.pos != undefined) target.labelOrientation = data.pos;
|
|
@@ -2,8 +2,8 @@ import { GenericParser } from "./generic-parser";
|
|
|
2
2
|
import { Ast } from "./ast";
|
|
3
3
|
|
|
4
4
|
import type { DesmostOptions } from "../compiler";
|
|
5
|
-
import {
|
|
6
|
-
import type {
|
|
5
|
+
import { NO_MATCH, UnrecoverableError } from "../errors";
|
|
6
|
+
import type { NoMatch, Unrecoverable } from "../errors";
|
|
7
7
|
import * as utils from "../utils";
|
|
8
8
|
|
|
9
9
|
import {
|
|
@@ -87,18 +87,14 @@ export class DesmostParser extends GenericParser
|
|
|
87
87
|
*/
|
|
88
88
|
parse_pre_sep():
|
|
89
89
|
Unrecoverable<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
| { local: Array<Ast.IncantationInvocation<LOCAL>
|
|
94
|
-
| Ast.InvalidInvocation>;
|
|
95
|
-
}
|
|
90
|
+
| { global: Ast.IncantationInvocation<GLOBAL> | Ast.InvalidInvocation }
|
|
91
|
+
| { local: Array<Ast.IncantationInvocation<LOCAL> | Ast.InvalidInvocation> }
|
|
96
92
|
>
|
|
97
93
|
{
|
|
98
94
|
// 1 global incantation
|
|
99
95
|
let r = this.try_parse_global_incantation();
|
|
100
96
|
|
|
101
|
-
if (r !==
|
|
97
|
+
if (r !== NO_MATCH) {
|
|
102
98
|
this.consume_end_of_block(
|
|
103
99
|
`Received excess input after global incantation /${r.incantation.identifier}`
|
|
104
100
|
);
|
|
@@ -111,7 +107,7 @@ export class DesmostParser extends GenericParser
|
|
|
111
107
|
|
|
112
108
|
while (this.current === "/") {
|
|
113
109
|
let invocation = this.try_parse_local_incantation();
|
|
114
|
-
if (invocation ===
|
|
110
|
+
if (invocation === NO_MATCH) break;
|
|
115
111
|
incantations.push(invocation);
|
|
116
112
|
}
|
|
117
113
|
|
|
@@ -152,7 +148,7 @@ export class DesmostParser extends GenericParser
|
|
|
152
148
|
// expr incantation
|
|
153
149
|
case "/":
|
|
154
150
|
let incantation = this.try_parse_expr_incantation();
|
|
155
|
-
if (incantation !==
|
|
151
|
+
if (incantation !== NO_MATCH) return incantation;
|
|
156
152
|
// FALLTHROUGH: to fallback on plain LaTeX
|
|
157
153
|
|
|
158
154
|
// plain LaTeX
|
|
@@ -200,16 +196,16 @@ export class DesmostParser extends GenericParser
|
|
|
200
196
|
try_parse_global_incantation():
|
|
201
197
|
| Ast.IncantationInvocation<GLOBAL>
|
|
202
198
|
| Ast.InvalidInvocation
|
|
203
|
-
|
|
|
199
|
+
| NoMatch
|
|
204
200
|
{
|
|
205
201
|
let init = this.i;
|
|
206
202
|
|
|
207
|
-
if (this.try_consume("/") ===
|
|
203
|
+
if (this.try_consume("/") === NO_MATCH) return NO_MATCH;
|
|
208
204
|
|
|
209
205
|
let incantation = this.try_parse_identifier(GLOBAL_INCANTATIONS);
|
|
210
|
-
if (incantation ===
|
|
206
|
+
if (incantation === NO_MATCH) {
|
|
211
207
|
this.i = init;
|
|
212
|
-
return
|
|
208
|
+
return NO_MATCH;
|
|
213
209
|
}
|
|
214
210
|
|
|
215
211
|
let data = undefined;
|
|
@@ -245,16 +241,16 @@ export class DesmostParser extends GenericParser
|
|
|
245
241
|
try_parse_local_incantation():
|
|
246
242
|
| Ast.IncantationInvocation<LOCAL>
|
|
247
243
|
| Ast.InvalidInvocation
|
|
248
|
-
|
|
|
244
|
+
| NoMatch
|
|
249
245
|
{
|
|
250
246
|
let init = this.i;
|
|
251
247
|
|
|
252
|
-
if (this.try_consume("/") ===
|
|
248
|
+
if (this.try_consume("/") === NO_MATCH) return NO_MATCH;
|
|
253
249
|
|
|
254
250
|
let incantation = this.try_parse_identifier(LOCAL_INCANTATIONS);
|
|
255
|
-
if (incantation ===
|
|
251
|
+
if (incantation === NO_MATCH) {
|
|
256
252
|
this.i = init;
|
|
257
|
-
return
|
|
253
|
+
return NO_MATCH;
|
|
258
254
|
}
|
|
259
255
|
|
|
260
256
|
let arg_raw = undefined;
|
|
@@ -284,17 +280,17 @@ export class DesmostParser extends GenericParser
|
|
|
284
280
|
};
|
|
285
281
|
}
|
|
286
282
|
|
|
287
|
-
try_parse_expr_incantation():
|
|
283
|
+
try_parse_expr_incantation(): Unrecoverable<Ast.Expression | NoMatch>
|
|
288
284
|
{
|
|
289
285
|
let init = this.i;
|
|
290
286
|
|
|
291
|
-
if (this.try_consume("/") ===
|
|
287
|
+
if (this.try_consume("/") === NO_MATCH) return NO_MATCH;
|
|
292
288
|
|
|
293
289
|
let incantation = this.try_parse_identifier(EXPR_INCANTATIONS);
|
|
294
|
-
if (incantation ===
|
|
290
|
+
if (incantation === NO_MATCH) {
|
|
295
291
|
// TODO maybe flag to user
|
|
296
292
|
this.i = init;
|
|
297
|
-
return
|
|
293
|
+
return NO_MATCH;
|
|
298
294
|
}
|
|
299
295
|
|
|
300
296
|
let arg_raw = this.parse_incantation_arg((incantation as ArgIncantation<EXPR>).arg_type);
|
|
@@ -314,20 +310,20 @@ export class DesmostParser extends GenericParser
|
|
|
314
310
|
*/
|
|
315
311
|
try_parse_identifier<Effect extends Incantation.Effect>(
|
|
316
312
|
incantations: Incantation<Effect>[]
|
|
317
|
-
): Incantation<Effect> |
|
|
313
|
+
): Incantation<Effect> | NoMatch
|
|
318
314
|
{
|
|
319
315
|
for (let incantation of incantations) {
|
|
320
316
|
// yeah the duplication here is a little meh, unfortunately needing `return` means we can't extract it into a helper
|
|
321
317
|
let r = this.try_consume(incantation.identifier);
|
|
322
|
-
if (r !==
|
|
318
|
+
if (r !== NO_MATCH) return incantation;
|
|
323
319
|
|
|
324
320
|
if (incantation.alias != undefined) {
|
|
325
321
|
let r = this.try_consume(incantation.alias);
|
|
326
|
-
if (r !==
|
|
322
|
+
if (r !== NO_MATCH) return incantation;
|
|
327
323
|
}
|
|
328
324
|
}
|
|
329
325
|
|
|
330
|
-
return
|
|
326
|
+
return NO_MATCH;
|
|
331
327
|
}
|
|
332
328
|
|
|
333
329
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import { NO_MATCH, UnrecoverableError } from "../errors";
|
|
2
|
+
import type { NoMatch, Unrecoverable } from "../errors";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const IGNORED_CHARACTERS = new Set([
|
|
@@ -10,7 +10,7 @@ const IGNORED_CHARACTERS = new Set([
|
|
|
10
10
|
/**
|
|
11
11
|
* A stateful lazy parser, providing core (non-Desmost-specific) methods for parsing.
|
|
12
12
|
*
|
|
13
|
-
* Many methods come in `<verb>` and `try_<verb>` pairs. On parsing failure, the former throws an `UnrecoverableError`, but the latter instead backtracks and only returns a `
|
|
13
|
+
* Many methods come in `<verb>` and `try_<verb>` pairs. On parsing failure, the former throws an `UnrecoverableError`, but the latter instead backtracks and only returns a `NoMatch`. The former is for expected parses, while the latter is for speculative parsing.
|
|
14
14
|
*/
|
|
15
15
|
export class GenericParser
|
|
16
16
|
{
|
|
@@ -86,9 +86,9 @@ export class GenericParser
|
|
|
86
86
|
*
|
|
87
87
|
* Fails if the parser is the out-of-bounds *before* advancing.
|
|
88
88
|
*/
|
|
89
|
-
protected try_advance(): void |
|
|
89
|
+
protected try_advance(): void | NoMatch
|
|
90
90
|
{
|
|
91
|
-
if (this.out_of_bounds()) return
|
|
91
|
+
if (this.out_of_bounds()) return NO_MATCH;
|
|
92
92
|
this.#advance();
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -133,14 +133,14 @@ export class GenericParser
|
|
|
133
133
|
/**
|
|
134
134
|
* Attempt to consume `raw`, backtracking if `raw` was not found.
|
|
135
135
|
*/
|
|
136
|
-
protected try_consume(raw: string): void |
|
|
136
|
+
protected try_consume(raw: string): void | NoMatch
|
|
137
137
|
{
|
|
138
138
|
let init = this.i;
|
|
139
139
|
let ii = 0;
|
|
140
140
|
|
|
141
141
|
while (this.current === raw[ii]) {
|
|
142
142
|
let r = this.try_advance();
|
|
143
|
-
if (r ===
|
|
143
|
+
if (r === NO_MATCH) return NO_MATCH;
|
|
144
144
|
|
|
145
145
|
ii++;
|
|
146
146
|
if (ii === raw.length) return;
|
|
@@ -148,7 +148,7 @@ export class GenericParser
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
this.i = init;
|
|
151
|
-
return
|
|
151
|
+
return NO_MATCH;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
/**
|