desmost 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compiler/compile.d.ts +32 -0
- package/dist/compiler/compile.d.ts.map +1 -0
- package/dist/compiler/compile.js +101 -0
- package/dist/compiler/compile.js.map +1 -0
- package/dist/compiler/evaluate.d.ts +18 -0
- package/dist/compiler/evaluate.d.ts.map +1 -0
- package/dist/compiler/evaluate.js +83 -0
- package/dist/compiler/evaluate.js.map +1 -0
- package/dist/compiler/index.d.ts +3 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +2 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/options.d.ts +54 -0
- package/dist/compiler/options.d.ts.map +1 -0
- package/dist/compiler/options.js +15 -0
- package/dist/compiler/options.js.map +1 -0
- package/dist/desmos.d.ts +12 -0
- package/dist/desmos.d.ts.map +1 -0
- package/dist/desmos.js +13 -0
- package/dist/desmos.js.map +1 -0
- package/dist/errors.d.ts +45 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +38 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/magic/expr/index.d.ts +3 -0
- package/dist/magic/expr/index.d.ts.map +1 -0
- package/dist/magic/expr/index.js +8 -0
- package/dist/magic/expr/index.js.map +1 -0
- package/dist/magic/expr/latex.d.ts +10 -0
- package/dist/magic/expr/latex.d.ts.map +1 -0
- package/dist/magic/expr/latex.js +16 -0
- package/dist/magic/expr/latex.js.map +1 -0
- package/dist/magic/expr/text.d.ts +9 -0
- package/dist/magic/expr/text.d.ts.map +1 -0
- package/dist/magic/expr/text.js +13 -0
- package/dist/magic/expr/text.js.map +1 -0
- package/dist/magic/global/dark-mode.d.ts +7 -0
- package/dist/magic/global/dark-mode.d.ts.map +1 -0
- package/dist/magic/global/dark-mode.js +11 -0
- package/dist/magic/global/dark-mode.js.map +1 -0
- package/dist/magic/global/desmos.d.ts +9 -0
- package/dist/magic/global/desmos.d.ts.map +1 -0
- package/dist/magic/global/desmos.js +11 -0
- package/dist/magic/global/desmos.js.map +1 -0
- package/dist/magic/global/index.d.ts +3 -0
- package/dist/magic/global/index.d.ts.map +1 -0
- package/dist/magic/global/index.js +10 -0
- package/dist/magic/global/index.js.map +1 -0
- package/dist/magic/global/viewport.d.ts +16 -0
- package/dist/magic/global/viewport.d.ts.map +1 -0
- package/dist/magic/global/viewport.js +12 -0
- package/dist/magic/global/viewport.js.map +1 -0
- package/dist/magic/incantation.d.ts +74 -0
- package/dist/magic/incantation.d.ts.map +1 -0
- package/dist/magic/incantation.js +81 -0
- package/dist/magic/incantation.js.map +1 -0
- package/dist/magic/index.d.ts +6 -0
- package/dist/magic/index.d.ts.map +1 -0
- package/dist/magic/index.js +5 -0
- package/dist/magic/index.js.map +1 -0
- package/dist/magic/local/anim.d.ts +7 -0
- package/dist/magic/local/anim.d.ts.map +1 -0
- package/dist/magic/local/anim.js +11 -0
- package/dist/magic/local/anim.js.map +1 -0
- package/dist/magic/local/colour.d.ts +12 -0
- package/dist/magic/local/colour.d.ts.map +1 -0
- package/dist/magic/local/colour.js +27 -0
- package/dist/magic/local/colour.js.map +1 -0
- package/dist/magic/local/dashed.d.ts +7 -0
- package/dist/magic/local/dashed.d.ts.map +1 -0
- package/dist/magic/local/dashed.js +10 -0
- package/dist/magic/local/dashed.js.map +1 -0
- package/dist/magic/local/fill.d.ts +13 -0
- package/dist/magic/local/fill.d.ts.map +1 -0
- package/dist/magic/local/fill.js +12 -0
- package/dist/magic/local/fill.js.map +1 -0
- package/dist/magic/local/hide.d.ts +7 -0
- package/dist/magic/local/hide.d.ts.map +1 -0
- package/dist/magic/local/hide.js +10 -0
- package/dist/magic/local/hide.js.map +1 -0
- package/dist/magic/local/index.d.ts +3 -0
- package/dist/magic/local/index.d.ts.map +1 -0
- package/dist/magic/local/index.js +24 -0
- package/dist/magic/local/index.js.map +1 -0
- package/dist/magic/local/line.d.ts +15 -0
- package/dist/magic/local/line.d.ts.map +1 -0
- package/dist/magic/local/line.js +17 -0
- package/dist/magic/local/line.js.map +1 -0
- package/dist/magic/local/no-line.d.ts +7 -0
- package/dist/magic/local/no-line.d.ts.map +1 -0
- package/dist/magic/local/no-line.js +10 -0
- package/dist/magic/local/no-line.js.map +1 -0
- package/dist/magic/local/point.d.ts +15 -0
- package/dist/magic/local/point.d.ts.map +1 -0
- package/dist/magic/local/point.js +17 -0
- package/dist/magic/local/point.js.map +1 -0
- package/dist/magic/local/secret.d.ts +7 -0
- package/dist/magic/local/secret.d.ts.map +1 -0
- package/dist/magic/local/secret.js +10 -0
- package/dist/magic/local/secret.js.map +1 -0
- package/dist/magic/local/slider.d.ts +15 -0
- package/dist/magic/local/slider.d.ts.map +1 -0
- package/dist/magic/local/slider.js +13 -0
- package/dist/magic/local/slider.js.map +1 -0
- package/dist/parser/ast.d.ts +40 -0
- package/dist/parser/ast.d.ts.map +1 -0
- package/dist/parser/ast.js +13 -0
- package/dist/parser/ast.js.map +1 -0
- package/dist/parser/desmost-parser.d.ts +105 -0
- package/dist/parser/desmost-parser.d.ts.map +1 -0
- package/dist/parser/desmost-parser.js +379 -0
- package/dist/parser/desmost-parser.js.map +1 -0
- package/dist/parser/generic-parser.d.ts +62 -0
- package/dist/parser/generic-parser.d.ts.map +1 -0
- package/dist/parser/generic-parser.js +143 -0
- package/dist/parser/generic-parser.js.map +1 -0
- package/dist/parser/index.d.ts +8 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +8 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/src/compiler/compile.d.ts +32 -0
- package/dist/src/compiler/compile.d.ts.map +1 -0
- package/dist/src/compiler/compile.js +101 -0
- package/dist/src/compiler/compile.js.map +1 -0
- package/dist/src/compiler/evaluate.d.ts +18 -0
- package/dist/src/compiler/evaluate.d.ts.map +1 -0
- package/dist/src/compiler/evaluate.js +83 -0
- package/dist/src/compiler/evaluate.js.map +1 -0
- package/dist/src/compiler/index.d.ts +3 -0
- package/dist/src/compiler/index.d.ts.map +1 -0
- package/dist/src/compiler/index.js +2 -0
- package/dist/src/compiler/index.js.map +1 -0
- package/dist/src/compiler/options.d.ts +54 -0
- package/dist/src/compiler/options.d.ts.map +1 -0
- package/dist/src/compiler/options.js +15 -0
- package/dist/src/compiler/options.js.map +1 -0
- package/dist/src/desmos.d.ts +12 -0
- package/dist/src/desmos.d.ts.map +1 -0
- package/dist/src/desmos.js +13 -0
- package/dist/src/desmos.js.map +1 -0
- package/dist/src/errors.d.ts +45 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +38 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/magic/expr/index.d.ts +3 -0
- package/dist/src/magic/expr/index.d.ts.map +1 -0
- package/dist/src/magic/expr/index.js +8 -0
- package/dist/src/magic/expr/index.js.map +1 -0
- package/dist/src/magic/expr/latex.d.ts +10 -0
- package/dist/src/magic/expr/latex.d.ts.map +1 -0
- package/dist/src/magic/expr/latex.js +16 -0
- package/dist/src/magic/expr/latex.js.map +1 -0
- package/dist/src/magic/expr/text.d.ts +9 -0
- package/dist/src/magic/expr/text.d.ts.map +1 -0
- package/dist/src/magic/expr/text.js +13 -0
- package/dist/src/magic/expr/text.js.map +1 -0
- package/dist/src/magic/global/dark-mode.d.ts +7 -0
- package/dist/src/magic/global/dark-mode.d.ts.map +1 -0
- package/dist/src/magic/global/dark-mode.js +11 -0
- package/dist/src/magic/global/dark-mode.js.map +1 -0
- package/dist/src/magic/global/desmos.d.ts +9 -0
- package/dist/src/magic/global/desmos.d.ts.map +1 -0
- package/dist/src/magic/global/desmos.js +11 -0
- package/dist/src/magic/global/desmos.js.map +1 -0
- package/dist/src/magic/global/index.d.ts +3 -0
- package/dist/src/magic/global/index.d.ts.map +1 -0
- package/dist/src/magic/global/index.js +10 -0
- package/dist/src/magic/global/index.js.map +1 -0
- package/dist/src/magic/global/viewport.d.ts +16 -0
- package/dist/src/magic/global/viewport.d.ts.map +1 -0
- package/dist/src/magic/global/viewport.js +12 -0
- package/dist/src/magic/global/viewport.js.map +1 -0
- package/dist/src/magic/incantation.d.ts +74 -0
- package/dist/src/magic/incantation.d.ts.map +1 -0
- package/dist/src/magic/incantation.js +81 -0
- package/dist/src/magic/incantation.js.map +1 -0
- package/dist/src/magic/index.d.ts +6 -0
- package/dist/src/magic/index.d.ts.map +1 -0
- package/dist/src/magic/index.js +5 -0
- package/dist/src/magic/index.js.map +1 -0
- package/dist/src/magic/local/anim.d.ts +7 -0
- package/dist/src/magic/local/anim.d.ts.map +1 -0
- package/dist/src/magic/local/anim.js +11 -0
- package/dist/src/magic/local/anim.js.map +1 -0
- package/dist/src/magic/local/colour.d.ts +12 -0
- package/dist/src/magic/local/colour.d.ts.map +1 -0
- package/dist/src/magic/local/colour.js +27 -0
- package/dist/src/magic/local/colour.js.map +1 -0
- package/dist/src/magic/local/dashed.d.ts +7 -0
- package/dist/src/magic/local/dashed.d.ts.map +1 -0
- package/dist/src/magic/local/dashed.js +10 -0
- package/dist/src/magic/local/dashed.js.map +1 -0
- package/dist/src/magic/local/fill.d.ts +13 -0
- package/dist/src/magic/local/fill.d.ts.map +1 -0
- package/dist/src/magic/local/fill.js +12 -0
- package/dist/src/magic/local/fill.js.map +1 -0
- package/dist/src/magic/local/hide.d.ts +7 -0
- package/dist/src/magic/local/hide.d.ts.map +1 -0
- package/dist/src/magic/local/hide.js +10 -0
- package/dist/src/magic/local/hide.js.map +1 -0
- package/dist/src/magic/local/index.d.ts +3 -0
- package/dist/src/magic/local/index.d.ts.map +1 -0
- package/dist/src/magic/local/index.js +24 -0
- package/dist/src/magic/local/index.js.map +1 -0
- package/dist/src/magic/local/line.d.ts +15 -0
- package/dist/src/magic/local/line.d.ts.map +1 -0
- package/dist/src/magic/local/line.js +17 -0
- package/dist/src/magic/local/line.js.map +1 -0
- package/dist/src/magic/local/no-line.d.ts +7 -0
- package/dist/src/magic/local/no-line.d.ts.map +1 -0
- package/dist/src/magic/local/no-line.js +10 -0
- package/dist/src/magic/local/no-line.js.map +1 -0
- package/dist/src/magic/local/point.d.ts +15 -0
- package/dist/src/magic/local/point.d.ts.map +1 -0
- package/dist/src/magic/local/point.js +17 -0
- package/dist/src/magic/local/point.js.map +1 -0
- package/dist/src/magic/local/secret.d.ts +7 -0
- package/dist/src/magic/local/secret.d.ts.map +1 -0
- package/dist/src/magic/local/secret.js +10 -0
- package/dist/src/magic/local/secret.js.map +1 -0
- package/dist/src/magic/local/slider.d.ts +15 -0
- package/dist/src/magic/local/slider.d.ts.map +1 -0
- package/dist/src/magic/local/slider.js +13 -0
- package/dist/src/magic/local/slider.js.map +1 -0
- package/dist/src/parser/ast.d.ts +40 -0
- package/dist/src/parser/ast.d.ts.map +1 -0
- package/dist/src/parser/ast.js +13 -0
- package/dist/src/parser/ast.js.map +1 -0
- package/dist/src/parser/desmost-parser.d.ts +105 -0
- package/dist/src/parser/desmost-parser.d.ts.map +1 -0
- package/dist/src/parser/desmost-parser.js +379 -0
- package/dist/src/parser/desmost-parser.js.map +1 -0
- package/dist/src/parser/generic-parser.d.ts +62 -0
- package/dist/src/parser/generic-parser.d.ts.map +1 -0
- package/dist/src/parser/generic-parser.js +143 -0
- package/dist/src/parser/generic-parser.js.map +1 -0
- package/dist/src/parser/index.d.ts +8 -0
- package/dist/src/parser/index.d.ts.map +1 -0
- package/dist/src/parser/index.js +8 -0
- package/dist/src/parser/index.js.map +1 -0
- package/package.json +58 -0
- package/src/compiler/compile.ts +127 -0
- package/src/compiler/evaluate.ts +121 -0
- package/src/compiler/index.ts +2 -0
- package/src/compiler/options.ts +77 -0
- package/src/desmos.ts +13 -0
- package/src/errors.ts +46 -0
- package/src/index.ts +1 -0
- package/src/magic/.template.ts +22 -0
- package/src/magic/expr/index.ts +11 -0
- package/src/magic/expr/latex.ts +24 -0
- package/src/magic/expr/text.ts +19 -0
- package/src/magic/global/dark-mode.ts +17 -0
- package/src/magic/global/desmos.ts +20 -0
- package/src/magic/global/index.ts +13 -0
- package/src/magic/global/viewport.ts +25 -0
- package/src/magic/incantation.ts +142 -0
- package/src/magic/index.ts +6 -0
- package/src/magic/local/anim.ts +17 -0
- package/src/magic/local/colour.ts +38 -0
- package/src/magic/local/dashed.ts +16 -0
- package/src/magic/local/fill.ts +24 -0
- package/src/magic/local/hide.ts +16 -0
- package/src/magic/local/index.ts +27 -0
- package/src/magic/local/line.ts +29 -0
- package/src/magic/local/no-line.ts +16 -0
- package/src/magic/local/point.ts +29 -0
- package/src/magic/local/secret.ts +16 -0
- package/src/magic/local/slider.ts +27 -0
- package/src/parser/ast.ts +60 -0
- package/src/parser/desmost-parser.ts +486 -0
- package/src/parser/generic-parser.ts +191 -0
- package/src/parser/index.ts +8 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Incantation } from "../incantation";
|
|
2
|
+
export class SecretIncantation extends Incantation {
|
|
3
|
+
description = "Turn a block into a secret expression, which is hidden from the end user.";
|
|
4
|
+
identifier = "secret";
|
|
5
|
+
apply(target) {
|
|
6
|
+
super.require_expr_type(target.type, "expression");
|
|
7
|
+
target.secret = true;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=secret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret.js","sourceRoot":"","sources":["../../../src/magic/local/secret.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAGzD,MAAM,OAAO,iBAAkB,SAAQ,WAAkB;IAErC,WAAW,GACzB,2EAA2E,CAAA;IAE7D,UAAU,GAAG,QAAQ,CAAA;IAE9B,KAAK,CAAC,MAA8B;QAE3C,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACnD,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Incantation, ArgIncantation, type LOCAL } from "../incantation";
|
|
2
|
+
interface SliderBounds {
|
|
3
|
+
min?: number | string;
|
|
4
|
+
max?: number | string;
|
|
5
|
+
step?: number | string;
|
|
6
|
+
}
|
|
7
|
+
export declare class SliderIncantation extends ArgIncantation<LOCAL> {
|
|
8
|
+
readonly description = "Set the bounds of the slider for a variable.";
|
|
9
|
+
readonly identifier = "slider";
|
|
10
|
+
readonly requires_arg = true;
|
|
11
|
+
readonly arg_type = Incantation.ArgType.OBJECT;
|
|
12
|
+
apply(target: Desmos.ExpressionState, data: SliderBounds): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=slider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../src/magic/local/slider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGzE,UAAU,YAAY;IAEpB,GAAG,CAAC,EAAG,MAAM,GAAG,MAAM,CAAC;IACvB,GAAG,CAAC,EAAG,MAAM,GAAG,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAGD,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAE1D,SAAkB,WAAW,kDACqB;IAElD,SAAkB,UAAU,YAAa;IACzC,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAElD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,YAAY,QAKhE;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Incantation, ArgIncantation } from "../incantation";
|
|
2
|
+
export class SliderIncantation extends ArgIncantation {
|
|
3
|
+
description = "Set the bounds of the slider for a variable.";
|
|
4
|
+
identifier = "slider";
|
|
5
|
+
requires_arg = true;
|
|
6
|
+
arg_type = Incantation.ArgType.OBJECT;
|
|
7
|
+
apply(target, data) {
|
|
8
|
+
super.require_expr_type(target.type, "expression");
|
|
9
|
+
// @ts-expect-error: outdated types
|
|
10
|
+
target.sliderBounds = data;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +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;QACnD,mCAAmC;QACnC,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UnrecoverableError } from "../errors";
|
|
2
|
+
import { Incantation, ArgIncantation } from "../magic";
|
|
3
|
+
export declare namespace Ast {
|
|
4
|
+
/** What kind of parse result this is. */
|
|
5
|
+
enum Kind {
|
|
6
|
+
EXPRESSION = "Expression",
|
|
7
|
+
INCANTATION_INVOCATION = "Incantation-Invocation",
|
|
8
|
+
INVALID_INCANTATION = "Invalid-Incantation"
|
|
9
|
+
}
|
|
10
|
+
/** A Desmos expression to add to the calculator. */
|
|
11
|
+
interface Expression {
|
|
12
|
+
kind: Kind.EXPRESSION;
|
|
13
|
+
data: Desmos.ExpressionState;
|
|
14
|
+
incantations: Array<IncantationInvocation<Incantation.Effect.LOCAL> | InvalidInvocation>;
|
|
15
|
+
}
|
|
16
|
+
/** A pending incantation invocation that requires applying its argument (if any), then applying its effect. */
|
|
17
|
+
type IncantationInvocation<Effect extends Incantation.Effect = Incantation.Effect> = {
|
|
18
|
+
kind: Kind.INCANTATION_INVOCATION;
|
|
19
|
+
incantation: Incantation<Effect>;
|
|
20
|
+
arg_raw: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
kind: Kind.INCANTATION_INVOCATION;
|
|
23
|
+
incantation: ArgIncantation<Effect>;
|
|
24
|
+
arg_raw: string | undefined;
|
|
25
|
+
};
|
|
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
|
+
interface InvalidInvocation {
|
|
32
|
+
kind: Kind.INVALID_INCANTATION;
|
|
33
|
+
incantation: Incantation;
|
|
34
|
+
arg_raw?: string;
|
|
35
|
+
error: UnrecoverableError;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** An abstract object produced by parsing a block of source code. */
|
|
39
|
+
export type Ast = Ast.Expression | Ast.IncantationInvocation | Ast.InvalidInvocation;
|
|
40
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +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;IACE,yCAAyC;IACzC,KAAY,IAAI;QAEd,UAAU,eAA2B;QACrC,sBAAsB,2BAA2B;QACjD,mBAAmB,wBAA2B;KAC/C;IAGD,oDAAoD;IACpD,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;IAGD,+GAA+G;IAC/G,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;IAEJ;;;;OAIG;IACH,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;AAED,qEAAqE;AACrE,MAAM,MAAM,GAAG,GACX,GAAG,CAAC,UAAU,GACd,GAAG,CAAC,qBAAqB,GACzB,GAAG,CAAC,iBAAiB,CACxB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UnrecoverableError } from "../errors";
|
|
2
|
+
import { Incantation, ArgIncantation } from "../magic";
|
|
3
|
+
export var Ast;
|
|
4
|
+
(function (Ast) {
|
|
5
|
+
/** What kind of parse result this is. */
|
|
6
|
+
let Kind;
|
|
7
|
+
(function (Kind) {
|
|
8
|
+
Kind["EXPRESSION"] = "Expression";
|
|
9
|
+
Kind["INCANTATION_INVOCATION"] = "Incantation-Invocation";
|
|
10
|
+
Kind["INVALID_INCANTATION"] = "Invalid-Incantation";
|
|
11
|
+
})(Kind = Ast.Kind || (Ast.Kind = {}));
|
|
12
|
+
})(Ast || (Ast = {}));
|
|
13
|
+
//# sourceMappingURL=ast.js.map
|
|
@@ -0,0 +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;IAElB,yCAAyC;IACzC,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"}
|
|
@@ -0,0 +1,105 @@
|
|
|
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
|
+
*/
|
|
10
|
+
export declare class DesmostParser extends GenericParser {
|
|
11
|
+
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
|
+
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
|
+
parse_pre_sep(): Unrecoverable<{
|
|
23
|
+
global: Ast.IncantationInvocation<GLOBAL> | Ast.InvalidInvocation;
|
|
24
|
+
} | {
|
|
25
|
+
local: Array<Ast.IncantationInvocation<LOCAL> | Ast.InvalidInvocation>;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Parse the Desmost `::` separator.
|
|
29
|
+
*/
|
|
30
|
+
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
|
+
parse_post_sep(): Unrecoverable<Ast.Expression>;
|
|
38
|
+
/**
|
|
39
|
+
* Parse a single line of LaTeX.
|
|
40
|
+
*/
|
|
41
|
+
parse_latex_line(): Unrecoverable<Ast.Expression>;
|
|
42
|
+
/**
|
|
43
|
+
* Attempt to parse a global incantation invocation.
|
|
44
|
+
*/
|
|
45
|
+
try_parse_global_incantation(): Recoverable<Ast.IncantationInvocation<GLOBAL> | Ast.InvalidInvocation>;
|
|
46
|
+
/**
|
|
47
|
+
* Attempt to parse a local incantation invocation.
|
|
48
|
+
*/
|
|
49
|
+
try_parse_local_incantation(): Recoverable<Ast.IncantationInvocation<LOCAL> | Ast.InvalidInvocation>;
|
|
50
|
+
try_parse_expr_incantation(): MaybeRecoverable<Ast.Expression>;
|
|
51
|
+
/**
|
|
52
|
+
* Attempt to parse an incantation identifier.
|
|
53
|
+
*/
|
|
54
|
+
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>;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=desmost-parser.d.ts.map
|
|
@@ -0,0 +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,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE9E,OAAO,EACL,WAAW,EAEZ,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAQ,MAAM,UAAU,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD;;GAEG;AACH,qBAAa,aAAc,SAAQ,aAAa;IAE9C,YAAY,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,EAGnD;IAKD;;OAEG;IACI,UAAU,IAAI,GAAG,GAAG,IAAI,CAgC9B;IAED;;;;;OAKG;IACH,aAAa,IACX,aAAa,CACT;QAAE,MAAM,EAAE,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,GACjC,GAAG,CAAC,iBAAiB,CAAC;KACjC,GACC;QAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAC/B,GAAG,CAAC,iBAAiB,CAAC,CAAC;KACxC,CACF,CAkCF;IAED;;OAEG;IACH,SAAS,IAAI,aAAa,CAAC,IAAI,CAAC,CAM/B;IAED;;;;;OAKG;IACH,cAAc,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CA4B9C;IAKD;;OAEG;IACH,gBAAgB,IAAI,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAahD;IAGD;;OAEG;IACH,4BAA4B,IAC1B,WAAW,CACT,GAAG,CAAC,qBAAqB,CAAC,MAAM,CAAC,GACjC,GAAG,CAAC,iBAAiB,CACtB,CAwCF;IAED;;OAEG;IACH,2BAA2B,IACzB,WAAW,CACT,GAAG,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAChC,GAAG,CAAC,iBAAiB,CACtB,CAwCF;IAED,0BAA0B,IAAI,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,CA4B7D;IAED;;OAEG;IACH,oBAAoB,CAAC,MAAM,SAAS,WAAW,CAAC,MAAM,EACpD,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,GAClC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAwBlC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,qBAAqB;IACnB;;;;;;;OAOG;IACH,QAAQ,EAAE,WAAW,CAAC,OAAO,GAC5B,aAAa,CAAC,MAAM,CAAC,CAgFvB;CAEF"}
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { GenericParser } from "./generic-parser";
|
|
2
|
+
import { Ast } from "./ast";
|
|
3
|
+
import { RecoverableFail, UnrecoverableError } from "../errors";
|
|
4
|
+
import { Incantation, ArgIncantation, GLOBAL_INCANTATIONS, LOCAL_INCANTATIONS, EXPR_INCANTATIONS } from "../magic";
|
|
5
|
+
/**
|
|
6
|
+
* A stateful lazy parser for Desmost.
|
|
7
|
+
*/
|
|
8
|
+
export class DesmostParser extends GenericParser {
|
|
9
|
+
constructor(source, options) {
|
|
10
|
+
super(options?.ignore_trailing_blanks ? source : (source + "\n"));
|
|
11
|
+
}
|
|
12
|
+
// == TOP-LEVEL == //
|
|
13
|
+
/**
|
|
14
|
+
* 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.
|
|
15
|
+
*/
|
|
16
|
+
parse_next() {
|
|
17
|
+
this.consume_spaces();
|
|
18
|
+
if (this.out_of_bounds()) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (this.current === "/") {
|
|
22
|
+
let r = this.parse_pre_sep();
|
|
23
|
+
if ("global" in r) {
|
|
24
|
+
// 1 global
|
|
25
|
+
return r.global;
|
|
26
|
+
}
|
|
27
|
+
// 1+ locals + 1 expr
|
|
28
|
+
let incantations = r.local;
|
|
29
|
+
var expr = this.parse_post_sep();
|
|
30
|
+
for (let invocation of incantations) {
|
|
31
|
+
expr.incantations.push(invocation);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// 1 expr
|
|
36
|
+
var expr = this.parse_post_sep();
|
|
37
|
+
}
|
|
38
|
+
this.consume_end_of_block();
|
|
39
|
+
return expr;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse Desmost syntax before the `::` separator, which may be:
|
|
43
|
+
*
|
|
44
|
+
* - 1 global incantation
|
|
45
|
+
* - 1+ local incantations
|
|
46
|
+
*/
|
|
47
|
+
parse_pre_sep() {
|
|
48
|
+
// 1 global incantation
|
|
49
|
+
try {
|
|
50
|
+
let r = this.try_parse_global_incantation();
|
|
51
|
+
this.consume_end_of_block(`Received excess input after global incantation /${r.incantation.identifier}`);
|
|
52
|
+
return { global: r };
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
if (!(e instanceof RecoverableFail))
|
|
56
|
+
throw e;
|
|
57
|
+
}
|
|
58
|
+
let incantations = [];
|
|
59
|
+
// 1+ local incantations
|
|
60
|
+
while (this.current === "/") {
|
|
61
|
+
try {
|
|
62
|
+
incantations.push(this.try_parse_local_incantation());
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
if (!(e instanceof RecoverableFail))
|
|
66
|
+
throw e;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (incantations.length > 0) {
|
|
71
|
+
this.parse_sep();
|
|
72
|
+
}
|
|
73
|
+
return { local: incantations };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Parse the Desmost `::` separator.
|
|
77
|
+
*/
|
|
78
|
+
parse_sep() {
|
|
79
|
+
this.consume_whitespace();
|
|
80
|
+
this.consume("::", `Expected \`::\` separator between local incantations and expression, but found: \`${this.preview()}\``);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Parse Desmost syntax after the `::` separator, which may be:
|
|
84
|
+
*
|
|
85
|
+
* - 1 line of LaTeX
|
|
86
|
+
* - 1 expression incantation
|
|
87
|
+
*/
|
|
88
|
+
parse_post_sep() {
|
|
89
|
+
this.consume_spaces();
|
|
90
|
+
switch (this.current) {
|
|
91
|
+
// empty block
|
|
92
|
+
case "\n":
|
|
93
|
+
return {
|
|
94
|
+
kind: Ast.Kind.EXPRESSION,
|
|
95
|
+
data: { latex: ` ` },
|
|
96
|
+
incantations: [],
|
|
97
|
+
};
|
|
98
|
+
// expr incantation
|
|
99
|
+
case "/":
|
|
100
|
+
try {
|
|
101
|
+
return this.try_parse_expr_incantation();
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
if (!(e instanceof RecoverableFail))
|
|
105
|
+
throw e;
|
|
106
|
+
// plain LaTeX (fallback)
|
|
107
|
+
return this.parse_latex_line();
|
|
108
|
+
}
|
|
109
|
+
// plain LaTeX
|
|
110
|
+
default:
|
|
111
|
+
return this.parse_latex_line();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// == LOW-LEVEL == //
|
|
115
|
+
/**
|
|
116
|
+
* Parse a single line of LaTeX.
|
|
117
|
+
*/
|
|
118
|
+
parse_latex_line() {
|
|
119
|
+
let init = this.i;
|
|
120
|
+
while (!this.out_of_bounds() && this.current !== "\n") {
|
|
121
|
+
this.advance();
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
kind: Ast.Kind.EXPRESSION,
|
|
125
|
+
data: { latex: this.source.slice(init, this.i) },
|
|
126
|
+
incantations: [],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Attempt to parse a global incantation invocation.
|
|
131
|
+
*/
|
|
132
|
+
try_parse_global_incantation() {
|
|
133
|
+
let init = this.i;
|
|
134
|
+
this.try_consume("/");
|
|
135
|
+
try {
|
|
136
|
+
var incantation = this.try_parse_identifier(GLOBAL_INCANTATIONS);
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
if (e instanceof RecoverableFail) {
|
|
140
|
+
this.i = init;
|
|
141
|
+
}
|
|
142
|
+
throw e;
|
|
143
|
+
}
|
|
144
|
+
let data = undefined;
|
|
145
|
+
if (incantation instanceof ArgIncantation) {
|
|
146
|
+
if (this.current === "{") {
|
|
147
|
+
data = this.parse_incantation_arg(incantation.arg_type);
|
|
148
|
+
}
|
|
149
|
+
else if (incantation.requires_arg) {
|
|
150
|
+
return {
|
|
151
|
+
kind: Ast.Kind.INVALID_INCANTATION,
|
|
152
|
+
incantation,
|
|
153
|
+
error: new UnrecoverableError.MissingInput(`No argument provided for /${incantation.identifier}, which requires an argument of type: \`${incantation.arg_type}\``)
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
this.consume_spaces();
|
|
158
|
+
return {
|
|
159
|
+
kind: Ast.Kind.INCANTATION_INVOCATION,
|
|
160
|
+
incantation,
|
|
161
|
+
arg_raw: data,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Attempt to parse a local incantation invocation.
|
|
166
|
+
*/
|
|
167
|
+
try_parse_local_incantation() {
|
|
168
|
+
let init = this.i;
|
|
169
|
+
this.try_consume("/");
|
|
170
|
+
try {
|
|
171
|
+
var incantation = this.try_parse_identifier(LOCAL_INCANTATIONS);
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
if (e instanceof RecoverableFail) {
|
|
175
|
+
this.i = init;
|
|
176
|
+
}
|
|
177
|
+
throw e;
|
|
178
|
+
}
|
|
179
|
+
let arg_raw = undefined;
|
|
180
|
+
if (incantation instanceof ArgIncantation) {
|
|
181
|
+
if (this.current === "{") {
|
|
182
|
+
arg_raw = this.parse_incantation_arg(incantation.arg_type);
|
|
183
|
+
}
|
|
184
|
+
else if (incantation.requires_arg) {
|
|
185
|
+
return {
|
|
186
|
+
kind: Ast.Kind.INVALID_INCANTATION,
|
|
187
|
+
incantation,
|
|
188
|
+
error: new UnrecoverableError.MissingInput(`No argument provided for /${incantation.identifier}, which requires an argument of type: \`${incantation.arg_type}\``)
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
this.consume_whitespace();
|
|
193
|
+
return {
|
|
194
|
+
kind: Ast.Kind.INCANTATION_INVOCATION,
|
|
195
|
+
incantation,
|
|
196
|
+
arg_raw,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
try_parse_expr_incantation() {
|
|
200
|
+
// TODO refactor with `backtrack()` helper
|
|
201
|
+
let init = this.i;
|
|
202
|
+
this.try_consume("/");
|
|
203
|
+
try {
|
|
204
|
+
var incantation = this.try_parse_identifier(EXPR_INCANTATIONS);
|
|
205
|
+
}
|
|
206
|
+
catch (e) {
|
|
207
|
+
if (e instanceof RecoverableFail) {
|
|
208
|
+
// TODO maybe flag to user
|
|
209
|
+
this.i = init;
|
|
210
|
+
}
|
|
211
|
+
throw e;
|
|
212
|
+
}
|
|
213
|
+
let arg_raw = this.parse_incantation_arg(incantation.arg_type);
|
|
214
|
+
let data = {};
|
|
215
|
+
incantation.apply(data, arg_raw);
|
|
216
|
+
return {
|
|
217
|
+
kind: Ast.Kind.EXPRESSION,
|
|
218
|
+
data,
|
|
219
|
+
incantations: [],
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Attempt to parse an incantation identifier.
|
|
224
|
+
*/
|
|
225
|
+
try_parse_identifier(incantations) {
|
|
226
|
+
for (let incantation of incantations) {
|
|
227
|
+
// yeah the duplication here is a little meh, unfortunately needing `return` means we can't extract it into a helper
|
|
228
|
+
try {
|
|
229
|
+
this.try_consume(incantation.identifier);
|
|
230
|
+
return incantation;
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
if (!(e instanceof RecoverableFail))
|
|
234
|
+
throw e;
|
|
235
|
+
}
|
|
236
|
+
if (incantation.alias != undefined) {
|
|
237
|
+
try {
|
|
238
|
+
this.try_consume(incantation.alias);
|
|
239
|
+
return incantation;
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
if (!(e instanceof RecoverableFail))
|
|
243
|
+
throw e;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
throw new RecoverableFail();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Parse an argument to an incantation, enclosed in `{}`.
|
|
251
|
+
*
|
|
252
|
+
* ```ts
|
|
253
|
+
* /incantation{ arg }
|
|
254
|
+
* ^^^^^^^
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* ## Notes
|
|
258
|
+
*
|
|
259
|
+
* 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 `}`.
|
|
260
|
+
*
|
|
261
|
+
* However, the argument itself might be *meant* to contain a `}`. So we need a way to accurately identify the actual closing brace:
|
|
262
|
+
*
|
|
263
|
+
* ```ts
|
|
264
|
+
* /incantation{ field: { value: 1 } }
|
|
265
|
+
* ^ ^
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* 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.
|
|
269
|
+
*
|
|
270
|
+
* However, there's still more edge cases:
|
|
271
|
+
*
|
|
272
|
+
* ```ts
|
|
273
|
+
* /label{ text: "This }s weird" }
|
|
274
|
+
* ^
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* `{` and `}` can appear in strings, and they won't necessarily be matched, so we'll ignore them by also tracking string contexts.
|
|
278
|
+
*
|
|
279
|
+
* ```ts
|
|
280
|
+
* /latex{ \{ x, y ) }
|
|
281
|
+
* ^
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* `{` 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.
|
|
285
|
+
*
|
|
286
|
+
* If the user truly mismatches `{}`, then, well ...parsing will fail catastrophically!
|
|
287
|
+
*/
|
|
288
|
+
parse_incantation_arg(
|
|
289
|
+
/**
|
|
290
|
+
* The type of argument to parse.
|
|
291
|
+
*
|
|
292
|
+
* Parsing strategy varies for different types:
|
|
293
|
+
*
|
|
294
|
+
* - String / LaTeX: Track only balanced `{}` and escaped `\{\}`.
|
|
295
|
+
* - JavaScript object: The above, plus balanced string quotes.
|
|
296
|
+
*/
|
|
297
|
+
arg_type) {
|
|
298
|
+
let init = this.i;
|
|
299
|
+
this.consume("{", `Expected \`{\` to start incantation argument, but found: \`${this.preview()}\``);
|
|
300
|
+
let Ctx;
|
|
301
|
+
(function (Ctx) {
|
|
302
|
+
Ctx["BLOCK"] = "{";
|
|
303
|
+
Ctx["STR_1"] = "'";
|
|
304
|
+
Ctx["STR_2"] = "\"";
|
|
305
|
+
Ctx["STR_F"] = "`";
|
|
306
|
+
Ctx["ESCAPE"] = "\\";
|
|
307
|
+
})(Ctx || (Ctx = {}));
|
|
308
|
+
let stack = [Ctx.BLOCK];
|
|
309
|
+
/**
|
|
310
|
+
* Pop `ctx` if it is the currently active context, returning `true` if successful.
|
|
311
|
+
*
|
|
312
|
+
* If `{ force: true }`, backtrack the stack and report errors for unterminated contexts.
|
|
313
|
+
*/
|
|
314
|
+
function try_pop(ctx, options) {
|
|
315
|
+
if (stack.at(-1) === ctx) {
|
|
316
|
+
stack.pop();
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
else if (options?.force) {
|
|
320
|
+
if (stack.includes(ctx)) {
|
|
321
|
+
/* NOTE: We could report errors for unterminated contexts, but we'll leave that for the actual evaluation - in case we get something wrong ;) */
|
|
322
|
+
while (stack.at(-1) !== ctx) {
|
|
323
|
+
stack.pop();
|
|
324
|
+
}
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
while (stack.length > 0) {
|
|
331
|
+
if (try_pop(Ctx.ESCAPE)) {
|
|
332
|
+
this.advance(`Unexpected end of input while parsing incantation argument, stack: ${JSON.stringify(stack)}`);
|
|
333
|
+
}
|
|
334
|
+
let top = stack.at(-1);
|
|
335
|
+
switch (this.current) {
|
|
336
|
+
case Ctx.ESCAPE:
|
|
337
|
+
stack.push(Ctx.ESCAPE);
|
|
338
|
+
break;
|
|
339
|
+
/* NOTE: *Currently* `{}` should be ignored in all contexts except `Ctx.BLOCK`. This might change if more contexts are added in future! */
|
|
340
|
+
case Char.L_BRACE:
|
|
341
|
+
if (top !== Ctx.BLOCK)
|
|
342
|
+
break;
|
|
343
|
+
stack.push(Ctx.BLOCK);
|
|
344
|
+
break;
|
|
345
|
+
case Char.R_BRACE:
|
|
346
|
+
if (top !== Ctx.BLOCK)
|
|
347
|
+
break;
|
|
348
|
+
try_pop(Ctx.BLOCK, { force: true });
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
if (arg_type === Incantation.ArgType.OBJECT) {
|
|
352
|
+
switch (this.current) {
|
|
353
|
+
case Ctx.STR_1:
|
|
354
|
+
try_pop(Ctx.STR_1) || stack.push(Ctx.STR_1);
|
|
355
|
+
break;
|
|
356
|
+
case Ctx.STR_2:
|
|
357
|
+
try_pop(Ctx.STR_2) || stack.push(Ctx.STR_2);
|
|
358
|
+
break;
|
|
359
|
+
case Ctx.STR_F:
|
|
360
|
+
try_pop(Ctx.STR_F) || stack.push(Ctx.STR_F);
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
this.advance(`Unexpected end of input while parsing incantation argument, stack: ${JSON.stringify(stack)}`);
|
|
365
|
+
}
|
|
366
|
+
/* NOTE: Cut in by 1 on both sides to exclude {} braces */
|
|
367
|
+
return this.source.slice(init + 1, this.i - 1).trim();
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
var Char;
|
|
371
|
+
(function (Char) {
|
|
372
|
+
Char["L_BRACE"] = "{";
|
|
373
|
+
Char["R_BRACE"] = "}";
|
|
374
|
+
Char["QUOTE_SINGLE"] = "'";
|
|
375
|
+
Char["QUOTE_DOUBLE"] = "\"";
|
|
376
|
+
Char["BACKTICK"] = "`";
|
|
377
|
+
Char["BACKSLASH"] = "\\";
|
|
378
|
+
})(Char || (Char = {}));
|
|
379
|
+
//# sourceMappingURL=desmost-parser.js.map
|
|
@@ -0,0 +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;AAE5B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGhE,OAAO,EACL,WAAW,EAAE,cAAc,EAC3B,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAC3D,MAAM,UAAU,CAAC;AAMlB;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAE9C,YAAY,MAAc,EAAE,OAAwB;QAElD,KAAK,CAAC,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IACpE,CAAC;IAGD,qBAAqB;IAErB;;OAEG;IACI,UAAU;QAEf,IAAI,CAAC,cAAc,EAAE,CAAC;QAEtB,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,IAAI,IAAI,CAAC,OAAO,KAAK,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC,GA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