desmost 0.1.0 → 0.1.2
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/LICENCE +21 -0
- package/dist/compiler/compile.d.ts +3 -26
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/compile.js +5 -29
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/evaluate.d.ts +3 -14
- package/dist/compiler/evaluate.d.ts.map +1 -1
- package/dist/compiler/evaluate.js +2 -14
- package/dist/compiler/evaluate.js.map +1 -1
- package/dist/compiler/index.d.ts +2 -2
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/options.d.ts +0 -43
- package/dist/compiler/options.d.ts.map +1 -1
- package/dist/compiler/options.js +0 -3
- package/dist/compiler/options.js.map +1 -1
- package/dist/desmos.d.ts +0 -3
- package/dist/desmos.d.ts.map +1 -1
- package/dist/desmos.js +0 -3
- package/dist/desmos.js.map +1 -1
- package/dist/errors.d.ts +0 -19
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +0 -12
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.internal.d.ts +2 -0
- package/dist/index.internal.d.ts.map +1 -0
- package/dist/index.internal.js +2 -0
- package/dist/index.internal.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/magic/expr/index.d.ts +1 -1
- package/dist/magic/expr/index.js +3 -3
- package/dist/magic/expr/latex.d.ts +1 -1
- package/dist/magic/expr/latex.js +1 -2
- package/dist/magic/expr/latex.js.map +1 -1
- package/dist/magic/expr/text.d.ts +1 -1
- package/dist/magic/expr/text.js +1 -2
- package/dist/magic/expr/text.js.map +1 -1
- package/dist/magic/global/dark-mode.d.ts +1 -1
- package/dist/magic/global/dark-mode.js +1 -1
- package/dist/magic/global/desmos.d.ts +1 -1
- package/dist/magic/global/desmos.js +1 -1
- package/dist/magic/global/index.d.ts +1 -1
- package/dist/magic/global/index.js +4 -4
- package/dist/magic/global/viewport.d.ts +1 -1
- package/dist/magic/global/viewport.js +1 -2
- package/dist/magic/global/viewport.js.map +1 -1
- package/dist/magic/incantation.d.ts +1 -45
- package/dist/magic/incantation.d.ts.map +1 -1
- package/dist/magic/incantation.js +1 -39
- package/dist/magic/incantation.js.map +1 -1
- package/dist/magic/index.d.ts +5 -5
- package/dist/magic/index.js +4 -4
- package/dist/magic/local/anim.d.ts +1 -1
- package/dist/magic/local/anim.js +1 -2
- package/dist/magic/local/anim.js.map +1 -1
- package/dist/magic/local/colour.d.ts +2 -2
- package/dist/magic/local/colour.js +3 -3
- package/dist/magic/local/dashed.d.ts +1 -1
- package/dist/magic/local/dashed.js +1 -1
- package/dist/magic/local/fill.d.ts +1 -1
- package/dist/magic/local/fill.js +1 -1
- package/dist/magic/local/hide.d.ts +1 -1
- package/dist/magic/local/hide.js +1 -1
- package/dist/magic/local/index.d.ts +1 -1
- package/dist/magic/local/index.js +11 -11
- package/dist/magic/local/line.d.ts +1 -1
- package/dist/magic/local/line.js +1 -1
- package/dist/magic/local/no-line.d.ts +1 -1
- package/dist/magic/local/no-line.js +1 -1
- package/dist/magic/local/point.d.ts +1 -1
- package/dist/magic/local/point.js +1 -1
- package/dist/magic/local/secret.d.ts +1 -1
- package/dist/magic/local/secret.js +1 -1
- package/dist/magic/local/slider.d.ts +1 -1
- package/dist/magic/local/slider.js +1 -2
- package/dist/magic/local/slider.js.map +1 -1
- package/dist/parser/ast.d.ts +2 -11
- package/dist/parser/ast.d.ts.map +1 -1
- package/dist/parser/ast.js +2 -3
- package/dist/parser/ast.js.map +1 -1
- package/dist/parser/desmost-parser.d.ts +7 -88
- package/dist/parser/desmost-parser.d.ts.map +1 -1
- package/dist/parser/desmost-parser.js +5 -108
- package/dist/parser/desmost-parser.js.map +1 -1
- package/dist/parser/generic-parser.d.ts +1 -44
- package/dist/parser/generic-parser.d.ts.map +1 -1
- package/dist/parser/generic-parser.js +1 -47
- package/dist/parser/generic-parser.js.map +1 -1
- package/dist/parser/index.d.ts +2 -7
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +2 -7
- package/dist/parser/index.js.map +1 -1
- package/package.json +14 -8
- package/src/index.internal.ts +1 -0
- package/dist/src/compiler/compile.d.ts +0 -32
- package/dist/src/compiler/compile.d.ts.map +0 -1
- package/dist/src/compiler/compile.js +0 -101
- package/dist/src/compiler/compile.js.map +0 -1
- package/dist/src/compiler/evaluate.d.ts +0 -18
- package/dist/src/compiler/evaluate.d.ts.map +0 -1
- package/dist/src/compiler/evaluate.js +0 -83
- package/dist/src/compiler/evaluate.js.map +0 -1
- package/dist/src/compiler/index.d.ts +0 -3
- package/dist/src/compiler/index.d.ts.map +0 -1
- package/dist/src/compiler/index.js +0 -2
- package/dist/src/compiler/index.js.map +0 -1
- package/dist/src/compiler/options.d.ts +0 -54
- package/dist/src/compiler/options.d.ts.map +0 -1
- package/dist/src/compiler/options.js +0 -15
- package/dist/src/compiler/options.js.map +0 -1
- package/dist/src/desmos.d.ts +0 -12
- package/dist/src/desmos.d.ts.map +0 -1
- package/dist/src/desmos.js +0 -13
- package/dist/src/desmos.js.map +0 -1
- package/dist/src/errors.d.ts +0 -45
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js +0 -38
- package/dist/src/errors.js.map +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +0 -1
- package/dist/src/magic/expr/index.d.ts +0 -3
- package/dist/src/magic/expr/index.d.ts.map +0 -1
- package/dist/src/magic/expr/index.js +0 -8
- package/dist/src/magic/expr/index.js.map +0 -1
- package/dist/src/magic/expr/latex.d.ts +0 -10
- package/dist/src/magic/expr/latex.d.ts.map +0 -1
- package/dist/src/magic/expr/latex.js +0 -16
- package/dist/src/magic/expr/latex.js.map +0 -1
- package/dist/src/magic/expr/text.d.ts +0 -9
- package/dist/src/magic/expr/text.d.ts.map +0 -1
- package/dist/src/magic/expr/text.js +0 -13
- package/dist/src/magic/expr/text.js.map +0 -1
- package/dist/src/magic/global/dark-mode.d.ts +0 -7
- package/dist/src/magic/global/dark-mode.d.ts.map +0 -1
- package/dist/src/magic/global/dark-mode.js +0 -11
- package/dist/src/magic/global/dark-mode.js.map +0 -1
- package/dist/src/magic/global/desmos.d.ts +0 -9
- package/dist/src/magic/global/desmos.d.ts.map +0 -1
- package/dist/src/magic/global/desmos.js +0 -11
- package/dist/src/magic/global/desmos.js.map +0 -1
- package/dist/src/magic/global/index.d.ts +0 -3
- package/dist/src/magic/global/index.d.ts.map +0 -1
- package/dist/src/magic/global/index.js +0 -10
- package/dist/src/magic/global/index.js.map +0 -1
- package/dist/src/magic/global/viewport.d.ts +0 -16
- package/dist/src/magic/global/viewport.d.ts.map +0 -1
- package/dist/src/magic/global/viewport.js +0 -12
- package/dist/src/magic/global/viewport.js.map +0 -1
- package/dist/src/magic/incantation.d.ts +0 -74
- package/dist/src/magic/incantation.d.ts.map +0 -1
- package/dist/src/magic/incantation.js +0 -81
- package/dist/src/magic/incantation.js.map +0 -1
- package/dist/src/magic/index.d.ts +0 -6
- package/dist/src/magic/index.d.ts.map +0 -1
- package/dist/src/magic/index.js +0 -5
- package/dist/src/magic/index.js.map +0 -1
- package/dist/src/magic/local/anim.d.ts +0 -7
- package/dist/src/magic/local/anim.d.ts.map +0 -1
- package/dist/src/magic/local/anim.js +0 -11
- package/dist/src/magic/local/anim.js.map +0 -1
- package/dist/src/magic/local/colour.d.ts +0 -12
- package/dist/src/magic/local/colour.d.ts.map +0 -1
- package/dist/src/magic/local/colour.js +0 -27
- package/dist/src/magic/local/colour.js.map +0 -1
- package/dist/src/magic/local/dashed.d.ts +0 -7
- package/dist/src/magic/local/dashed.d.ts.map +0 -1
- package/dist/src/magic/local/dashed.js +0 -10
- package/dist/src/magic/local/dashed.js.map +0 -1
- package/dist/src/magic/local/fill.d.ts +0 -13
- package/dist/src/magic/local/fill.d.ts.map +0 -1
- package/dist/src/magic/local/fill.js +0 -12
- package/dist/src/magic/local/fill.js.map +0 -1
- package/dist/src/magic/local/hide.d.ts +0 -7
- package/dist/src/magic/local/hide.d.ts.map +0 -1
- package/dist/src/magic/local/hide.js +0 -10
- package/dist/src/magic/local/hide.js.map +0 -1
- package/dist/src/magic/local/index.d.ts +0 -3
- package/dist/src/magic/local/index.d.ts.map +0 -1
- package/dist/src/magic/local/index.js +0 -24
- package/dist/src/magic/local/index.js.map +0 -1
- package/dist/src/magic/local/line.d.ts +0 -15
- package/dist/src/magic/local/line.d.ts.map +0 -1
- package/dist/src/magic/local/line.js +0 -17
- package/dist/src/magic/local/line.js.map +0 -1
- package/dist/src/magic/local/no-line.d.ts +0 -7
- package/dist/src/magic/local/no-line.d.ts.map +0 -1
- package/dist/src/magic/local/no-line.js +0 -10
- package/dist/src/magic/local/no-line.js.map +0 -1
- package/dist/src/magic/local/point.d.ts +0 -15
- package/dist/src/magic/local/point.d.ts.map +0 -1
- package/dist/src/magic/local/point.js +0 -17
- package/dist/src/magic/local/point.js.map +0 -1
- package/dist/src/magic/local/secret.d.ts +0 -7
- package/dist/src/magic/local/secret.d.ts.map +0 -1
- package/dist/src/magic/local/secret.js +0 -10
- package/dist/src/magic/local/secret.js.map +0 -1
- package/dist/src/magic/local/slider.d.ts +0 -15
- package/dist/src/magic/local/slider.d.ts.map +0 -1
- package/dist/src/magic/local/slider.js +0 -13
- package/dist/src/magic/local/slider.js.map +0 -1
- package/dist/src/parser/ast.d.ts +0 -40
- package/dist/src/parser/ast.d.ts.map +0 -1
- package/dist/src/parser/ast.js +0 -13
- package/dist/src/parser/ast.js.map +0 -1
- package/dist/src/parser/desmost-parser.d.ts +0 -105
- package/dist/src/parser/desmost-parser.d.ts.map +0 -1
- package/dist/src/parser/desmost-parser.js +0 -379
- package/dist/src/parser/desmost-parser.js.map +0 -1
- package/dist/src/parser/generic-parser.d.ts +0 -62
- package/dist/src/parser/generic-parser.d.ts.map +0 -1
- package/dist/src/parser/generic-parser.js +0 -143
- package/dist/src/parser/generic-parser.js.map +0 -1
- package/dist/src/parser/index.d.ts +0 -8
- package/dist/src/parser/index.d.ts.map +0 -1
- package/dist/src/parser/index.js +0 -8
- package/dist/src/parser/index.js.map +0 -1
|
@@ -1,74 +1,30 @@
|
|
|
1
|
-
import { type Unrecoverable } from "../errors";
|
|
2
|
-
/**
|
|
3
|
-
* An *Incantation* is like a slash command that tells Desmost to do something - like changing the properties of an expression, or applying some settings to the calculator as a whole.
|
|
4
|
-
*
|
|
5
|
-
* Incantations must be prefixed by a `/`. They look like this:
|
|
6
|
-
*
|
|
7
|
-
* ```math
|
|
8
|
-
* /viewport{ left: -1, right: 1 }
|
|
9
|
-
* /hidden :: x = 69
|
|
10
|
-
* /text :: Never gonna give you up
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Incantations that accept an argument derive from `ArgIncantation`.
|
|
14
|
-
*/
|
|
1
|
+
import { type Unrecoverable } from "../errors.js";
|
|
15
2
|
export declare abstract class Incantation<Effect extends Incantation.Effect = Incantation.Effect> {
|
|
16
|
-
/** Short user-facing description of what the incantation does. */
|
|
17
3
|
abstract readonly description: string;
|
|
18
|
-
/** The raw text sequence that matches this incantation, such as `viewport` or `hidden`. */
|
|
19
4
|
abstract readonly identifier: string;
|
|
20
|
-
/** An alternative `.identifier`, strictly for localisation purposes only. */
|
|
21
5
|
readonly alias?: string;
|
|
22
|
-
/** Apply this incantation's effect to `target`, using the provided `data` if required. */
|
|
23
6
|
abstract apply(target: Effect extends GLOBAL ? Desmos.Calculator : Desmos.ExpressionState, data?: unknown): void;
|
|
24
|
-
/** Error if the `actual` type of the given expression is not `required`. */
|
|
25
7
|
protected require_expr_type<T extends Desmos.ExpressionState["type"]>(actual: unknown, required: T): asserts actual is T;
|
|
26
8
|
}
|
|
27
|
-
/**
|
|
28
|
-
* An incantation that accepts an argument.
|
|
29
|
-
*/
|
|
30
9
|
export declare abstract class ArgIncantation<Effect extends Incantation.Effect = Incantation.Effect> extends Incantation<Effect> {
|
|
31
|
-
/** Does this incantation always require an argument to be passed? */
|
|
32
10
|
readonly requires_arg: boolean;
|
|
33
|
-
/** What type of argument does this incantation accept? */
|
|
34
11
|
abstract readonly arg_type: Incantation.ArgType;
|
|
35
|
-
/**
|
|
36
|
-
* Evaluate the argument provided to this incantation, throwing if an error is encountered.
|
|
37
|
-
*
|
|
38
|
-
* For instance, for `/viewport{ left: -1, right: 1 }`, this returns the POJO `{ left: -1, right: 1 }`.
|
|
39
|
-
*
|
|
40
|
-
* ## Notes
|
|
41
|
-
*
|
|
42
|
-
* Child incantation classes should override this method, though the defaults should cover most cases (except `ArgType.ENUM`).
|
|
43
|
-
*/
|
|
44
12
|
evaluate_arg(raw: string): Unrecoverable<unknown>;
|
|
45
13
|
}
|
|
46
14
|
export declare namespace Incantation {
|
|
47
|
-
/** The kind of effect an incantation produces - it either modifies only one block, or modifies the calculator as a whole. */
|
|
48
15
|
enum Effect {
|
|
49
|
-
/** An incantation that affects the entire Desmos calculator state, like `/desmos` or `/viewport`. */
|
|
50
16
|
GLOBAL = 0,
|
|
51
|
-
/** An incantation that affects only the expression immediately following it, like `/hide` or `/slider`. */
|
|
52
17
|
LOCAL = 1,
|
|
53
|
-
/** An incantation that produces an expression, like `/latex` or `/text`. */
|
|
54
18
|
EXPR = 2
|
|
55
19
|
}
|
|
56
|
-
/** The type of argument an incantation accepts, which affects how it is parsed. */
|
|
57
20
|
enum ArgType {
|
|
58
|
-
/** Any arbitrary user text content, where characters like `"` and `'` don't have semantic meaning and can be ignored. */
|
|
59
21
|
STRING = "String",
|
|
60
|
-
/** LaTeX, which should have balanced `{}` braces. */
|
|
61
22
|
LATEX = "LaTeX",
|
|
62
|
-
/** Specific value from an allowed set of values, which will map to an enum value in the Desmos API. */
|
|
63
23
|
ENUM = "Enum",
|
|
64
|
-
/** JavaScript object fields, where characters like `{}` and `"` all have semantic meaning, and must be balanced. */
|
|
65
24
|
OBJECT = "Object"
|
|
66
25
|
}
|
|
67
26
|
}
|
|
68
|
-
/** An incantation that affects the entire Desmos calculator state, like `/desmos` or `/viewport`. */
|
|
69
27
|
export type GLOBAL = Incantation.Effect.GLOBAL;
|
|
70
|
-
/** An incantation that affects only the expression immediately following it, like `/hide` or `/slider`. */
|
|
71
28
|
export type LOCAL = Incantation.Effect.LOCAL;
|
|
72
|
-
/** An incantation that produces an expression, like `/latex` or `/text`. */
|
|
73
29
|
export type EXPR = Incantation.Effect.EXPR;
|
|
74
30
|
//# sourceMappingURL=incantation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incantation.d.ts","sourceRoot":"","sources":["../../src/magic/incantation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"incantation.d.ts","sourceRoot":"","sources":["../../src/magic/incantation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAgBnE,8BAAsB,WAAW,CAC/B,MAAM,SAAS,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM;IAItD,kBAAyB,WAAW,EAAE,MAAM,CAAA;IAG5C,kBAAyB,UAAU,EAAE,MAAM,CAAA;IAG3C,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAA;IAI9B,SAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,eAAe,EAC1E,IAAI,CAAC,EAAE,OAAO,GACb,IAAI,CAAA;IAGP,SAAS,CAAC,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,EAClE,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,CAAC,GACV,OAAO,CAAC,MAAM,IAAI,CAAC,CAQrB;CACF;AAMD,8BAAsB,cAAc,CAClC,MAAM,SAAS,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAEtD,SAAQ,WAAW,CAAC,MAAM,CAAC;IAG3B,SAAgB,YAAY,EAAE,OAAO,CAAO;IAG5C,kBAAyB,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAA;IAY/C,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAgBvD;CACF;AAGD,yBAAiB,WAAW,CAC5B;IAEE,KAAY,MAAM;QAGhB,MAAM,IAAA;QAGN,KAAK,IAAA;QAGL,IAAI,IAAA;KACL;IAGD,KAAY,OAAO;QAGjB,MAAM,WAAW;QAGjB,KAAK,UAAU;QAGf,IAAI,SAAS;QAGb,MAAM,WAAW;KAClB;CACF;AAMD,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;AAG/C,MAAM,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;AAG7C,MAAM,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC"}
|
|
@@ -1,43 +1,15 @@
|
|
|
1
1
|
import Json5 from "json5";
|
|
2
|
-
import { UnrecoverableError } from "../errors";
|
|
3
|
-
/**
|
|
4
|
-
* An *Incantation* is like a slash command that tells Desmost to do something - like changing the properties of an expression, or applying some settings to the calculator as a whole.
|
|
5
|
-
*
|
|
6
|
-
* Incantations must be prefixed by a `/`. They look like this:
|
|
7
|
-
*
|
|
8
|
-
* ```math
|
|
9
|
-
* /viewport{ left: -1, right: 1 }
|
|
10
|
-
* /hidden :: x = 69
|
|
11
|
-
* /text :: Never gonna give you up
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* Incantations that accept an argument derive from `ArgIncantation`.
|
|
15
|
-
*/
|
|
2
|
+
import { UnrecoverableError } from "../errors.js";
|
|
16
3
|
export class Incantation {
|
|
17
|
-
/** An alternative `.identifier`, strictly for localisation purposes only. */
|
|
18
4
|
alias;
|
|
19
|
-
/** Error if the `actual` type of the given expression is not `required`. */
|
|
20
5
|
require_expr_type(actual, required) {
|
|
21
6
|
if ((actual ?? "expression") !== required) {
|
|
22
7
|
throw new UnrecoverableError.IllegalIncantation(`/${this.identifier} can only applied to ${required === "expression" ? "latex" : required} expressions, but target block has type: ${actual}`);
|
|
23
8
|
}
|
|
24
9
|
}
|
|
25
10
|
}
|
|
26
|
-
/**
|
|
27
|
-
* An incantation that accepts an argument.
|
|
28
|
-
*/
|
|
29
11
|
export class ArgIncantation extends Incantation {
|
|
30
|
-
/** Does this incantation always require an argument to be passed? */
|
|
31
12
|
requires_arg = true;
|
|
32
|
-
/**
|
|
33
|
-
* Evaluate the argument provided to this incantation, throwing if an error is encountered.
|
|
34
|
-
*
|
|
35
|
-
* For instance, for `/viewport{ left: -1, right: 1 }`, this returns the POJO `{ left: -1, right: 1 }`.
|
|
36
|
-
*
|
|
37
|
-
* ## Notes
|
|
38
|
-
*
|
|
39
|
-
* Child incantation classes should override this method, though the defaults should cover most cases (except `ArgType.ENUM`).
|
|
40
|
-
*/
|
|
41
13
|
evaluate_arg(raw) {
|
|
42
14
|
switch (this.arg_type) {
|
|
43
15
|
case Incantation.ArgType.STRING: return raw;
|
|
@@ -48,33 +20,23 @@ export class ArgIncantation extends Incantation {
|
|
|
48
20
|
return Json5.parse(`{${raw}}`);
|
|
49
21
|
}
|
|
50
22
|
catch (e) {
|
|
51
|
-
// @ts-expect-error: fine
|
|
52
23
|
throw new UnrecoverableError.InvalidArgument(e.message);
|
|
53
24
|
}
|
|
54
25
|
}
|
|
55
26
|
}
|
|
56
27
|
}
|
|
57
28
|
(function (Incantation) {
|
|
58
|
-
/** The kind of effect an incantation produces - it either modifies only one block, or modifies the calculator as a whole. */
|
|
59
29
|
let Effect;
|
|
60
30
|
(function (Effect) {
|
|
61
|
-
/** An incantation that affects the entire Desmos calculator state, like `/desmos` or `/viewport`. */
|
|
62
31
|
Effect[Effect["GLOBAL"] = 0] = "GLOBAL";
|
|
63
|
-
/** An incantation that affects only the expression immediately following it, like `/hide` or `/slider`. */
|
|
64
32
|
Effect[Effect["LOCAL"] = 1] = "LOCAL";
|
|
65
|
-
/** An incantation that produces an expression, like `/latex` or `/text`. */
|
|
66
33
|
Effect[Effect["EXPR"] = 2] = "EXPR";
|
|
67
34
|
})(Effect = Incantation.Effect || (Incantation.Effect = {}));
|
|
68
|
-
/** The type of argument an incantation accepts, which affects how it is parsed. */
|
|
69
35
|
let ArgType;
|
|
70
36
|
(function (ArgType) {
|
|
71
|
-
/** Any arbitrary user text content, where characters like `"` and `'` don't have semantic meaning and can be ignored. */
|
|
72
37
|
ArgType["STRING"] = "String";
|
|
73
|
-
/** LaTeX, which should have balanced `{}` braces. */
|
|
74
38
|
ArgType["LATEX"] = "LaTeX";
|
|
75
|
-
/** Specific value from an allowed set of values, which will map to an enum value in the Desmos API. */
|
|
76
39
|
ArgType["ENUM"] = "Enum";
|
|
77
|
-
/** JavaScript object fields, where characters like `{}` and `"` all have semantic meaning, and must be balanced. */
|
|
78
40
|
ArgType["OBJECT"] = "Object";
|
|
79
41
|
})(ArgType = Incantation.ArgType || (Incantation.ArgType = {}));
|
|
80
42
|
})(Incantation || (Incantation = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incantation.js","sourceRoot":"","sources":["../../src/magic/incantation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAsB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"incantation.js","sourceRoot":"","sources":["../../src/magic/incantation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAsB,MAAM,WAAW,CAAC;AAgBnE,MAAM,OAAgB,WAAW;IAWf,KAAK,CAAS;IAUpB,iBAAiB,CACzB,MAAe,EACf,QAAW;QAGX,IAAI,CAAC,MAAM,IAAI,YAAY,CAAC,KAAK,QAAQ,EACzC,CAAC;YACC,MAAM,IAAI,kBAAkB,CAAC,kBA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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { Incantation, ArgIncantation } from "./incantation";
|
|
2
|
-
export type { GLOBAL, LOCAL, EXPR } from "./incantation";
|
|
3
|
-
export { GLOBAL_INCANTATIONS } from "./global";
|
|
4
|
-
export { LOCAL_INCANTATIONS } from "./local";
|
|
5
|
-
export { EXPR_INCANTATIONS } from "./expr";
|
|
1
|
+
export { Incantation, ArgIncantation } from "./incantation.js";
|
|
2
|
+
export type { GLOBAL, LOCAL, EXPR } from "./incantation.js";
|
|
3
|
+
export { GLOBAL_INCANTATIONS } from "./global/index.js";
|
|
4
|
+
export { LOCAL_INCANTATIONS } from "./local/index.js";
|
|
5
|
+
export { EXPR_INCANTATIONS } from "./expr/index.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/magic/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Incantation, ArgIncantation } from "./incantation";
|
|
2
|
-
export { GLOBAL_INCANTATIONS } from "./global";
|
|
3
|
-
export { LOCAL_INCANTATIONS } from "./local";
|
|
4
|
-
export { EXPR_INCANTATIONS } from "./expr";
|
|
1
|
+
export { Incantation, ArgIncantation } from "./incantation.js";
|
|
2
|
+
export { GLOBAL_INCANTATIONS } from "./global/index.js";
|
|
3
|
+
export { LOCAL_INCANTATIONS } from "./local/index.js";
|
|
4
|
+
export { EXPR_INCANTATIONS } from "./expr/index.js";
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, type LOCAL } from "../incantation";
|
|
1
|
+
import { Incantation, type LOCAL } from "../incantation.js";
|
|
2
2
|
export declare class AnimIncantation extends Incantation<LOCAL> {
|
|
3
3
|
readonly description = "Animates the slider of a block.";
|
|
4
4
|
readonly identifier = "anim";
|
package/dist/magic/local/anim.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Incantation } from "../incantation";
|
|
1
|
+
import { Incantation } from "../incantation.js";
|
|
2
2
|
export class AnimIncantation extends Incantation {
|
|
3
3
|
description = "Animates the slider of a block.";
|
|
4
4
|
identifier = "anim";
|
|
5
5
|
apply(target) {
|
|
6
6
|
super.require_expr_type(target.type, "expression");
|
|
7
|
-
// @ts-expect-error: outdated types
|
|
8
7
|
target.playing = true;
|
|
9
8
|
}
|
|
10
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anim.js","sourceRoot":"","sources":["../../../src/magic/local/anim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAGzD,MAAM,OAAO,eAAgB,SAAQ,WAAkB;IAEnC,WAAW,GACzB,iCAAiC,CAAA;IAEnB,UAAU,GAAG,MAAM,CAAA;IAE5B,KAAK,CAAC,MAA8B;QAE3C,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"anim.js","sourceRoot":"","sources":["../../../src/magic/local/anim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAGzD,MAAM,OAAO,eAAgB,SAAQ,WAAkB;IAEnC,WAAW,GACzB,iCAAiC,CAAA;IAEnB,UAAU,GAAG,MAAM,CAAA;IAE5B,KAAK,CAAC,MAA8B;QAE3C,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QAEnD,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation, type LOCAL } from "../incantation";
|
|
2
|
-
import { DesmosColour } from "../../desmos";
|
|
1
|
+
import { Incantation, ArgIncantation, type LOCAL } from "../incantation.js";
|
|
2
|
+
import { DesmosColour } from "../../desmos.js";
|
|
3
3
|
export declare class ColourIncantation extends ArgIncantation<LOCAL> {
|
|
4
4
|
readonly description = "";
|
|
5
5
|
readonly identifier = "color";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation } from "../incantation";
|
|
2
|
-
import { UnrecoverableError } from "../../errors";
|
|
3
|
-
import { DesmosColour } from "../../desmos";
|
|
1
|
+
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
|
+
import { UnrecoverableError } from "../../errors.js";
|
|
3
|
+
import { DesmosColour } from "../../desmos.js";
|
|
4
4
|
export class ColourIncantation extends ArgIncantation {
|
|
5
5
|
description = "";
|
|
6
6
|
identifier = "color";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, type LOCAL } from "../incantation";
|
|
1
|
+
import { Incantation, type LOCAL } from "../incantation.js";
|
|
2
2
|
export declare class DashedIncantation extends Incantation<LOCAL> {
|
|
3
3
|
readonly description = "Render a block as a dashed line.";
|
|
4
4
|
readonly identifier = "dashed";
|
package/dist/magic/local/fill.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, type LOCAL } from "../incantation";
|
|
1
|
+
import { Incantation, type LOCAL } from "../incantation.js";
|
|
2
2
|
export declare class HideIncantation extends Incantation<LOCAL> {
|
|
3
3
|
readonly description = "Hide rendering for a block. This includes graphs, points, polygons, etc.";
|
|
4
4
|
readonly identifier = "hide";
|
package/dist/magic/local/hide.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Incantation } from "../incantation";
|
|
2
|
-
import { AnimIncantation } from "./anim";
|
|
3
|
-
import { ColourIncantation } from "./colour";
|
|
4
|
-
import { DashedIncantation } from "./dashed";
|
|
5
|
-
import { FillIncantation } from "./fill";
|
|
6
|
-
import { HideIncantation } from "./hide";
|
|
7
|
-
import { LineIncantation } from "./line";
|
|
8
|
-
import { NoLineIncantation } from "./no-line";
|
|
9
|
-
import { PointIncantation } from "./point";
|
|
10
|
-
import { SecretIncantation } from "./secret";
|
|
11
|
-
import { SliderIncantation } from "./slider";
|
|
1
|
+
import { Incantation } from "../incantation.js";
|
|
2
|
+
import { AnimIncantation } from "./anim.js";
|
|
3
|
+
import { ColourIncantation } from "./colour.js";
|
|
4
|
+
import { DashedIncantation } from "./dashed.js";
|
|
5
|
+
import { FillIncantation } from "./fill.js";
|
|
6
|
+
import { HideIncantation } from "./hide.js";
|
|
7
|
+
import { LineIncantation } from "./line.js";
|
|
8
|
+
import { NoLineIncantation } from "./no-line.js";
|
|
9
|
+
import { PointIncantation } from "./point.js";
|
|
10
|
+
import { SecretIncantation } from "./secret.js";
|
|
11
|
+
import { SliderIncantation } from "./slider.js";
|
|
12
12
|
export const LOCAL_INCANTATIONS = [
|
|
13
13
|
new AnimIncantation(),
|
|
14
14
|
new ColourIncantation(),
|
package/dist/magic/local/line.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, type LOCAL } from "../incantation";
|
|
1
|
+
import { Incantation, type LOCAL } from "../incantation.js";
|
|
2
2
|
export declare class NoLineIncantation extends Incantation<LOCAL> {
|
|
3
3
|
readonly description = "Disable rendering lines for a block.";
|
|
4
4
|
readonly identifier = "no-line";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, type LOCAL } from "../incantation";
|
|
1
|
+
import { Incantation, type LOCAL } from "../incantation.js";
|
|
2
2
|
export declare class SecretIncantation extends Incantation<LOCAL> {
|
|
3
3
|
readonly description = "Turn a block into a secret expression, which is hidden from the end user.";
|
|
4
4
|
readonly identifier = "secret";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation } from "../incantation";
|
|
1
|
+
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
2
|
export class SliderIncantation extends ArgIncantation {
|
|
3
3
|
description = "Set the bounds of the slider for a variable.";
|
|
4
4
|
identifier = "slider";
|
|
@@ -6,7 +6,6 @@ export class SliderIncantation extends ArgIncantation {
|
|
|
6
6
|
arg_type = Incantation.ArgType.OBJECT;
|
|
7
7
|
apply(target, data) {
|
|
8
8
|
super.require_expr_type(target.type, "expression");
|
|
9
|
-
// @ts-expect-error: outdated types
|
|
10
9
|
target.sliderBounds = data;
|
|
11
10
|
}
|
|
12
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../src/magic/local/slider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAWzE,MAAM,OAAO,iBAAkB,SAAQ,cAAqB;IAExC,WAAW,GACzB,8CAA8C,CAAA;IAEhC,UAAU,GAAK,QAAQ,CAAA;IACvB,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;
|
|
1
|
+
{"version":3,"file":"slider.js","sourceRoot":"","sources":["../../../src/magic/local/slider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAWzE,MAAM,OAAO,iBAAkB,SAAQ,cAAqB;IAExC,WAAW,GACzB,8CAA8C,CAAA;IAEhC,UAAU,GAAK,QAAQ,CAAA;IACvB,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;QAEnD,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7B,CAAC;CACF"}
|
package/dist/parser/ast.d.ts
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { UnrecoverableError } from "../errors";
|
|
2
|
-
import { Incantation, ArgIncantation } from "../magic";
|
|
1
|
+
import { UnrecoverableError } from "../errors.js";
|
|
2
|
+
import { Incantation, ArgIncantation } from "../magic/index.js";
|
|
3
3
|
export declare namespace Ast {
|
|
4
|
-
/** What kind of parse result this is. */
|
|
5
4
|
enum Kind {
|
|
6
5
|
EXPRESSION = "Expression",
|
|
7
6
|
INCANTATION_INVOCATION = "Incantation-Invocation",
|
|
8
7
|
INVALID_INCANTATION = "Invalid-Incantation"
|
|
9
8
|
}
|
|
10
|
-
/** A Desmos expression to add to the calculator. */
|
|
11
9
|
interface Expression {
|
|
12
10
|
kind: Kind.EXPRESSION;
|
|
13
11
|
data: Desmos.ExpressionState;
|
|
14
12
|
incantations: Array<IncantationInvocation<Incantation.Effect.LOCAL> | InvalidInvocation>;
|
|
15
13
|
}
|
|
16
|
-
/** A pending incantation invocation that requires applying its argument (if any), then applying its effect. */
|
|
17
14
|
type IncantationInvocation<Effect extends Incantation.Effect = Incantation.Effect> = {
|
|
18
15
|
kind: Kind.INCANTATION_INVOCATION;
|
|
19
16
|
incantation: Incantation<Effect>;
|
|
@@ -23,11 +20,6 @@ export declare namespace Ast {
|
|
|
23
20
|
incantation: ArgIncantation<Effect>;
|
|
24
21
|
arg_raw: string | undefined;
|
|
25
22
|
};
|
|
26
|
-
/**
|
|
27
|
-
* An invalid invantation invocation that raised an error when parsed.
|
|
28
|
-
*
|
|
29
|
-
* This will be propogated to the user as an extra Desmos text expression (unless they have `errors: false` configured).
|
|
30
|
-
*/
|
|
31
23
|
interface InvalidInvocation {
|
|
32
24
|
kind: Kind.INVALID_INCANTATION;
|
|
33
25
|
incantation: Incantation;
|
|
@@ -35,6 +27,5 @@ export declare namespace Ast {
|
|
|
35
27
|
error: UnrecoverableError;
|
|
36
28
|
}
|
|
37
29
|
}
|
|
38
|
-
/** An abstract object produced by parsing a block of source code. */
|
|
39
30
|
export type Ast = Ast.Expression | Ast.IncantationInvocation | Ast.InvalidInvocation;
|
|
40
31
|
//# sourceMappingURL=ast.d.ts.map
|
package/dist/parser/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/parser/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGvD,yBAAiB,GAAG,CACpB;
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/parser/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGvD,yBAAiB,GAAG,CACpB;IAEE,KAAY,IAAI;QAEd,UAAU,eAA2B;QACrC,sBAAsB,2BAA2B;QACjD,mBAAmB,wBAA2B;KAC/C;IAID,UAAiB,UAAU;QAEzB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAA;QACrB,IAAI,EAAE,MAAM,CAAC,eAAe,CAAA;QAC5B,YAAY,EAAE,KAAK,CACf,qBAAqB,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,GAC/C,iBAAiB,CAClB,CAAA;KACJ;IAID,KAAY,qBAAqB,CAAC,MAAM,SAAS,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,IACpF;QACA,IAAI,EAAE,IAAI,CAAC,sBAAsB,CAAA;QACjC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;QAChC,OAAO,EAAE,SAAS,CAAA;KACnB,GACC;QACA,IAAI,EAAE,IAAI,CAAC,sBAAsB,CAAA;QACjC,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;QACnC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;KAC5B,CAAC;IAOJ,UAAiB,iBAAiB;QAEhC,IAAI,EAAE,IAAI,CAAC,mBAAmB,CAAA;QAC9B,WAAW,EAAE,WAAW,CAAA;QACxB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,kBAAkB,CAAA;KAC1B;CACF;AAGD,MAAM,MAAM,GAAG,GACX,GAAG,CAAC,UAAU,GACd,GAAG,CAAC,qBAAqB,GACzB,GAAG,CAAC,iBAAiB,CACxB"}
|
package/dist/parser/ast.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { UnrecoverableError } from "../errors";
|
|
2
|
-
import { Incantation, ArgIncantation } from "../magic";
|
|
1
|
+
import { UnrecoverableError } from "../errors.js";
|
|
2
|
+
import { Incantation, ArgIncantation } from "../magic/index.js";
|
|
3
3
|
export var Ast;
|
|
4
4
|
(function (Ast) {
|
|
5
|
-
/** What kind of parse result this is. */
|
|
6
5
|
let Kind;
|
|
7
6
|
(function (Kind) {
|
|
8
7
|
Kind["EXPRESSION"] = "Expression";
|
package/dist/parser/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/parser/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGvD,MAAM,KAAW,GAAG,CAgDnB;AAhDD,WAAiB,GAAG;
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/parser/ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGvD,MAAM,KAAW,GAAG,CAgDnB;AAhDD,WAAiB,GAAG;IAGlB,IAAY,IAKX;IALD,WAAY,IAAI;QAEd,iCAAqC,CAAA;QACrC,yDAAiD,CAAA;QACjD,mDAA8C,CAAA;IAChD,CAAC,EALW,IAAI,GAAJ,IAAA,IAAI,KAAJ,IAAA,IAAI,QAKf;AAwCH,CAAC,EAhDgB,GAAG,KAAH,GAAG,QAgDnB"}
|
|
@@ -1,105 +1,24 @@
|
|
|
1
|
-
import { GenericParser } from "./generic-parser";
|
|
2
|
-
import { Ast } from "./ast";
|
|
3
|
-
import type { Recoverable, Unrecoverable, MaybeRecoverable } from "../errors";
|
|
4
|
-
import { Incantation } from "../magic";
|
|
5
|
-
import type { GLOBAL, LOCAL } from "../magic";
|
|
6
|
-
import type { DesmostOptions } from "../compiler";
|
|
7
|
-
/**
|
|
8
|
-
* A stateful lazy parser for Desmost.
|
|
9
|
-
*/
|
|
1
|
+
import { GenericParser } from "./generic-parser.js";
|
|
2
|
+
import { Ast } from "./ast.js";
|
|
3
|
+
import type { Recoverable, Unrecoverable, MaybeRecoverable } from "../errors.js";
|
|
4
|
+
import { Incantation } from "../magic/index.js";
|
|
5
|
+
import type { GLOBAL, LOCAL } from "../magic/index.js";
|
|
6
|
+
import type { DesmostOptions } from "../compiler/index.js";
|
|
10
7
|
export declare class DesmostParser extends GenericParser {
|
|
11
8
|
constructor(source: string, options?: DesmostOptions);
|
|
12
|
-
/**
|
|
13
|
-
* Parse the next semantic block of source code, producing an `Ast` object, or `null` if the parser has successfully reached the end of the source code.
|
|
14
|
-
*/
|
|
15
9
|
parse_next(): Ast | null;
|
|
16
|
-
/**
|
|
17
|
-
* Parse Desmost syntax before the `::` separator, which may be:
|
|
18
|
-
*
|
|
19
|
-
* - 1 global incantation
|
|
20
|
-
* - 1+ local incantations
|
|
21
|
-
*/
|
|
22
10
|
parse_pre_sep(): Unrecoverable<{
|
|
23
11
|
global: Ast.IncantationInvocation<GLOBAL> | Ast.InvalidInvocation;
|
|
24
12
|
} | {
|
|
25
13
|
local: Array<Ast.IncantationInvocation<LOCAL> | Ast.InvalidInvocation>;
|
|
26
14
|
}>;
|
|
27
|
-
/**
|
|
28
|
-
* Parse the Desmost `::` separator.
|
|
29
|
-
*/
|
|
30
15
|
parse_sep(): Unrecoverable<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Parse Desmost syntax after the `::` separator, which may be:
|
|
33
|
-
*
|
|
34
|
-
* - 1 line of LaTeX
|
|
35
|
-
* - 1 expression incantation
|
|
36
|
-
*/
|
|
37
16
|
parse_post_sep(): Unrecoverable<Ast.Expression>;
|
|
38
|
-
/**
|
|
39
|
-
* Parse a single line of LaTeX.
|
|
40
|
-
*/
|
|
41
17
|
parse_latex_line(): Unrecoverable<Ast.Expression>;
|
|
42
|
-
/**
|
|
43
|
-
* Attempt to parse a global incantation invocation.
|
|
44
|
-
*/
|
|
45
18
|
try_parse_global_incantation(): Recoverable<Ast.IncantationInvocation<GLOBAL> | Ast.InvalidInvocation>;
|
|
46
|
-
/**
|
|
47
|
-
* Attempt to parse a local incantation invocation.
|
|
48
|
-
*/
|
|
49
19
|
try_parse_local_incantation(): Recoverable<Ast.IncantationInvocation<LOCAL> | Ast.InvalidInvocation>;
|
|
50
20
|
try_parse_expr_incantation(): MaybeRecoverable<Ast.Expression>;
|
|
51
|
-
/**
|
|
52
|
-
* Attempt to parse an incantation identifier.
|
|
53
|
-
*/
|
|
54
21
|
try_parse_identifier<Effect extends Incantation.Effect>(incantations: Incantation<Effect>[]): Recoverable<Incantation<Effect>>;
|
|
55
|
-
|
|
56
|
-
* Parse an argument to an incantation, enclosed in `{}`.
|
|
57
|
-
*
|
|
58
|
-
* ```ts
|
|
59
|
-
* /incantation{ arg }
|
|
60
|
-
* ^^^^^^^
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* ## Notes
|
|
64
|
-
*
|
|
65
|
-
* We don't actually care for what type the argument is since we won't be evaluating it, we just want to find the closing `}`.
|
|
66
|
-
*
|
|
67
|
-
* However, the argument itself might be *meant* to contain a `}`. So we need a way to accurately identify the actual closing brace:
|
|
68
|
-
*
|
|
69
|
-
* ```ts
|
|
70
|
-
* /incantation{ field: { value: 1 } }
|
|
71
|
-
* ^ ^
|
|
72
|
-
* ```
|
|
73
|
-
*
|
|
74
|
-
* A well-formed argument always has matching pairs of `{}`, so we'll keep a stack. It starts with the opening `{`. When the stack is depleted, we must've reached the end of the argument.
|
|
75
|
-
*
|
|
76
|
-
* However, there's still more edge cases:
|
|
77
|
-
*
|
|
78
|
-
* ```ts
|
|
79
|
-
* /label{ text: "This }s weird" }
|
|
80
|
-
* ^
|
|
81
|
-
* ```
|
|
82
|
-
*
|
|
83
|
-
* `{` and `}` can appear in strings, and they won't necessarily be matched, so we'll ignore them by also tracking string contexts.
|
|
84
|
-
*
|
|
85
|
-
* ```ts
|
|
86
|
-
* /latex{ \{ x, y ) }
|
|
87
|
-
* ^
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* `{` and `}` in LaTeX can be escaped with `\{` or `\}`, and these won't necessarily be matched, so we'll ignore them by also tracking backslash escapes.
|
|
91
|
-
*
|
|
92
|
-
* If the user truly mismatches `{}`, then, well ...parsing will fail catastrophically!
|
|
93
|
-
*/
|
|
94
|
-
parse_incantation_arg(
|
|
95
|
-
/**
|
|
96
|
-
* The type of argument to parse.
|
|
97
|
-
*
|
|
98
|
-
* Parsing strategy varies for different types:
|
|
99
|
-
*
|
|
100
|
-
* - String / LaTeX: Track only balanced `{}` and escaped `\{\}`.
|
|
101
|
-
* - JavaScript object: The above, plus balanced string quotes.
|
|
102
|
-
*/
|
|
103
|
-
arg_type: Incantation.ArgType): Unrecoverable<string>;
|
|
22
|
+
parse_incantation_arg(arg_type: Incantation.ArgType): Unrecoverable<string>;
|
|
104
23
|
}
|
|
105
24
|
//# 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;AAG5B,OAAO,KA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