@rohal12/spindle 0.62.2 → 0.62.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pkg/format.js +1 -1
- package/dist/pkg/headless.js +462 -271
- package/dist/pkg/story-variables.js +590 -386
- package/dist/pkg/tooling.js +1 -0
- package/package.json +1 -1
- package/src/code-check.ts +1 -1
- package/src/completion-context.ts +226 -0
- package/src/components/Passage.tsx +28 -3
- package/src/define-macro.ts +6 -1
- package/src/macro-discovery.ts +27 -15
- package/src/markup/code-attributes.ts +10 -3
- package/src/markup/parse.ts +19 -4
- package/src/markup/spindle.d.peggy.ts +2 -0
- package/src/markup/spindle.peggy +22 -13
- package/src/passage-render-state.ts +7 -0
- package/src/saves/format.ts +4 -0
- package/src/saves/types.ts +6 -6
- package/src/static-literal.ts +24 -22
- package/src/store.ts +42 -16
- package/src/tooling.ts +4 -0
- package/src/triggers.ts +107 -0
- package/src/twine-editor/references.ts +9 -11
- package/src/widgets/ast-scanner.ts +40 -44
- package/src/widgets/widget-def.ts +74 -45
- package/types/tooling.d.ts +17 -0
|
@@ -10,133 +10,6 @@ var __exportAll = (all, no_symbols) => {
|
|
|
10
10
|
return target;
|
|
11
11
|
};
|
|
12
12
|
//#endregion
|
|
13
|
-
//#region src/utils/macro-names.ts
|
|
14
|
-
/**
|
|
15
|
-
* Macro and widget names are case-insensitive: `{StatusBar}` invokes the
|
|
16
|
-
* widget defined as `statusbar`. A NameMap keys its entries by the lowercased
|
|
17
|
-
* name.
|
|
18
|
-
*/
|
|
19
|
-
var NameMap = class extends Map {
|
|
20
|
-
get(name) {
|
|
21
|
-
return super.get(name.toLowerCase());
|
|
22
|
-
}
|
|
23
|
-
set(name, value) {
|
|
24
|
-
return super.set(name.toLowerCase(), value);
|
|
25
|
-
}
|
|
26
|
-
has(name) {
|
|
27
|
-
return super.has(name.toLowerCase());
|
|
28
|
-
}
|
|
29
|
-
delete(name) {
|
|
30
|
-
return super.delete(name.toLowerCase());
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
/** A set of macro or widget names (see NameMap). */
|
|
34
|
-
var NameSet = class {
|
|
35
|
-
constructor(names = []) {
|
|
36
|
-
this.names = new NameMap();
|
|
37
|
-
for (const name of names) this.add(name);
|
|
38
|
-
}
|
|
39
|
-
add(name) {
|
|
40
|
-
this.names.set(name, true);
|
|
41
|
-
}
|
|
42
|
-
has(name) {
|
|
43
|
-
return this.names.has(name);
|
|
44
|
-
}
|
|
45
|
-
delete(name) {
|
|
46
|
-
this.names.delete(name);
|
|
47
|
-
}
|
|
48
|
-
clear() {
|
|
49
|
-
this.names.clear();
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
new NameMap();
|
|
53
|
-
new NameMap();
|
|
54
|
-
new NameSet();
|
|
55
|
-
/**
|
|
56
|
-
* How a macro argument is read (see components/macros/macro-args.ts). Every
|
|
57
|
-
* declared parameter names one: there is no default.
|
|
58
|
-
* Quoted strings accept `\"`, `\'` and `\\` escapes.
|
|
59
|
-
* - `expression`: code, as written.
|
|
60
|
-
* - `statements`: code run as statements (`{set}`), as written.
|
|
61
|
-
* - `passage`: a passage name: a quoted string or an expression, as written.
|
|
62
|
-
* - `variable`: a variable reference such as `$name` or `"$name"`, as written.
|
|
63
|
-
* - `string`: one quoted string; anything else leaves the argument unset.
|
|
64
|
-
* - `text`: one quoted string, or text with any loose quotes stripped.
|
|
65
|
-
* - `names`: a comma-separated list of names (`@item, @i`).
|
|
66
|
-
* - `delay`: a duration (`2s`, `500ms`, `300`) in milliseconds.
|
|
67
|
-
* - `number`: a number.
|
|
68
|
-
* - `flag`: a keyword, the parameter's name, at the start or end; a boolean.
|
|
69
|
-
* - `separator`: a word (`of`) or `=` separating the parameters before it
|
|
70
|
-
* from those after it; a boolean.
|
|
71
|
-
* - `options`: keywords, the names of its `parameters`, each followed by a
|
|
72
|
-
* quoted string or a number unless it is a flag.
|
|
73
|
-
*/
|
|
74
|
-
var PARAMETER_TYPES = [
|
|
75
|
-
"expression",
|
|
76
|
-
"statements",
|
|
77
|
-
"passage",
|
|
78
|
-
"variable",
|
|
79
|
-
"string",
|
|
80
|
-
"text",
|
|
81
|
-
"names",
|
|
82
|
-
"delay",
|
|
83
|
-
"number",
|
|
84
|
-
"flag",
|
|
85
|
-
"separator",
|
|
86
|
-
"options"
|
|
87
|
-
];
|
|
88
|
-
/**
|
|
89
|
-
* What the value of a `string` or `text` argument holds, for the check at
|
|
90
|
-
* story start and for tooling (see code-check.ts):
|
|
91
|
-
* - `markup`: markup the macro renders (`{button}`'s label): its markup
|
|
92
|
-
* is checked.
|
|
93
|
-
* - `text`: plain text the macro uses as written (`{checkbox}`'s label).
|
|
94
|
-
* - `passage`: a passage name (`{watch}`'s `goto`): the passage must exist.
|
|
95
|
-
* - `expression`, `statements`: code (`{watch}`'s condition and `run`): it
|
|
96
|
-
* is checked as code, and its variable references against the schema.
|
|
97
|
-
*
|
|
98
|
-
* Without it, the argument of a macro with `interpolate` holds `markup`,
|
|
99
|
-
* any other `text`.
|
|
100
|
-
*/
|
|
101
|
-
var STRING_HOLDS = [
|
|
102
|
-
"markup",
|
|
103
|
-
"text",
|
|
104
|
-
"passage",
|
|
105
|
-
"expression",
|
|
106
|
-
"statements"
|
|
107
|
-
];
|
|
108
|
-
/**
|
|
109
|
-
* Throw if a parameter `macro` declares (or an option of one) has no type,
|
|
110
|
-
* or one that isn't a ParameterType: arguments are read by their type, and
|
|
111
|
-
* there is no default. Throw too if it declares what it `holds` wrongly.
|
|
112
|
-
*/
|
|
113
|
-
function checkParameterTypes(macro, parameters) {
|
|
114
|
-
const holdsFix = `Give a \`string\` or \`text\` parameter one of ${STRING_HOLDS.join(", ")} to hold (see docs/custom-macros.md#what-a-string-holds).`;
|
|
115
|
-
for (const param of parameters) {
|
|
116
|
-
const type = param.type;
|
|
117
|
-
if (!PARAMETER_TYPES.includes(type)) throw parameterError(macro, param, type === void 0 ? "has no type" : `has the unknown type ${JSON.stringify(type)}`, `Give it one of the types ${PARAMETER_TYPES.join(", ")} (see docs/custom-macros.md#parameter-types), or declare no parameters and read props.rawArgs.`);
|
|
118
|
-
const holds = param.holds;
|
|
119
|
-
if (holds !== void 0 && type !== "string" && type !== "text") throw parameterError(macro, param, `is of the type ${type}, which holds what it is`, holdsFix);
|
|
120
|
-
if (holds !== void 0 && !STRING_HOLDS.includes(holds)) throw parameterError(macro, param, `holds the unknown ${JSON.stringify(holds)}`, holdsFix);
|
|
121
|
-
if (param.parameters) checkParameterTypes(macro, param.parameters);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/** The error for the parameter `param` of `macro`: what is wrong, and the fix. */
|
|
125
|
-
function parameterError(macro, param, problem, fix) {
|
|
126
|
-
return /* @__PURE__ */ new Error(`spindle: The parameter "${param.name}" of the macro {${macro}} ${problem}. ${fix}`);
|
|
127
|
-
}
|
|
128
|
-
var metadataRegistry = new NameMap();
|
|
129
|
-
/** Indexed at registration, so parsing each tag does not scan every macro. */
|
|
130
|
-
var companionParents = new NameMap();
|
|
131
|
-
/** The parents declaring a branching companion (listbox options are values). */
|
|
132
|
-
function branchParents(name, macros) {
|
|
133
|
-
if (!macros) return [...companionParents.get(name) ?? []].filter((parent) => parent !== "listbox");
|
|
134
|
-
return macros.filter((macro) => macro.name.toLowerCase() !== "listbox" && macro.subMacros.some((sub) => sub.toLowerCase() === name.toLowerCase())).map((macro) => macro.name.toLowerCase());
|
|
135
|
-
}
|
|
136
|
-
function getMacroRegistry() {
|
|
137
|
-
return Array.from(metadataRegistry.values());
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
13
|
//#region src/markup/tokens.ts
|
|
141
14
|
/** Variable sigils: story ($), temporary (_), local (@), transient (%). */
|
|
142
15
|
var SIGIL_SCOPES = {
|
|
@@ -764,23 +637,29 @@ function peg$parse(input, options) {
|
|
|
764
637
|
return [body ? lexeme("text", loc, { value: body }) : null, end];
|
|
765
638
|
}
|
|
766
639
|
function peg$f16() {
|
|
640
|
+
return completionMode;
|
|
641
|
+
}
|
|
642
|
+
function peg$f17(body) {
|
|
643
|
+
return lexeme("text", location(), { value: body });
|
|
644
|
+
}
|
|
645
|
+
function peg$f18() {
|
|
767
646
|
return offset();
|
|
768
647
|
}
|
|
769
|
-
function peg$
|
|
648
|
+
function peg$f19(value) {
|
|
770
649
|
return lexeme("text", location(), { value });
|
|
771
650
|
}
|
|
772
|
-
function peg$
|
|
651
|
+
function peg$f20(value) {
|
|
773
652
|
const node = lexeme("text", location(), { value });
|
|
774
653
|
node.comment = true;
|
|
775
654
|
return node;
|
|
776
655
|
}
|
|
777
|
-
function peg$
|
|
656
|
+
function peg$f21(bs) {
|
|
778
657
|
return bs.length % 2 === 1;
|
|
779
658
|
}
|
|
780
|
-
function peg$
|
|
659
|
+
function peg$f22(bs, c) {
|
|
781
660
|
return c;
|
|
782
661
|
}
|
|
783
|
-
function peg$
|
|
662
|
+
function peg$f23(bs, brace) {
|
|
784
663
|
const loc = location();
|
|
785
664
|
const next = input.charAt(loc.end.offset);
|
|
786
665
|
if (textMode) {
|
|
@@ -797,48 +676,48 @@ function peg$parse(input, options) {
|
|
|
797
676
|
escaped.escape = true;
|
|
798
677
|
return bs.length > 1 ? [before, escaped] : escaped;
|
|
799
678
|
}
|
|
800
|
-
function peg$
|
|
679
|
+
function peg$f24() {
|
|
801
680
|
return lexeme("text", location(), { value: LB });
|
|
802
681
|
}
|
|
803
|
-
function peg$
|
|
682
|
+
function peg$f25() {
|
|
804
683
|
return !textMode;
|
|
805
684
|
}
|
|
806
|
-
function peg$
|
|
685
|
+
function peg$f26() {
|
|
807
686
|
return lexeme("text", location(), { value: "<" });
|
|
808
687
|
}
|
|
809
|
-
function peg$
|
|
688
|
+
function peg$f27() {
|
|
810
689
|
return lexeme("text", location(), { value: "[" });
|
|
811
690
|
}
|
|
812
|
-
function peg$
|
|
691
|
+
function peg$f28() {
|
|
813
692
|
return !textMode;
|
|
814
693
|
}
|
|
815
|
-
function peg$
|
|
694
|
+
function peg$f29(ss, s, at, inner) {
|
|
816
695
|
const link = lexeme("link", location(), parseLink(inner, at, (separator) => linkSeparatorIndex(inner, at, separator)));
|
|
817
696
|
link.selectorSpan = selectorSpan(s, ss, at);
|
|
818
697
|
return withSelectors(link, s);
|
|
819
698
|
}
|
|
820
|
-
function peg$
|
|
699
|
+
function peg$f30() {
|
|
821
700
|
return !textMode;
|
|
822
701
|
}
|
|
823
|
-
function peg$
|
|
702
|
+
function peg$f31() {
|
|
824
703
|
fail("Unclosed link: [[ without ]]", location(), "unclosed-link");
|
|
825
704
|
}
|
|
826
|
-
function peg$
|
|
705
|
+
function peg$f32(parts) {
|
|
827
706
|
return selectorsOf(parts);
|
|
828
707
|
}
|
|
829
|
-
function peg$
|
|
708
|
+
function peg$f33() {
|
|
830
709
|
return NO_SELECTORS;
|
|
831
710
|
}
|
|
832
|
-
function peg$
|
|
711
|
+
function peg$f34(s, end) {
|
|
833
712
|
return {
|
|
834
713
|
...s,
|
|
835
714
|
end
|
|
836
715
|
};
|
|
837
716
|
}
|
|
838
|
-
function peg$
|
|
717
|
+
function peg$f35(prefix, name) {
|
|
839
718
|
return [prefix, name];
|
|
840
719
|
}
|
|
841
|
-
function peg$
|
|
720
|
+
function peg$f36(ss, s, sigil, nameStart, name) {
|
|
842
721
|
const variable = lexeme("variable", location(), {
|
|
843
722
|
name,
|
|
844
723
|
nameStart,
|
|
@@ -848,7 +727,7 @@ function peg$parse(input, options) {
|
|
|
848
727
|
variable.selectorSpan = selectorSpan(s, ss, nameStart - 1);
|
|
849
728
|
return withSelectors(variable, s);
|
|
850
729
|
}
|
|
851
|
-
function peg$
|
|
730
|
+
function peg$f37(ss, s, after, expression) {
|
|
852
731
|
const node = lexeme("expression", location(), {
|
|
853
732
|
expression,
|
|
854
733
|
expressionStart: after,
|
|
@@ -857,28 +736,33 @@ function peg$parse(input, options) {
|
|
|
857
736
|
node.selectorSpan = selectorSpan(s, ss, after);
|
|
858
737
|
return withSelectors(node, s);
|
|
859
738
|
}
|
|
860
|
-
function peg$
|
|
739
|
+
function peg$f38() {
|
|
861
740
|
fail("Unclosed {" + input.substr(location().end.offset, 1) + "…: no } ends it", location(), "unclosed-expression");
|
|
862
741
|
}
|
|
863
|
-
function peg$
|
|
864
|
-
|
|
742
|
+
function peg$f39(start) {
|
|
743
|
+
const end = hooks.closeBrace(input, start, start);
|
|
744
|
+
return skipTo(end < 0 && completionMode ? input.length : end);
|
|
865
745
|
}
|
|
866
|
-
function peg$
|
|
746
|
+
function peg$f40(start) {
|
|
867
747
|
return skipEnd - offset();
|
|
868
748
|
}
|
|
869
|
-
function peg$
|
|
749
|
+
function peg$f41(start, code) {
|
|
870
750
|
return code;
|
|
871
751
|
}
|
|
872
|
-
function peg$
|
|
873
|
-
return
|
|
752
|
+
function peg$f42() {
|
|
753
|
+
return completionMode;
|
|
874
754
|
}
|
|
875
|
-
function peg$
|
|
755
|
+
function peg$f43(ss, s, start, close, name, nameEnd) {
|
|
756
|
+
const end = hooks.closeBrace(input, nameEnd, start);
|
|
757
|
+
return skipTo(end < 0 && completionMode ? input.length : end);
|
|
758
|
+
}
|
|
759
|
+
function peg$f44(ss, s, start, close, name, nameEnd) {
|
|
876
760
|
return skipEnd - offset();
|
|
877
761
|
}
|
|
878
|
-
function peg$
|
|
762
|
+
function peg$f45(ss, s, start, close, name, nameEnd, args) {
|
|
879
763
|
return args;
|
|
880
764
|
}
|
|
881
|
-
function peg$
|
|
765
|
+
function peg$f46(ss, s, start, close, name, nameEnd, tail) {
|
|
882
766
|
const loc = location();
|
|
883
767
|
const lower = name.toLowerCase();
|
|
884
768
|
const tag = lexeme("macro", loc, {
|
|
@@ -891,7 +775,7 @@ function peg$parse(input, options) {
|
|
|
891
775
|
tag.nameEnd = nameEnd;
|
|
892
776
|
tag.selectorSpan = selectorSpan(s, ss, start);
|
|
893
777
|
if (tail === null) fail("Unclosed {" + (close ? "/" : "") + name + "…: no } ends the macro", loc, "unclosed-macro");
|
|
894
|
-
tag.rawArgs = tail.trim();
|
|
778
|
+
tag.rawArgs = completionMode ? tail.trimStart() : tail.trim();
|
|
895
779
|
tag.argsStart = tag.rawArgs ? nameEnd + tail.length - tail.trimStart().length : nameEnd;
|
|
896
780
|
tag.argsEnd = tag.argsStart + tag.rawArgs.length;
|
|
897
781
|
if (close) {
|
|
@@ -904,19 +788,19 @@ function peg$parse(input, options) {
|
|
|
904
788
|
}
|
|
905
789
|
return tag;
|
|
906
790
|
}
|
|
907
|
-
function peg$
|
|
791
|
+
function peg$f47(s) {
|
|
908
792
|
fail("A closing tag starts with a letter after {/", location(), "invalid-closer");
|
|
909
793
|
}
|
|
910
|
-
function peg$
|
|
794
|
+
function peg$f48(value) {
|
|
911
795
|
return EMAIL_AUTOLINK.test(value);
|
|
912
796
|
}
|
|
913
|
-
function peg$
|
|
797
|
+
function peg$f49(value) {
|
|
914
798
|
return lexeme("text", location(), { value });
|
|
915
799
|
}
|
|
916
|
-
function peg$
|
|
800
|
+
function peg$f50(value) {
|
|
917
801
|
return lexeme("text", location(), { value });
|
|
918
802
|
}
|
|
919
|
-
function peg$
|
|
803
|
+
function peg$f51(tagStart, tag, list, slash) {
|
|
920
804
|
const lower = tag.toLowerCase();
|
|
921
805
|
return lexeme("html", location(), {
|
|
922
806
|
tag,
|
|
@@ -929,7 +813,7 @@ function peg$parse(input, options) {
|
|
|
929
813
|
isSelfClose: !!slash || VOID_TAGS.has(lower)
|
|
930
814
|
});
|
|
931
815
|
}
|
|
932
|
-
function peg$
|
|
816
|
+
function peg$f52(tag, bad) {
|
|
933
817
|
const c = input.charAt(bad);
|
|
934
818
|
if (!c) fail("Unclosed tag <" + tag + ": no > ends it (write < for a < that starts no tag)", location(), "unclosed-tag");
|
|
935
819
|
const at = {
|
|
@@ -947,7 +831,7 @@ function peg$parse(input, options) {
|
|
|
947
831
|
};
|
|
948
832
|
fail("Unexpected " + JSON.stringify(c) + " in the tag <" + tag + ">: expected an attribute, or > to end the tag", at, "unexpected-character");
|
|
949
833
|
}
|
|
950
|
-
function peg$
|
|
834
|
+
function peg$f53(tagStart, tag) {
|
|
951
835
|
return lexeme("html", location(), {
|
|
952
836
|
tag,
|
|
953
837
|
lower: tag.toLowerCase(),
|
|
@@ -959,14 +843,14 @@ function peg$parse(input, options) {
|
|
|
959
843
|
isSelfClose: false
|
|
960
844
|
});
|
|
961
845
|
}
|
|
962
|
-
function peg$
|
|
846
|
+
function peg$f54(nameStart, name) {
|
|
963
847
|
attrCode = hooks.isCodeAttribute(name);
|
|
964
848
|
return true;
|
|
965
849
|
}
|
|
966
|
-
function peg$
|
|
850
|
+
function peg$f55(nameStart, name, v) {
|
|
967
851
|
return v;
|
|
968
852
|
}
|
|
969
|
-
function peg$
|
|
853
|
+
function peg$f56(nameStart, name, value) {
|
|
970
854
|
const attribute = {
|
|
971
855
|
name,
|
|
972
856
|
value: value ? value.value : "",
|
|
@@ -980,7 +864,7 @@ function peg$parse(input, options) {
|
|
|
980
864
|
}
|
|
981
865
|
return attribute;
|
|
982
866
|
}
|
|
983
|
-
function peg$
|
|
867
|
+
function peg$f57(start, value, end) {
|
|
984
868
|
return {
|
|
985
869
|
value,
|
|
986
870
|
start,
|
|
@@ -988,7 +872,7 @@ function peg$parse(input, options) {
|
|
|
988
872
|
quote: "\""
|
|
989
873
|
};
|
|
990
874
|
}
|
|
991
|
-
function peg$
|
|
875
|
+
function peg$f58(start, value, end) {
|
|
992
876
|
return {
|
|
993
877
|
value,
|
|
994
878
|
start,
|
|
@@ -996,35 +880,36 @@ function peg$parse(input, options) {
|
|
|
996
880
|
quote: "'"
|
|
997
881
|
};
|
|
998
882
|
}
|
|
999
|
-
function peg$
|
|
883
|
+
function peg$f59(q) {
|
|
1000
884
|
fail("Unclosed attribute value: the " + q + " here has no closing " + q, location(), "unclosed-attribute");
|
|
1001
885
|
}
|
|
1002
|
-
function peg$
|
|
886
|
+
function peg$f60(start, value, end) {
|
|
1003
887
|
return {
|
|
1004
888
|
value,
|
|
1005
889
|
start,
|
|
1006
890
|
end
|
|
1007
891
|
};
|
|
1008
892
|
}
|
|
1009
|
-
function peg$
|
|
893
|
+
function peg$f61() {
|
|
1010
894
|
return !attrCode;
|
|
1011
895
|
}
|
|
1012
|
-
function peg$
|
|
896
|
+
function peg$f62(bs) {
|
|
1013
897
|
return bs.length % 2 === 1;
|
|
1014
898
|
}
|
|
1015
|
-
function peg$
|
|
899
|
+
function peg$f63() {
|
|
1016
900
|
return !attrCode;
|
|
1017
901
|
}
|
|
1018
|
-
function peg$
|
|
1019
|
-
|
|
902
|
+
function peg$f64(start, nameEnd) {
|
|
903
|
+
const end = hooks.closeBrace(input, nameEnd, start);
|
|
904
|
+
return skipTo(end < 0 && completionMode ? input.length : end);
|
|
1020
905
|
}
|
|
1021
|
-
function peg$
|
|
906
|
+
function peg$f65(start, nameEnd) {
|
|
1022
907
|
return skipEnd - offset();
|
|
1023
908
|
}
|
|
1024
|
-
function peg$
|
|
909
|
+
function peg$f66() {
|
|
1025
910
|
return !attrCode;
|
|
1026
911
|
}
|
|
1027
|
-
function peg$
|
|
912
|
+
function peg$f67() {
|
|
1028
913
|
return attrCode;
|
|
1029
914
|
}
|
|
1030
915
|
let peg$currPos = options.peg$currPos | 0;
|
|
@@ -1363,6 +1248,40 @@ function peg$parse(input, options) {
|
|
|
1363
1248
|
peg$currPos = s0;
|
|
1364
1249
|
s0 = peg$FAILED;
|
|
1365
1250
|
}
|
|
1251
|
+
if (s0 === peg$FAILED) {
|
|
1252
|
+
s0 = peg$currPos;
|
|
1253
|
+
peg$savedPos = peg$currPos;
|
|
1254
|
+
s1 = peg$f16();
|
|
1255
|
+
if (s1) s1 = void 0;
|
|
1256
|
+
else s1 = peg$FAILED;
|
|
1257
|
+
if (s1 !== peg$FAILED) {
|
|
1258
|
+
s2 = peg$currPos;
|
|
1259
|
+
s3 = [];
|
|
1260
|
+
if (input.length > peg$currPos) {
|
|
1261
|
+
s4 = input.charAt(peg$currPos);
|
|
1262
|
+
peg$currPos++;
|
|
1263
|
+
} else {
|
|
1264
|
+
s4 = peg$FAILED;
|
|
1265
|
+
if (peg$silentFails === 0) peg$fail(peg$e0);
|
|
1266
|
+
}
|
|
1267
|
+
while (s4 !== peg$FAILED) {
|
|
1268
|
+
s3.push(s4);
|
|
1269
|
+
if (input.length > peg$currPos) {
|
|
1270
|
+
s4 = input.charAt(peg$currPos);
|
|
1271
|
+
peg$currPos++;
|
|
1272
|
+
} else {
|
|
1273
|
+
s4 = peg$FAILED;
|
|
1274
|
+
if (peg$silentFails === 0) peg$fail(peg$e0);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
s2 = input.substring(s2, peg$currPos);
|
|
1278
|
+
peg$savedPos = s0;
|
|
1279
|
+
s0 = peg$f17(s2);
|
|
1280
|
+
} else {
|
|
1281
|
+
peg$currPos = s0;
|
|
1282
|
+
s0 = peg$FAILED;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1366
1285
|
return s0;
|
|
1367
1286
|
}
|
|
1368
1287
|
function peg$parseHere() {
|
|
@@ -1370,7 +1289,7 @@ function peg$parse(input, options) {
|
|
|
1370
1289
|
s0 = peg$currPos;
|
|
1371
1290
|
s1 = "";
|
|
1372
1291
|
peg$savedPos = s0;
|
|
1373
|
-
s1 = peg$
|
|
1292
|
+
s1 = peg$f18();
|
|
1374
1293
|
s0 = s1;
|
|
1375
1294
|
return s0;
|
|
1376
1295
|
}
|
|
@@ -1399,7 +1318,7 @@ function peg$parse(input, options) {
|
|
|
1399
1318
|
else s1 = s2;
|
|
1400
1319
|
if (s1 !== peg$FAILED) {
|
|
1401
1320
|
peg$savedPos = s0;
|
|
1402
|
-
s1 = peg$
|
|
1321
|
+
s1 = peg$f19(s1);
|
|
1403
1322
|
}
|
|
1404
1323
|
s0 = s1;
|
|
1405
1324
|
return s0;
|
|
@@ -1515,6 +1434,7 @@ function peg$parse(input, options) {
|
|
|
1515
1434
|
s6 = peg$FAILED;
|
|
1516
1435
|
if (peg$silentFails === 0) peg$fail(peg$e5);
|
|
1517
1436
|
}
|
|
1437
|
+
if (s6 === peg$FAILED) s6 = peg$parseOpenEnd();
|
|
1518
1438
|
if (s6 !== peg$FAILED) {
|
|
1519
1439
|
s5 = [s5, s6];
|
|
1520
1440
|
s4 = s5;
|
|
@@ -1539,7 +1459,7 @@ function peg$parse(input, options) {
|
|
|
1539
1459
|
else s1 = s2;
|
|
1540
1460
|
if (s1 !== peg$FAILED) {
|
|
1541
1461
|
peg$savedPos = s0;
|
|
1542
|
-
s1 = peg$
|
|
1462
|
+
s1 = peg$f20(s1);
|
|
1543
1463
|
}
|
|
1544
1464
|
s0 = s1;
|
|
1545
1465
|
return s0;
|
|
@@ -1572,7 +1492,7 @@ function peg$parse(input, options) {
|
|
|
1572
1492
|
if (s1 !== peg$FAILED) {
|
|
1573
1493
|
s2 = peg$currPos;
|
|
1574
1494
|
peg$savedPos = peg$currPos;
|
|
1575
|
-
s3 = peg$
|
|
1495
|
+
s3 = peg$f21(s1);
|
|
1576
1496
|
if (s3) s3 = void 0;
|
|
1577
1497
|
else s3 = peg$FAILED;
|
|
1578
1498
|
if (s3 !== peg$FAILED) {
|
|
@@ -1584,7 +1504,7 @@ function peg$parse(input, options) {
|
|
|
1584
1504
|
}
|
|
1585
1505
|
if (s4 !== peg$FAILED) {
|
|
1586
1506
|
peg$savedPos = s2;
|
|
1587
|
-
s2 = peg$
|
|
1507
|
+
s2 = peg$f22(s1, s4);
|
|
1588
1508
|
} else {
|
|
1589
1509
|
peg$currPos = s2;
|
|
1590
1510
|
s2 = peg$FAILED;
|
|
@@ -1595,7 +1515,7 @@ function peg$parse(input, options) {
|
|
|
1595
1515
|
}
|
|
1596
1516
|
if (s2 === peg$FAILED) s2 = null;
|
|
1597
1517
|
peg$savedPos = s0;
|
|
1598
|
-
s0 = peg$
|
|
1518
|
+
s0 = peg$f23(s1, s2);
|
|
1599
1519
|
} else {
|
|
1600
1520
|
peg$currPos = s0;
|
|
1601
1521
|
s0 = peg$FAILED;
|
|
@@ -1643,7 +1563,7 @@ function peg$parse(input, options) {
|
|
|
1643
1563
|
}
|
|
1644
1564
|
if (s2 !== peg$FAILED) {
|
|
1645
1565
|
peg$savedPos = s0;
|
|
1646
|
-
s0 = peg$
|
|
1566
|
+
s0 = peg$f24();
|
|
1647
1567
|
} else {
|
|
1648
1568
|
peg$currPos = s0;
|
|
1649
1569
|
s0 = peg$FAILED;
|
|
@@ -1658,7 +1578,7 @@ function peg$parse(input, options) {
|
|
|
1658
1578
|
peg$silentFails++;
|
|
1659
1579
|
s2 = peg$currPos;
|
|
1660
1580
|
peg$savedPos = peg$currPos;
|
|
1661
|
-
s3 = peg$
|
|
1581
|
+
s3 = peg$f25();
|
|
1662
1582
|
if (s3) s3 = void 0;
|
|
1663
1583
|
else s3 = peg$FAILED;
|
|
1664
1584
|
if (s3 !== peg$FAILED) {
|
|
@@ -1690,7 +1610,7 @@ function peg$parse(input, options) {
|
|
|
1690
1610
|
}
|
|
1691
1611
|
if (s2 !== peg$FAILED) {
|
|
1692
1612
|
peg$savedPos = s0;
|
|
1693
|
-
s0 = peg$
|
|
1613
|
+
s0 = peg$f26();
|
|
1694
1614
|
} else {
|
|
1695
1615
|
peg$currPos = s0;
|
|
1696
1616
|
s0 = peg$FAILED;
|
|
@@ -1710,7 +1630,7 @@ function peg$parse(input, options) {
|
|
|
1710
1630
|
}
|
|
1711
1631
|
if (s1 !== peg$FAILED) {
|
|
1712
1632
|
peg$savedPos = s0;
|
|
1713
|
-
s1 = peg$
|
|
1633
|
+
s1 = peg$f27();
|
|
1714
1634
|
}
|
|
1715
1635
|
s0 = s1;
|
|
1716
1636
|
}
|
|
@@ -1721,7 +1641,7 @@ function peg$parse(input, options) {
|
|
|
1721
1641
|
let s0, s1, s2, s3, s4, s5, s6, s7;
|
|
1722
1642
|
s0 = peg$currPos;
|
|
1723
1643
|
peg$savedPos = peg$currPos;
|
|
1724
|
-
s1 = peg$
|
|
1644
|
+
s1 = peg$f28();
|
|
1725
1645
|
if (s1) s1 = void 0;
|
|
1726
1646
|
else s1 = peg$FAILED;
|
|
1727
1647
|
if (s1 !== peg$FAILED) {
|
|
@@ -1747,9 +1667,10 @@ function peg$parse(input, options) {
|
|
|
1747
1667
|
s7 = peg$FAILED;
|
|
1748
1668
|
if (peg$silentFails === 0) peg$fail(peg$e13);
|
|
1749
1669
|
}
|
|
1670
|
+
if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
|
|
1750
1671
|
if (s7 !== peg$FAILED) {
|
|
1751
1672
|
peg$savedPos = s0;
|
|
1752
|
-
s0 = peg$
|
|
1673
|
+
s0 = peg$f29(s3, s4, s5, s6);
|
|
1753
1674
|
} else {
|
|
1754
1675
|
peg$currPos = s0;
|
|
1755
1676
|
s0 = peg$FAILED;
|
|
@@ -1769,7 +1690,7 @@ function peg$parse(input, options) {
|
|
|
1769
1690
|
if (s0 === peg$FAILED) {
|
|
1770
1691
|
s0 = peg$currPos;
|
|
1771
1692
|
peg$savedPos = peg$currPos;
|
|
1772
|
-
s1 = peg$
|
|
1693
|
+
s1 = peg$f30();
|
|
1773
1694
|
if (s1) s1 = void 0;
|
|
1774
1695
|
else s1 = peg$FAILED;
|
|
1775
1696
|
if (s1 !== peg$FAILED) {
|
|
@@ -1782,7 +1703,7 @@ function peg$parse(input, options) {
|
|
|
1782
1703
|
}
|
|
1783
1704
|
if (s2 !== peg$FAILED) {
|
|
1784
1705
|
peg$savedPos = s0;
|
|
1785
|
-
s0 = peg$
|
|
1706
|
+
s0 = peg$f31();
|
|
1786
1707
|
} else {
|
|
1787
1708
|
peg$currPos = s0;
|
|
1788
1709
|
s0 = peg$FAILED;
|
|
@@ -1910,7 +1831,7 @@ function peg$parse(input, options) {
|
|
|
1910
1831
|
}
|
|
1911
1832
|
if (s2 === peg$FAILED) s2 = null;
|
|
1912
1833
|
peg$savedPos = s0;
|
|
1913
|
-
s0 = peg$
|
|
1834
|
+
s0 = peg$f32(s1);
|
|
1914
1835
|
} else {
|
|
1915
1836
|
peg$currPos = s0;
|
|
1916
1837
|
s0 = peg$FAILED;
|
|
@@ -1919,7 +1840,7 @@ function peg$parse(input, options) {
|
|
|
1919
1840
|
s0 = peg$currPos;
|
|
1920
1841
|
s1 = "";
|
|
1921
1842
|
peg$savedPos = s0;
|
|
1922
|
-
s1 = peg$
|
|
1843
|
+
s1 = peg$f33();
|
|
1923
1844
|
s0 = s1;
|
|
1924
1845
|
}
|
|
1925
1846
|
return s0;
|
|
@@ -1949,7 +1870,7 @@ function peg$parse(input, options) {
|
|
|
1949
1870
|
}
|
|
1950
1871
|
}
|
|
1951
1872
|
peg$savedPos = s0;
|
|
1952
|
-
s0 = peg$
|
|
1873
|
+
s0 = peg$f34(s1, s2);
|
|
1953
1874
|
} else {
|
|
1954
1875
|
peg$currPos = s0;
|
|
1955
1876
|
s0 = peg$FAILED;
|
|
@@ -1975,7 +1896,7 @@ function peg$parse(input, options) {
|
|
|
1975
1896
|
}
|
|
1976
1897
|
s2 = input.substring(s2, peg$currPos);
|
|
1977
1898
|
peg$savedPos = s0;
|
|
1978
|
-
s0 = peg$
|
|
1899
|
+
s0 = peg$f35(s1, s2);
|
|
1979
1900
|
} else {
|
|
1980
1901
|
peg$currPos = s0;
|
|
1981
1902
|
s0 = peg$FAILED;
|
|
@@ -2093,16 +2014,10 @@ function peg$parse(input, options) {
|
|
|
2093
2014
|
}
|
|
2094
2015
|
}
|
|
2095
2016
|
s6 = input.substring(s6, peg$currPos);
|
|
2096
|
-
|
|
2097
|
-
s7 = peg$c11;
|
|
2098
|
-
peg$currPos++;
|
|
2099
|
-
} else {
|
|
2100
|
-
s7 = peg$FAILED;
|
|
2101
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
2102
|
-
}
|
|
2017
|
+
s7 = peg$parseBraceEnd();
|
|
2103
2018
|
if (s7 !== peg$FAILED) {
|
|
2104
2019
|
peg$savedPos = s0;
|
|
2105
|
-
s0 = peg$
|
|
2020
|
+
s0 = peg$f36(s2, s3, s4, s5, s6);
|
|
2106
2021
|
} else {
|
|
2107
2022
|
peg$currPos = s0;
|
|
2108
2023
|
s0 = peg$FAILED;
|
|
@@ -2149,16 +2064,10 @@ function peg$parse(input, options) {
|
|
|
2149
2064
|
if (s5 !== peg$FAILED) {
|
|
2150
2065
|
s6 = peg$parseCodeToBrace();
|
|
2151
2066
|
if (s6 !== peg$FAILED) {
|
|
2152
|
-
|
|
2153
|
-
s7 = peg$c11;
|
|
2154
|
-
peg$currPos++;
|
|
2155
|
-
} else {
|
|
2156
|
-
s7 = peg$FAILED;
|
|
2157
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
2158
|
-
}
|
|
2067
|
+
s7 = peg$parseBraceEnd();
|
|
2159
2068
|
if (s7 !== peg$FAILED) {
|
|
2160
2069
|
peg$savedPos = s0;
|
|
2161
|
-
s0 = peg$
|
|
2070
|
+
s0 = peg$f37(s2, s3, s4, s6);
|
|
2162
2071
|
} else {
|
|
2163
2072
|
peg$currPos = s0;
|
|
2164
2073
|
s0 = peg$FAILED;
|
|
@@ -2206,7 +2115,7 @@ function peg$parse(input, options) {
|
|
|
2206
2115
|
} else s3 = peg$FAILED;
|
|
2207
2116
|
if (s3 !== peg$FAILED) {
|
|
2208
2117
|
peg$savedPos = s0;
|
|
2209
|
-
s0 = peg$
|
|
2118
|
+
s0 = peg$f38();
|
|
2210
2119
|
} else {
|
|
2211
2120
|
peg$currPos = s0;
|
|
2212
2121
|
s0 = peg$FAILED;
|
|
@@ -2228,12 +2137,12 @@ function peg$parse(input, options) {
|
|
|
2228
2137
|
s0 = peg$currPos;
|
|
2229
2138
|
s1 = peg$parseHere();
|
|
2230
2139
|
peg$savedPos = peg$currPos;
|
|
2231
|
-
s2 = peg$
|
|
2140
|
+
s2 = peg$f39(s1);
|
|
2232
2141
|
if (s2) s2 = void 0;
|
|
2233
2142
|
else s2 = peg$FAILED;
|
|
2234
2143
|
if (s2 !== peg$FAILED) {
|
|
2235
2144
|
s3 = peg$currPos;
|
|
2236
|
-
s4 = peg$
|
|
2145
|
+
s4 = peg$f40(s1);
|
|
2237
2146
|
s5 = peg$currPos;
|
|
2238
2147
|
s6 = [];
|
|
2239
2148
|
if (s6.length >= (s4 | 0)) s7 = peg$FAILED;
|
|
@@ -2264,7 +2173,7 @@ function peg$parse(input, options) {
|
|
|
2264
2173
|
else s3 = s4;
|
|
2265
2174
|
if (s3 !== peg$FAILED) {
|
|
2266
2175
|
peg$savedPos = s0;
|
|
2267
|
-
s0 = peg$
|
|
2176
|
+
s0 = peg$f41(s1, s3);
|
|
2268
2177
|
} else {
|
|
2269
2178
|
peg$currPos = s0;
|
|
2270
2179
|
s0 = peg$FAILED;
|
|
@@ -2275,6 +2184,54 @@ function peg$parse(input, options) {
|
|
|
2275
2184
|
}
|
|
2276
2185
|
return s0;
|
|
2277
2186
|
}
|
|
2187
|
+
function peg$parseOpenEnd() {
|
|
2188
|
+
let s0, s1, s2, s3;
|
|
2189
|
+
s0 = peg$currPos;
|
|
2190
|
+
peg$savedPos = peg$currPos;
|
|
2191
|
+
s1 = peg$f42();
|
|
2192
|
+
if (s1) s1 = void 0;
|
|
2193
|
+
else s1 = peg$FAILED;
|
|
2194
|
+
if (s1 !== peg$FAILED) {
|
|
2195
|
+
s2 = peg$currPos;
|
|
2196
|
+
peg$silentFails++;
|
|
2197
|
+
if (input.length > peg$currPos) {
|
|
2198
|
+
s3 = input.charAt(peg$currPos);
|
|
2199
|
+
peg$currPos++;
|
|
2200
|
+
} else {
|
|
2201
|
+
s3 = peg$FAILED;
|
|
2202
|
+
if (peg$silentFails === 0) peg$fail(peg$e0);
|
|
2203
|
+
}
|
|
2204
|
+
peg$silentFails--;
|
|
2205
|
+
if (s3 === peg$FAILED) s2 = void 0;
|
|
2206
|
+
else {
|
|
2207
|
+
peg$currPos = s2;
|
|
2208
|
+
s2 = peg$FAILED;
|
|
2209
|
+
}
|
|
2210
|
+
if (s2 !== peg$FAILED) {
|
|
2211
|
+
s1 = [s1, s2];
|
|
2212
|
+
s0 = s1;
|
|
2213
|
+
} else {
|
|
2214
|
+
peg$currPos = s0;
|
|
2215
|
+
s0 = peg$FAILED;
|
|
2216
|
+
}
|
|
2217
|
+
} else {
|
|
2218
|
+
peg$currPos = s0;
|
|
2219
|
+
s0 = peg$FAILED;
|
|
2220
|
+
}
|
|
2221
|
+
return s0;
|
|
2222
|
+
}
|
|
2223
|
+
function peg$parseBraceEnd() {
|
|
2224
|
+
let s0;
|
|
2225
|
+
if (input.charCodeAt(peg$currPos) === 125) {
|
|
2226
|
+
s0 = peg$c11;
|
|
2227
|
+
peg$currPos++;
|
|
2228
|
+
} else {
|
|
2229
|
+
s0 = peg$FAILED;
|
|
2230
|
+
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
2231
|
+
}
|
|
2232
|
+
if (s0 === peg$FAILED) s0 = peg$parseOpenEnd();
|
|
2233
|
+
return s0;
|
|
2234
|
+
}
|
|
2278
2235
|
function peg$parseMacroTag() {
|
|
2279
2236
|
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14;
|
|
2280
2237
|
s0 = peg$currPos;
|
|
@@ -2303,12 +2260,12 @@ function peg$parse(input, options) {
|
|
|
2303
2260
|
s7 = peg$parseHere();
|
|
2304
2261
|
s8 = peg$currPos;
|
|
2305
2262
|
peg$savedPos = peg$currPos;
|
|
2306
|
-
s9 = peg$
|
|
2263
|
+
s9 = peg$f43(s2, s3, s4, s5, s6, s7);
|
|
2307
2264
|
if (s9) s9 = void 0;
|
|
2308
2265
|
else s9 = peg$FAILED;
|
|
2309
2266
|
if (s9 !== peg$FAILED) {
|
|
2310
2267
|
s10 = peg$currPos;
|
|
2311
|
-
s11 = peg$
|
|
2268
|
+
s11 = peg$f44(s2, s3, s4, s5, s6, s7);
|
|
2312
2269
|
s12 = peg$currPos;
|
|
2313
2270
|
s13 = [];
|
|
2314
2271
|
if (s13.length >= (s11 | 0)) s14 = peg$FAILED;
|
|
@@ -2338,16 +2295,10 @@ function peg$parse(input, options) {
|
|
|
2338
2295
|
if (s11 !== peg$FAILED) s10 = input.substring(s10, peg$currPos);
|
|
2339
2296
|
else s10 = s11;
|
|
2340
2297
|
if (s10 !== peg$FAILED) {
|
|
2341
|
-
|
|
2342
|
-
s11 = peg$c11;
|
|
2343
|
-
peg$currPos++;
|
|
2344
|
-
} else {
|
|
2345
|
-
s11 = peg$FAILED;
|
|
2346
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
2347
|
-
}
|
|
2298
|
+
s11 = peg$parseBraceEnd();
|
|
2348
2299
|
if (s11 !== peg$FAILED) {
|
|
2349
2300
|
peg$savedPos = s8;
|
|
2350
|
-
s8 = peg$
|
|
2301
|
+
s8 = peg$f45(s2, s3, s4, s5, s6, s7, s10);
|
|
2351
2302
|
} else {
|
|
2352
2303
|
peg$currPos = s8;
|
|
2353
2304
|
s8 = peg$FAILED;
|
|
@@ -2362,7 +2313,7 @@ function peg$parse(input, options) {
|
|
|
2362
2313
|
}
|
|
2363
2314
|
if (s8 === peg$FAILED) s8 = null;
|
|
2364
2315
|
peg$savedPos = s0;
|
|
2365
|
-
s0 = peg$
|
|
2316
|
+
s0 = peg$f46(s2, s3, s4, s5, s6, s7, s8);
|
|
2366
2317
|
} else {
|
|
2367
2318
|
peg$currPos = s0;
|
|
2368
2319
|
s0 = peg$FAILED;
|
|
@@ -2396,7 +2347,7 @@ function peg$parse(input, options) {
|
|
|
2396
2347
|
}
|
|
2397
2348
|
if (s3 !== peg$FAILED) {
|
|
2398
2349
|
peg$savedPos = s0;
|
|
2399
|
-
s0 = peg$
|
|
2350
|
+
s0 = peg$f47(s2);
|
|
2400
2351
|
} else {
|
|
2401
2352
|
peg$currPos = s0;
|
|
2402
2353
|
s0 = peg$FAILED;
|
|
@@ -2546,12 +2497,12 @@ function peg$parse(input, options) {
|
|
|
2546
2497
|
else s1 = s2;
|
|
2547
2498
|
if (s1 !== peg$FAILED) {
|
|
2548
2499
|
peg$savedPos = peg$currPos;
|
|
2549
|
-
s2 = peg$
|
|
2500
|
+
s2 = peg$f48(s1);
|
|
2550
2501
|
if (s2) s2 = void 0;
|
|
2551
2502
|
else s2 = peg$FAILED;
|
|
2552
2503
|
if (s2 !== peg$FAILED) {
|
|
2553
2504
|
peg$savedPos = s0;
|
|
2554
|
-
s0 = peg$
|
|
2505
|
+
s0 = peg$f49(s1);
|
|
2555
2506
|
} else {
|
|
2556
2507
|
peg$currPos = s0;
|
|
2557
2508
|
s0 = peg$FAILED;
|
|
@@ -2728,7 +2679,7 @@ function peg$parse(input, options) {
|
|
|
2728
2679
|
else s1 = s2;
|
|
2729
2680
|
if (s1 !== peg$FAILED) {
|
|
2730
2681
|
peg$savedPos = s0;
|
|
2731
|
-
s1 = peg$
|
|
2682
|
+
s1 = peg$f50(s1);
|
|
2732
2683
|
}
|
|
2733
2684
|
s0 = s1;
|
|
2734
2685
|
return s0;
|
|
@@ -2769,9 +2720,10 @@ function peg$parse(input, options) {
|
|
|
2769
2720
|
s7 = peg$FAILED;
|
|
2770
2721
|
if (peg$silentFails === 0) peg$fail(peg$e3);
|
|
2771
2722
|
}
|
|
2723
|
+
if (s7 === peg$FAILED) s7 = peg$parseOpenEnd();
|
|
2772
2724
|
if (s7 !== peg$FAILED) {
|
|
2773
2725
|
peg$savedPos = s0;
|
|
2774
|
-
s0 = peg$
|
|
2726
|
+
s0 = peg$f51(s2, s3, s4, s6);
|
|
2775
2727
|
} else {
|
|
2776
2728
|
peg$currPos = s0;
|
|
2777
2729
|
s0 = peg$FAILED;
|
|
@@ -2836,7 +2788,7 @@ function peg$parse(input, options) {
|
|
|
2836
2788
|
s5 = peg$parse_();
|
|
2837
2789
|
s6 = peg$parseHere();
|
|
2838
2790
|
peg$savedPos = s0;
|
|
2839
|
-
s0 = peg$
|
|
2791
|
+
s0 = peg$f52(s2, s6);
|
|
2840
2792
|
} else {
|
|
2841
2793
|
peg$currPos = s0;
|
|
2842
2794
|
s0 = peg$FAILED;
|
|
@@ -2876,7 +2828,7 @@ function peg$parse(input, options) {
|
|
|
2876
2828
|
}
|
|
2877
2829
|
if (s5 !== peg$FAILED) {
|
|
2878
2830
|
peg$savedPos = s0;
|
|
2879
|
-
s0 = peg$
|
|
2831
|
+
s0 = peg$f53(s2, s3);
|
|
2880
2832
|
} else {
|
|
2881
2833
|
peg$currPos = s0;
|
|
2882
2834
|
s0 = peg$FAILED;
|
|
@@ -3011,7 +2963,7 @@ function peg$parse(input, options) {
|
|
|
3011
2963
|
else s3 = s4;
|
|
3012
2964
|
if (s3 !== peg$FAILED) {
|
|
3013
2965
|
peg$savedPos = peg$currPos;
|
|
3014
|
-
s4 = peg$
|
|
2966
|
+
s4 = peg$f54(s2, s3);
|
|
3015
2967
|
if (s4) s4 = void 0;
|
|
3016
2968
|
else s4 = peg$FAILED;
|
|
3017
2969
|
if (s4 !== peg$FAILED) {
|
|
@@ -3029,7 +2981,7 @@ function peg$parse(input, options) {
|
|
|
3029
2981
|
s9 = peg$parseAttrValue();
|
|
3030
2982
|
if (s9 !== peg$FAILED) {
|
|
3031
2983
|
peg$savedPos = s5;
|
|
3032
|
-
s5 = peg$
|
|
2984
|
+
s5 = peg$f55(s2, s3, s9);
|
|
3033
2985
|
} else {
|
|
3034
2986
|
peg$currPos = s5;
|
|
3035
2987
|
s5 = peg$FAILED;
|
|
@@ -3040,7 +2992,7 @@ function peg$parse(input, options) {
|
|
|
3040
2992
|
}
|
|
3041
2993
|
if (s5 === peg$FAILED) s5 = null;
|
|
3042
2994
|
peg$savedPos = s0;
|
|
3043
|
-
s0 = peg$
|
|
2995
|
+
s0 = peg$f56(s2, s3, s5);
|
|
3044
2996
|
} else {
|
|
3045
2997
|
peg$currPos = s0;
|
|
3046
2998
|
s0 = peg$FAILED;
|
|
@@ -3095,9 +3047,10 @@ function peg$parse(input, options) {
|
|
|
3095
3047
|
s5 = peg$FAILED;
|
|
3096
3048
|
if (peg$silentFails === 0) peg$fail(peg$e35);
|
|
3097
3049
|
}
|
|
3050
|
+
if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
|
|
3098
3051
|
if (s5 !== peg$FAILED) {
|
|
3099
3052
|
peg$savedPos = s0;
|
|
3100
|
-
s0 = peg$
|
|
3053
|
+
s0 = peg$f57(s2, s3, s4);
|
|
3101
3054
|
} else {
|
|
3102
3055
|
peg$currPos = s0;
|
|
3103
3056
|
s0 = peg$FAILED;
|
|
@@ -3149,9 +3102,10 @@ function peg$parse(input, options) {
|
|
|
3149
3102
|
s5 = peg$FAILED;
|
|
3150
3103
|
if (peg$silentFails === 0) peg$fail(peg$e37);
|
|
3151
3104
|
}
|
|
3105
|
+
if (s5 === peg$FAILED) s5 = peg$parseOpenEnd();
|
|
3152
3106
|
if (s5 !== peg$FAILED) {
|
|
3153
3107
|
peg$savedPos = s0;
|
|
3154
|
-
s0 = peg$
|
|
3108
|
+
s0 = peg$f58(s2, s3, s4);
|
|
3155
3109
|
} else {
|
|
3156
3110
|
peg$currPos = s0;
|
|
3157
3111
|
s0 = peg$FAILED;
|
|
@@ -3170,7 +3124,7 @@ function peg$parse(input, options) {
|
|
|
3170
3124
|
}
|
|
3171
3125
|
if (s1 !== peg$FAILED) {
|
|
3172
3126
|
peg$savedPos = s0;
|
|
3173
|
-
s1 = peg$
|
|
3127
|
+
s1 = peg$f59(s1);
|
|
3174
3128
|
}
|
|
3175
3129
|
s0 = s1;
|
|
3176
3130
|
if (s0 === peg$FAILED) {
|
|
@@ -3196,7 +3150,7 @@ function peg$parse(input, options) {
|
|
|
3196
3150
|
s2 = input.substring(s2, peg$currPos);
|
|
3197
3151
|
s3 = peg$parseHere();
|
|
3198
3152
|
peg$savedPos = s0;
|
|
3199
|
-
s0 = peg$
|
|
3153
|
+
s0 = peg$f60(s1, s2, s3);
|
|
3200
3154
|
}
|
|
3201
3155
|
}
|
|
3202
3156
|
}
|
|
@@ -3206,7 +3160,7 @@ function peg$parse(input, options) {
|
|
|
3206
3160
|
let s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13;
|
|
3207
3161
|
s0 = peg$currPos;
|
|
3208
3162
|
peg$savedPos = peg$currPos;
|
|
3209
|
-
s1 = peg$
|
|
3163
|
+
s1 = peg$f61();
|
|
3210
3164
|
if (s1) s1 = void 0;
|
|
3211
3165
|
else s1 = peg$FAILED;
|
|
3212
3166
|
if (s1 !== peg$FAILED) {
|
|
@@ -3235,7 +3189,7 @@ function peg$parse(input, options) {
|
|
|
3235
3189
|
if (s2 !== peg$FAILED) {
|
|
3236
3190
|
s3 = peg$currPos;
|
|
3237
3191
|
peg$savedPos = peg$currPos;
|
|
3238
|
-
s4 = peg$
|
|
3192
|
+
s4 = peg$f62(s2);
|
|
3239
3193
|
if (s4) s4 = void 0;
|
|
3240
3194
|
else s4 = peg$FAILED;
|
|
3241
3195
|
if (s4 !== peg$FAILED) {
|
|
@@ -3274,7 +3228,7 @@ function peg$parse(input, options) {
|
|
|
3274
3228
|
if (s0 === peg$FAILED) {
|
|
3275
3229
|
s0 = peg$currPos;
|
|
3276
3230
|
peg$savedPos = peg$currPos;
|
|
3277
|
-
s1 = peg$
|
|
3231
|
+
s1 = peg$f63();
|
|
3278
3232
|
if (s1) s1 = void 0;
|
|
3279
3233
|
else s1 = peg$FAILED;
|
|
3280
3234
|
if (s1 !== peg$FAILED) {
|
|
@@ -3301,12 +3255,12 @@ function peg$parse(input, options) {
|
|
|
3301
3255
|
if (s6 !== peg$FAILED) {
|
|
3302
3256
|
s7 = peg$parseHere();
|
|
3303
3257
|
peg$savedPos = peg$currPos;
|
|
3304
|
-
s8 = peg$
|
|
3258
|
+
s8 = peg$f64(s4, s7);
|
|
3305
3259
|
if (s8) s8 = void 0;
|
|
3306
3260
|
else s8 = peg$FAILED;
|
|
3307
3261
|
if (s8 !== peg$FAILED) {
|
|
3308
3262
|
s9 = peg$currPos;
|
|
3309
|
-
s10 = peg$
|
|
3263
|
+
s10 = peg$f65(s4, s7);
|
|
3310
3264
|
s11 = peg$currPos;
|
|
3311
3265
|
s12 = [];
|
|
3312
3266
|
if (s12.length >= (s10 | 0)) s13 = peg$FAILED;
|
|
@@ -3336,13 +3290,7 @@ function peg$parse(input, options) {
|
|
|
3336
3290
|
if (s10 !== peg$FAILED) s9 = input.substring(s9, peg$currPos);
|
|
3337
3291
|
else s9 = s10;
|
|
3338
3292
|
if (s9 !== peg$FAILED) {
|
|
3339
|
-
|
|
3340
|
-
s10 = peg$c11;
|
|
3341
|
-
peg$currPos++;
|
|
3342
|
-
} else {
|
|
3343
|
-
s10 = peg$FAILED;
|
|
3344
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
3345
|
-
}
|
|
3293
|
+
s10 = peg$parseBraceEnd();
|
|
3346
3294
|
if (s10 !== peg$FAILED) {
|
|
3347
3295
|
s1 = [
|
|
3348
3296
|
s1,
|
|
@@ -3388,7 +3336,7 @@ function peg$parse(input, options) {
|
|
|
3388
3336
|
if (s0 === peg$FAILED) {
|
|
3389
3337
|
s0 = peg$currPos;
|
|
3390
3338
|
peg$savedPos = peg$currPos;
|
|
3391
|
-
s1 = peg$
|
|
3339
|
+
s1 = peg$f66();
|
|
3392
3340
|
if (s1) s1 = void 0;
|
|
3393
3341
|
else s1 = peg$FAILED;
|
|
3394
3342
|
if (s1 !== peg$FAILED) {
|
|
@@ -3435,13 +3383,7 @@ function peg$parse(input, options) {
|
|
|
3435
3383
|
if (s4 !== peg$FAILED) {
|
|
3436
3384
|
s5 = peg$parseCodeToBrace();
|
|
3437
3385
|
if (s5 !== peg$FAILED) {
|
|
3438
|
-
|
|
3439
|
-
s6 = peg$c11;
|
|
3440
|
-
peg$currPos++;
|
|
3441
|
-
} else {
|
|
3442
|
-
s6 = peg$FAILED;
|
|
3443
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
3444
|
-
}
|
|
3386
|
+
s6 = peg$parseBraceEnd();
|
|
3445
3387
|
if (s6 !== peg$FAILED) {
|
|
3446
3388
|
s1 = [
|
|
3447
3389
|
s1,
|
|
@@ -3479,7 +3421,7 @@ function peg$parse(input, options) {
|
|
|
3479
3421
|
if (s0 === peg$FAILED) {
|
|
3480
3422
|
s0 = peg$currPos;
|
|
3481
3423
|
peg$savedPos = peg$currPos;
|
|
3482
|
-
s1 = peg$
|
|
3424
|
+
s1 = peg$f67();
|
|
3483
3425
|
if (s1) s1 = void 0;
|
|
3484
3426
|
else s1 = peg$FAILED;
|
|
3485
3427
|
if (s1 !== peg$FAILED) {
|
|
@@ -3507,13 +3449,7 @@ function peg$parse(input, options) {
|
|
|
3507
3449
|
if (s3 !== peg$FAILED) {
|
|
3508
3450
|
s4 = peg$parseCodeToBrace();
|
|
3509
3451
|
if (s4 !== peg$FAILED) {
|
|
3510
|
-
|
|
3511
|
-
s5 = peg$c11;
|
|
3512
|
-
peg$currPos++;
|
|
3513
|
-
} else {
|
|
3514
|
-
s5 = peg$FAILED;
|
|
3515
|
-
if (peg$silentFails === 0) peg$fail(peg$e19);
|
|
3516
|
-
}
|
|
3452
|
+
s5 = peg$parseBraceEnd();
|
|
3517
3453
|
if (s5 !== peg$FAILED) {
|
|
3518
3454
|
s1 = [
|
|
3519
3455
|
s1,
|
|
@@ -3569,6 +3505,7 @@ function peg$parse(input, options) {
|
|
|
3569
3505
|
return s0;
|
|
3570
3506
|
}
|
|
3571
3507
|
const textMode = options.text === true;
|
|
3508
|
+
const completionMode = options.completion === true;
|
|
3572
3509
|
const hooks = options.hooks;
|
|
3573
3510
|
/** End of the stretch a `.|n|` repetition consumes (see skipTo). */
|
|
3574
3511
|
let skipEnd = -1;
|
|
@@ -3654,6 +3591,46 @@ function peg$parse(input, options) {
|
|
|
3654
3591
|
else peg$throw();
|
|
3655
3592
|
}
|
|
3656
3593
|
//#endregion
|
|
3594
|
+
//#region src/utils/macro-names.ts
|
|
3595
|
+
/**
|
|
3596
|
+
* Macro and widget names are case-insensitive: `{StatusBar}` invokes the
|
|
3597
|
+
* widget defined as `statusbar`. A NameMap keys its entries by the lowercased
|
|
3598
|
+
* name.
|
|
3599
|
+
*/
|
|
3600
|
+
var NameMap = class extends Map {
|
|
3601
|
+
get(name) {
|
|
3602
|
+
return super.get(name.toLowerCase());
|
|
3603
|
+
}
|
|
3604
|
+
set(name, value) {
|
|
3605
|
+
return super.set(name.toLowerCase(), value);
|
|
3606
|
+
}
|
|
3607
|
+
has(name) {
|
|
3608
|
+
return super.has(name.toLowerCase());
|
|
3609
|
+
}
|
|
3610
|
+
delete(name) {
|
|
3611
|
+
return super.delete(name.toLowerCase());
|
|
3612
|
+
}
|
|
3613
|
+
};
|
|
3614
|
+
/** A set of macro or widget names (see NameMap). */
|
|
3615
|
+
var NameSet = class {
|
|
3616
|
+
constructor(names = []) {
|
|
3617
|
+
this.names = new NameMap();
|
|
3618
|
+
for (const name of names) this.add(name);
|
|
3619
|
+
}
|
|
3620
|
+
add(name) {
|
|
3621
|
+
this.names.set(name, true);
|
|
3622
|
+
}
|
|
3623
|
+
has(name) {
|
|
3624
|
+
return this.names.has(name);
|
|
3625
|
+
}
|
|
3626
|
+
delete(name) {
|
|
3627
|
+
this.names.delete(name);
|
|
3628
|
+
}
|
|
3629
|
+
clear() {
|
|
3630
|
+
this.names.clear();
|
|
3631
|
+
}
|
|
3632
|
+
};
|
|
3633
|
+
//#endregion
|
|
3657
3634
|
//#region src/markup/ast.ts
|
|
3658
3635
|
/**
|
|
3659
3636
|
* The passage AST (built by parse.ts), and the registry of block macros:
|
|
@@ -3764,6 +3741,93 @@ function astNode({ token, body }) {
|
|
|
3764
3741
|
}
|
|
3765
3742
|
}
|
|
3766
3743
|
}
|
|
3744
|
+
new NameMap();
|
|
3745
|
+
new NameMap();
|
|
3746
|
+
new NameSet();
|
|
3747
|
+
/**
|
|
3748
|
+
* How a macro argument is read (see components/macros/macro-args.ts). Every
|
|
3749
|
+
* declared parameter names one: there is no default.
|
|
3750
|
+
* Quoted strings accept `\"`, `\'` and `\\` escapes.
|
|
3751
|
+
* - `expression`: code, as written.
|
|
3752
|
+
* - `statements`: code run as statements (`{set}`), as written.
|
|
3753
|
+
* - `passage`: a passage name: a quoted string or an expression, as written.
|
|
3754
|
+
* - `variable`: a variable reference such as `$name` or `"$name"`, as written.
|
|
3755
|
+
* - `string`: one quoted string; anything else leaves the argument unset.
|
|
3756
|
+
* - `text`: one quoted string, or text with any loose quotes stripped.
|
|
3757
|
+
* - `names`: a comma-separated list of names (`@item, @i`).
|
|
3758
|
+
* - `delay`: a duration (`2s`, `500ms`, `300`) in milliseconds.
|
|
3759
|
+
* - `number`: a number.
|
|
3760
|
+
* - `flag`: a keyword, the parameter's name, at the start or end; a boolean.
|
|
3761
|
+
* - `separator`: a word (`of`) or `=` separating the parameters before it
|
|
3762
|
+
* from those after it; a boolean.
|
|
3763
|
+
* - `options`: keywords, the names of its `parameters`, each followed by a
|
|
3764
|
+
* quoted string or a number unless it is a flag.
|
|
3765
|
+
*/
|
|
3766
|
+
var PARAMETER_TYPES = [
|
|
3767
|
+
"expression",
|
|
3768
|
+
"statements",
|
|
3769
|
+
"passage",
|
|
3770
|
+
"variable",
|
|
3771
|
+
"string",
|
|
3772
|
+
"text",
|
|
3773
|
+
"names",
|
|
3774
|
+
"delay",
|
|
3775
|
+
"number",
|
|
3776
|
+
"flag",
|
|
3777
|
+
"separator",
|
|
3778
|
+
"options"
|
|
3779
|
+
];
|
|
3780
|
+
/**
|
|
3781
|
+
* What the value of a `string` or `text` argument holds, for the check at
|
|
3782
|
+
* story start and for tooling (see code-check.ts):
|
|
3783
|
+
* - `markup`: markup the macro renders (`{button}`'s label): its markup
|
|
3784
|
+
* is checked.
|
|
3785
|
+
* - `text`: plain text the macro uses as written (`{checkbox}`'s label).
|
|
3786
|
+
* - `passage`: a passage name (`{watch}`'s `goto`): the passage must exist.
|
|
3787
|
+
* - `expression`, `statements`: code (`{watch}`'s condition and `run`): it
|
|
3788
|
+
* is checked as code, and its variable references against the schema.
|
|
3789
|
+
*
|
|
3790
|
+
* Without it, the argument of a macro with `interpolate` holds `markup`,
|
|
3791
|
+
* any other `text`.
|
|
3792
|
+
*/
|
|
3793
|
+
var STRING_HOLDS = [
|
|
3794
|
+
"markup",
|
|
3795
|
+
"text",
|
|
3796
|
+
"passage",
|
|
3797
|
+
"expression",
|
|
3798
|
+
"statements"
|
|
3799
|
+
];
|
|
3800
|
+
/**
|
|
3801
|
+
* Throw if a parameter `macro` declares (or an option of one) has no type,
|
|
3802
|
+
* or one that isn't a ParameterType: arguments are read by their type, and
|
|
3803
|
+
* there is no default. Throw too if it declares what it `holds` wrongly.
|
|
3804
|
+
*/
|
|
3805
|
+
function checkParameterTypes(macro, parameters) {
|
|
3806
|
+
const holdsFix = `Give a \`string\` or \`text\` parameter one of ${STRING_HOLDS.join(", ")} to hold (see docs/custom-macros.md#what-a-string-holds).`;
|
|
3807
|
+
for (const param of parameters) {
|
|
3808
|
+
const type = param.type;
|
|
3809
|
+
if (!PARAMETER_TYPES.includes(type)) throw parameterError(macro, param, type === void 0 ? "has no type" : `has the unknown type ${JSON.stringify(type)}`, `Give it one of the types ${PARAMETER_TYPES.join(", ")} (see docs/custom-macros.md#parameter-types), or declare no parameters and read props.rawArgs.`);
|
|
3810
|
+
const holds = param.holds;
|
|
3811
|
+
if (holds !== void 0 && type !== "string" && type !== "text") throw parameterError(macro, param, `is of the type ${type}, which holds what it is`, holdsFix);
|
|
3812
|
+
if (holds !== void 0 && !STRING_HOLDS.includes(holds)) throw parameterError(macro, param, `holds the unknown ${JSON.stringify(holds)}`, holdsFix);
|
|
3813
|
+
if (param.parameters) checkParameterTypes(macro, param.parameters);
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
/** The error for the parameter `param` of `macro`: what is wrong, and the fix. */
|
|
3817
|
+
function parameterError(macro, param, problem, fix) {
|
|
3818
|
+
return /* @__PURE__ */ new Error(`spindle: The parameter "${param.name}" of the macro {${macro}} ${problem}. ${fix}`);
|
|
3819
|
+
}
|
|
3820
|
+
var metadataRegistry = new NameMap();
|
|
3821
|
+
/** Indexed at registration, so parsing each tag does not scan every macro. */
|
|
3822
|
+
var companionParents = new NameMap();
|
|
3823
|
+
/** The parents declaring a branching companion (listbox options are values). */
|
|
3824
|
+
function branchParents(name, macros) {
|
|
3825
|
+
if (!macros) return [...companionParents.get(name) ?? []].filter((parent) => parent !== "listbox");
|
|
3826
|
+
return macros.filter((macro) => macro.name.toLowerCase() !== "listbox" && macro.subMacros.some((sub) => sub.toLowerCase() === name.toLowerCase())).map((macro) => macro.name.toLowerCase());
|
|
3827
|
+
}
|
|
3828
|
+
function getMacroRegistry() {
|
|
3829
|
+
return Array.from(metadataRegistry.values());
|
|
3830
|
+
}
|
|
3767
3831
|
//#endregion
|
|
3768
3832
|
//#region src/markup/line-column.ts
|
|
3769
3833
|
/** 1-based line and column of `offset` in `text`. */
|
|
@@ -10168,7 +10232,7 @@ function isCodeAttribute(name) {
|
|
|
10168
10232
|
* sigil is not followed by a word character (`{$(…)}`) is code, kept
|
|
10169
10233
|
* verbatim: not resolved, and not decoded like text.
|
|
10170
10234
|
*/
|
|
10171
|
-
function splitSigilTemplate(template) {
|
|
10235
|
+
function splitSigilTemplate(template, incomplete = false) {
|
|
10172
10236
|
const parts = [];
|
|
10173
10237
|
let text = "";
|
|
10174
10238
|
let i = 0;
|
|
@@ -10180,7 +10244,8 @@ function splitSigilTemplate(template) {
|
|
|
10180
10244
|
}
|
|
10181
10245
|
text += template.slice(i, brace);
|
|
10182
10246
|
i = brace + 1;
|
|
10183
|
-
|
|
10247
|
+
let end = isSigil(template[i]) ? defaultCodeEnd.closeBrace(template, i, i) : -1;
|
|
10248
|
+
if (end === -1 && incomplete && isSigil(template[i])) end = template.length;
|
|
10184
10249
|
if (end === -1) {
|
|
10185
10250
|
text += "{";
|
|
10186
10251
|
continue;
|
|
@@ -10188,7 +10253,7 @@ function splitSigilTemplate(template) {
|
|
|
10188
10253
|
if (text) parts.push({ text });
|
|
10189
10254
|
text = "";
|
|
10190
10255
|
const block = template.slice(i, end);
|
|
10191
|
-
parts.push(/^.\w/.test(block) ? { expr: block } : { verbatim: `{${block}}` });
|
|
10256
|
+
parts.push(/^.\w/.test(block) || incomplete && block.length === 1 && end === template.length ? { expr: block } : { verbatim: `{${block}}` });
|
|
10192
10257
|
i = end + 1;
|
|
10193
10258
|
}
|
|
10194
10259
|
if (text) parts.push({ text });
|
|
@@ -10221,7 +10286,7 @@ var MarkupError = class extends Error {
|
|
|
10221
10286
|
this.name = "MarkupError";
|
|
10222
10287
|
}
|
|
10223
10288
|
};
|
|
10224
|
-
function run$1(source, startRule, options) {
|
|
10289
|
+
function run$1(source, startRule, options, completion = false) {
|
|
10225
10290
|
const hooks = options.hooks ? {
|
|
10226
10291
|
...defaultHooks,
|
|
10227
10292
|
...options.hooks
|
|
@@ -10230,7 +10295,8 @@ function run$1(source, startRule, options) {
|
|
|
10230
10295
|
return peg$parse(source, {
|
|
10231
10296
|
startRule,
|
|
10232
10297
|
text: options.text === true,
|
|
10233
|
-
hooks
|
|
10298
|
+
hooks,
|
|
10299
|
+
completion
|
|
10234
10300
|
});
|
|
10235
10301
|
} catch (err) {
|
|
10236
10302
|
const { location, code } = err;
|
|
@@ -10331,7 +10397,7 @@ function tokenizeMarkupTolerant(source, options = {}) {
|
|
|
10331
10397
|
* each error starts (`damage[i]` for `errors[i]`): the tag that is
|
|
10332
10398
|
* malformed, which an error inside it (an attribute value) is after.
|
|
10333
10399
|
*/
|
|
10334
|
-
function scanMarkupTolerant(source, options = {}) {
|
|
10400
|
+
function scanMarkupTolerant(source, options = {}, completion = false) {
|
|
10335
10401
|
const tokens = [];
|
|
10336
10402
|
const errors = [];
|
|
10337
10403
|
const damage = [];
|
|
@@ -10348,10 +10414,10 @@ function scanMarkupTolerant(source, options = {}) {
|
|
|
10348
10414
|
closeBrace: (input, codeStart, lenientStart) => base + Math.min(codeStart, lenientStart) > lastBrace ? -1 : closeBrace(input, codeStart, lenientStart)
|
|
10349
10415
|
};
|
|
10350
10416
|
try {
|
|
10351
|
-
return
|
|
10417
|
+
return run$1(text, "Tokens", {
|
|
10352
10418
|
...options,
|
|
10353
10419
|
hooks
|
|
10354
|
-
}).map((token) => shiftOffsets(token, base));
|
|
10420
|
+
}, completion).map((token) => shiftOffsets(token, base));
|
|
10355
10421
|
} catch (error) {
|
|
10356
10422
|
if (!(error instanceof MarkupError)) throw error;
|
|
10357
10423
|
return error;
|
|
@@ -10394,6 +10460,10 @@ function scanMarkupTolerant(source, options = {}) {
|
|
|
10394
10460
|
damage
|
|
10395
10461
|
};
|
|
10396
10462
|
}
|
|
10463
|
+
/** Runtime grammar with unfinished EOF tokens, for cursor contexts only. */
|
|
10464
|
+
function completionTokens(source, options = {}) {
|
|
10465
|
+
return scanMarkupTolerant(source, options, true).tokens;
|
|
10466
|
+
}
|
|
10397
10467
|
/** The offset fields of a token (and of an attribute): `start`, `nameEnd`… */
|
|
10398
10468
|
var OFFSET_FIELD = /^(start|end|[A-Za-z]*(Start|End))$/;
|
|
10399
10469
|
/** `token` (or an attribute of it) with each of its offsets turned by `map`. */
|
|
@@ -11572,6 +11642,118 @@ function referencesOf(pieces) {
|
|
|
11572
11642
|
return refs;
|
|
11573
11643
|
}
|
|
11574
11644
|
//#endregion
|
|
11645
|
+
//#region src/completion-context.ts
|
|
11646
|
+
/** Cursor context from the runtime grammar and argument metadata, without executing code. */
|
|
11647
|
+
var LITERAL = { kind: "literal" };
|
|
11648
|
+
/**
|
|
11649
|
+
* Whether a cursor is in executable markup, including unfinished EOF tags.
|
|
11650
|
+
* Only the source before cursor is inspected. Code includes its literals;
|
|
11651
|
+
* kind is literal when the cursor itself is inside one, a comment, or prose.
|
|
11652
|
+
*/
|
|
11653
|
+
function completionContext(source, cursor, macros = []) {
|
|
11654
|
+
if (!Number.isInteger(cursor) || cursor < 0 || cursor > source.length) throw new RangeError("cursor must be a UTF-16 offset within source");
|
|
11655
|
+
const parametersOf = parameterLookup(macros);
|
|
11656
|
+
const codeContext = (code, goal, map) => {
|
|
11657
|
+
const probe = code.length + 1;
|
|
11658
|
+
let executable = false;
|
|
11659
|
+
lexJs(code + " __spindle_cursor__", {
|
|
11660
|
+
code(_ch, at) {
|
|
11661
|
+
if (at >= probe) executable = true;
|
|
11662
|
+
},
|
|
11663
|
+
variable(_sigil, _name, at) {
|
|
11664
|
+
if (at >= probe) executable = true;
|
|
11665
|
+
}
|
|
11666
|
+
}, goal);
|
|
11667
|
+
if (!executable) return LITERAL;
|
|
11668
|
+
const offset = map(0);
|
|
11669
|
+
const offsets = Array.from({ length: code.length + 1 }, (_, i) => map(i));
|
|
11670
|
+
return {
|
|
11671
|
+
kind: "code",
|
|
11672
|
+
code,
|
|
11673
|
+
goal,
|
|
11674
|
+
offset,
|
|
11675
|
+
cursor: code.length,
|
|
11676
|
+
...offsets.some((at, i) => at !== offset + i) ? { sourceOffsets: offsets } : {}
|
|
11677
|
+
};
|
|
11678
|
+
};
|
|
11679
|
+
const read = (src, map, text = false, depth = 0, sigilsOnly = false) => {
|
|
11680
|
+
if (depth >= 64) return LITERAL;
|
|
11681
|
+
if (sigilsOnly) {
|
|
11682
|
+
let at = 0;
|
|
11683
|
+
for (const part of splitSigilTemplate(src, true)) if ("expr" in part) {
|
|
11684
|
+
if (at + 1 + part.expr.length === src.length) return codeContext(part.expr, "expression", (i) => map(at + 1 + i));
|
|
11685
|
+
at += part.expr.length + 2;
|
|
11686
|
+
} else at += ("text" in part ? part.text : part.verbatim).length;
|
|
11687
|
+
return LITERAL;
|
|
11688
|
+
}
|
|
11689
|
+
const tokens = completionTokens(src, {
|
|
11690
|
+
text,
|
|
11691
|
+
hooks: { isRaw: (name) => isRawMacro(name, parametersOf.widget?.(name) !== void 0) }
|
|
11692
|
+
});
|
|
11693
|
+
const token = tokens[tokens.length - 1];
|
|
11694
|
+
if (!token || token.end !== src.length) return LITERAL;
|
|
11695
|
+
const codeAt = (code, at, goal = "expression") => codeContext(code, goal, (i) => map(at + i));
|
|
11696
|
+
const nested = (value, at, offsets, onlySigils = false) => read(value, (i) => map(offsets?.[i] ?? at + i), true, depth + 1, onlySigils);
|
|
11697
|
+
if (token.type === "variable" && token.nameEnd === src.length) return codeAt(src.slice(token.nameStart - 1), token.nameStart - 1);
|
|
11698
|
+
if (token.type === "expression" && token.expressionEnd === src.length) return codeAt(token.expression, token.expressionStart);
|
|
11699
|
+
if (token.type === "html") {
|
|
11700
|
+
for (const { name, value, at } of attributeValues(src, token)) if (at + value.length === src.length) return nested(value, at, void 0, isCodeAttribute(name));
|
|
11701
|
+
} else if (token.type === "link" && token.displayEnd === src.length) return nested(token.display, token.displayStart);
|
|
11702
|
+
else if (token.type === "text" && !token.comment) {
|
|
11703
|
+
const opener = tokens[tokens.length - 2];
|
|
11704
|
+
if (opener?.type === "macro" && !opener.isClose && isRawMacro(opener.name, parametersOf.widget?.(opener.name) !== void 0)) return codeAt(token.value, token.start, "statements");
|
|
11705
|
+
} else if (token.type === "macro" && !token.isClose && token.argsEnd === src.length) {
|
|
11706
|
+
const name = token.name.toLowerCase();
|
|
11707
|
+
const args = token.rawArgs;
|
|
11708
|
+
const widget = parametersOf.widget?.(name);
|
|
11709
|
+
if (!widget && [
|
|
11710
|
+
"if",
|
|
11711
|
+
"elseif",
|
|
11712
|
+
"case"
|
|
11713
|
+
].includes(name)) return codeAt(args, token.argsStart);
|
|
11714
|
+
const stringContext = (raw, at, holds, escapes = "quotes") => {
|
|
11715
|
+
const quoted = readQuoted(raw, 0, true);
|
|
11716
|
+
if (!quoted) {
|
|
11717
|
+
if (holds === "expression" || holds === "statements") return codeAt(raw, at, holds);
|
|
11718
|
+
return holds === "markup" ? nested(raw, at) : LITERAL;
|
|
11719
|
+
}
|
|
11720
|
+
if (scanStringLiteral(raw, 0).closed) return LITERAL;
|
|
11721
|
+
const value = escapes === "javascript" ? stringLiteralValue(raw + raw[0]) : quoted.value;
|
|
11722
|
+
if (value == null) return LITERAL;
|
|
11723
|
+
const offsets = escapeOffsets(raw.slice(1), at + 1, value, escapes);
|
|
11724
|
+
if (holds === "expression" || holds === "statements") return codeContext(value, holds, (i) => map(offsets?.[i] ?? at + 1 + i));
|
|
11725
|
+
return holds === "markup" ? nested(value, at + 1, offsets) : LITERAL;
|
|
11726
|
+
};
|
|
11727
|
+
if (widget) {
|
|
11728
|
+
const spans = splitArgSpans(args);
|
|
11729
|
+
const span = spans[spans.length - 1];
|
|
11730
|
+
if (!span) return LITERAL;
|
|
11731
|
+
const raw = args.slice(span[0]);
|
|
11732
|
+
const holds = widget[spans.length - 1]?.holds;
|
|
11733
|
+
return /^["']/.test(raw) && holds ? stringContext(raw, token.argsStart + span[0], holds, "javascript") : codeAt(raw, token.argsStart + span[0]);
|
|
11734
|
+
}
|
|
11735
|
+
const params = parametersOf(name);
|
|
11736
|
+
if (!params) return LITERAL;
|
|
11737
|
+
const spans = macroArgumentSpans(args, params).filter((span) => span.parameter.type !== "options" && span.end === args.trimEnd().length);
|
|
11738
|
+
const span = spans[spans.length - 1];
|
|
11739
|
+
if (!span) return LITERAL;
|
|
11740
|
+
const param = span.parameter;
|
|
11741
|
+
let at = span.start;
|
|
11742
|
+
if (span.parameterPath.length > 1) {
|
|
11743
|
+
at += param.name.length;
|
|
11744
|
+
while (/\s/.test(args.charAt(at))) at++;
|
|
11745
|
+
}
|
|
11746
|
+
const raw = args.slice(at);
|
|
11747
|
+
const offset = token.argsStart + at;
|
|
11748
|
+
if (param.type === "expression" || param.type === "passage") return codeAt(raw, offset);
|
|
11749
|
+
if (param.type === "statements") return codeAt(raw, offset, "statements");
|
|
11750
|
+
if (param.type === "string" || param.type === "text") return stringContext(raw, offset, param.holds);
|
|
11751
|
+
}
|
|
11752
|
+
return LITERAL;
|
|
11753
|
+
};
|
|
11754
|
+
return read(source.slice(0, cursor), (i) => i);
|
|
11755
|
+
}
|
|
11756
|
+
//#endregion
|
|
11575
11757
|
//#region src/widgets/ast-scanner.ts
|
|
11576
11758
|
/** The declared parameters of the macros registered so far. */
|
|
11577
11759
|
var registeredParameters = (name) => parameterLookup(getMacroRegistry())(name);
|
|
@@ -11579,25 +11761,29 @@ var registeredParameters = (name) => parameterLookup(getMacroRegistry())(name);
|
|
|
11579
11761
|
* Whether the text of an attribute value or macro label renders a
|
|
11580
11762
|
* `{@children}`: it is markup, parsed as the renderer parses it.
|
|
11581
11763
|
*/
|
|
11582
|
-
function textContainsChildren(text, parametersOf) {
|
|
11764
|
+
function textContainsChildren(text, parametersOf, hooks) {
|
|
11583
11765
|
if (!text.includes("{")) return false;
|
|
11584
11766
|
let nodes;
|
|
11585
11767
|
try {
|
|
11586
|
-
nodes = parseMarkup(text, {
|
|
11768
|
+
nodes = parseMarkup(text, {
|
|
11769
|
+
text: true,
|
|
11770
|
+
hooks
|
|
11771
|
+
});
|
|
11587
11772
|
} catch {
|
|
11588
11773
|
return false;
|
|
11589
11774
|
}
|
|
11590
|
-
return astContainsChildren(nodes, parametersOf);
|
|
11775
|
+
return astContainsChildren(nodes, parametersOf, hooks);
|
|
11591
11776
|
}
|
|
11592
11777
|
/**
|
|
11593
11778
|
* Whether a tag renders a `{@children}` in an attribute value or a macro
|
|
11594
11779
|
* argument that holds markup (`<span title="{@children}">`,
|
|
11595
11780
|
* `{button "{@children}"}`). Literal arguments and code are not markup.
|
|
11596
11781
|
* `src` is the text a flat token's offsets index into (its attribute values
|
|
11597
|
-
* are read from it); a token made from an AST has none.
|
|
11782
|
+
* are read from it); a token made from an AST has none. Discovery hooks
|
|
11783
|
+
* also apply inside these texts, before widgets have been registered.
|
|
11598
11784
|
*/
|
|
11599
|
-
function tokenTextContainsChildren(token, parametersOf = registeredParameters, src = "") {
|
|
11600
|
-
for (const piece of codeAndText(src, [token], parametersOf)) if (piece.kind === "text" && textContainsChildren(piece.text, parametersOf)) return true;
|
|
11785
|
+
function tokenTextContainsChildren(token, parametersOf = registeredParameters, src = "", hooks) {
|
|
11786
|
+
for (const piece of codeAndText(src, [token], parametersOf)) if (piece.kind === "text" && textContainsChildren(piece.text, parametersOf, hooks)) return true;
|
|
11601
11787
|
return false;
|
|
11602
11788
|
}
|
|
11603
11789
|
/**
|
|
@@ -11607,36 +11793,33 @@ function tokenTextContainsChildren(token, parametersOf = registeredParameters, s
|
|
|
11607
11793
|
* entered: its slot belongs to the innermost widget (as widgetDefinitions
|
|
11608
11794
|
* reads it), and a definition renders nothing of its own.
|
|
11609
11795
|
*/
|
|
11610
|
-
function astContainsChildren(nodes, parametersOf = registeredParameters) {
|
|
11796
|
+
function astContainsChildren(nodes, parametersOf = registeredParameters, hooks) {
|
|
11611
11797
|
for (const node of nodes) {
|
|
11612
11798
|
if (node.type === "variable" && node.scope === "local" && node.name === "children") return true;
|
|
11613
|
-
if (node.type
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
if (node.branches) {
|
|
11638
|
-
for (const branch of node.branches) if (astContainsChildren(branch.children, parametersOf)) return true;
|
|
11639
|
-
}
|
|
11799
|
+
if (node.type !== "html" && node.type !== "macro") continue;
|
|
11800
|
+
if (node.type === "macro" && node.name.toLowerCase() === "widget") continue;
|
|
11801
|
+
const span = {
|
|
11802
|
+
isClose: false,
|
|
11803
|
+
start: 0,
|
|
11804
|
+
end: 0
|
|
11805
|
+
};
|
|
11806
|
+
if (tokenTextContainsChildren(node.type === "html" ? {
|
|
11807
|
+
...node,
|
|
11808
|
+
...span,
|
|
11809
|
+
isSelfClose: false,
|
|
11810
|
+
tagNameStart: 0,
|
|
11811
|
+
tagNameEnd: 0,
|
|
11812
|
+
attributeSpans: []
|
|
11813
|
+
} : {
|
|
11814
|
+
...node,
|
|
11815
|
+
...span,
|
|
11816
|
+
nameStart: 0,
|
|
11817
|
+
nameEnd: 0,
|
|
11818
|
+
argsStart: 0,
|
|
11819
|
+
argsEnd: 0
|
|
11820
|
+
}, parametersOf, "", hooks) || astContainsChildren(node.children, parametersOf, hooks)) return true;
|
|
11821
|
+
if (node.type === "macro" && node.branches) {
|
|
11822
|
+
for (const branch of node.branches) if (astContainsChildren(branch.children, parametersOf, hooks)) return true;
|
|
11640
11823
|
}
|
|
11641
11824
|
}
|
|
11642
11825
|
return false;
|
|
@@ -11712,42 +11895,48 @@ function nameSpan(rawArgs) {
|
|
|
11712
11895
|
* nested definitions, it belongs to the innermost.
|
|
11713
11896
|
*/
|
|
11714
11897
|
function widgetDefinitions$1(passages, parametersOf = registeredParameters) {
|
|
11715
|
-
const
|
|
11716
|
-
|
|
11717
|
-
|
|
11718
|
-
const
|
|
11719
|
-
const
|
|
11720
|
-
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
if (def) done.push({
|
|
11728
|
-
...def,
|
|
11729
|
-
closeStart: token.start
|
|
11898
|
+
const list = [...passages];
|
|
11899
|
+
const scan = (replacesDo) => {
|
|
11900
|
+
const found = [];
|
|
11901
|
+
const hooks = { isRaw: (name) => isRawMacro(name, replacesDo || parametersOf.widget?.(name) !== void 0) };
|
|
11902
|
+
for (const passage of list) {
|
|
11903
|
+
if (passage.name !== "StoryInit" && !passage.tags?.includes("widget")) continue;
|
|
11904
|
+
const open = [];
|
|
11905
|
+
const done = [];
|
|
11906
|
+
for (const token of tokenizeMarkupTolerant(passage.content, { hooks }).tokens) if (token.type === "macro" && token.name.toLowerCase() === "widget") {
|
|
11907
|
+
if (!token.isClose) open.push({
|
|
11908
|
+
token,
|
|
11909
|
+
isBlock: false
|
|
11730
11910
|
});
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11736
|
-
|
|
11737
|
-
|
|
11738
|
-
|
|
11739
|
-
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11911
|
+
else {
|
|
11912
|
+
const def = open.pop();
|
|
11913
|
+
if (def) done.push({
|
|
11914
|
+
...def,
|
|
11915
|
+
closeStart: token.start
|
|
11916
|
+
});
|
|
11917
|
+
}
|
|
11918
|
+
} else if (open.length > 0 && (token.type === "variable" && token.scope === "local" && token.name === "children" || tokenTextContainsChildren(token, parametersOf, passage.content, hooks))) open[open.length - 1].isBlock = true;
|
|
11919
|
+
done.push(...open);
|
|
11920
|
+
const defs = [];
|
|
11921
|
+
for (const { token, isBlock, closeStart } of done) try {
|
|
11922
|
+
const [from, to] = nameSpan(token.rawArgs);
|
|
11923
|
+
defs.push({
|
|
11924
|
+
...parseWidgetDef(token.rawArgs),
|
|
11925
|
+
block: isBlock,
|
|
11926
|
+
passage: passage.name,
|
|
11927
|
+
start: token.start,
|
|
11928
|
+
end: token.end,
|
|
11929
|
+
nameStart: token.argsStart + from,
|
|
11930
|
+
nameEnd: token.argsStart + to,
|
|
11931
|
+
...closeStart === void 0 ? {} : { closeStart }
|
|
11932
|
+
});
|
|
11933
|
+
} catch {}
|
|
11934
|
+
found.push(...defs.sort((a, b) => a.start - b.start));
|
|
11935
|
+
}
|
|
11936
|
+
return found;
|
|
11937
|
+
};
|
|
11938
|
+
const initial = scan(false);
|
|
11939
|
+
return effectiveWidgetDefinitions(initial).some((def) => def.name.toLowerCase() === "do") ? scan(true) : initial;
|
|
11751
11940
|
}
|
|
11752
11941
|
/**
|
|
11753
11942
|
* The definitions the runtime ends up with, one per widget name: the closed
|
|
@@ -12340,22 +12529,40 @@ var Reader = class {
|
|
|
12340
12529
|
}
|
|
12341
12530
|
/** Skip an array literal (or any bracketed group) at the cursor. */
|
|
12342
12531
|
skipBalanced() {
|
|
12343
|
-
const { src } = this;
|
|
12344
12532
|
const close = {
|
|
12345
12533
|
"[": "]",
|
|
12346
12534
|
"{": "}",
|
|
12347
12535
|
"(": ")"
|
|
12348
|
-
}[src.charAt(this.i)];
|
|
12349
|
-
|
|
12536
|
+
}[this.src.charAt(this.i)];
|
|
12537
|
+
return close ? this.skipNested(close) : false;
|
|
12538
|
+
}
|
|
12539
|
+
/** Skip groups and template interpolations with an explicit stack. */
|
|
12540
|
+
skipNested(close) {
|
|
12541
|
+
const { src } = this;
|
|
12542
|
+
const stack = [close];
|
|
12350
12543
|
this.i++;
|
|
12351
|
-
while (this.i < src.length) {
|
|
12352
|
-
|
|
12544
|
+
while (this.i < src.length && stack.length) {
|
|
12545
|
+
const c = src.charAt(this.i);
|
|
12546
|
+
const top = stack[stack.length - 1];
|
|
12547
|
+
if (c === top) {
|
|
12548
|
+
stack.pop();
|
|
12353
12549
|
this.i++;
|
|
12354
|
-
|
|
12355
|
-
|
|
12356
|
-
|
|
12550
|
+
} else if (top === "`") {
|
|
12551
|
+
if (c === "\\") this.i += 2;
|
|
12552
|
+
else if (c === "$" && src.charAt(this.i + 1) === "{") {
|
|
12553
|
+
stack.push("}");
|
|
12554
|
+
this.i += 2;
|
|
12555
|
+
} else this.i++;
|
|
12556
|
+
} else if (c === "`" || c === "[" || c === "{" || c === "(") {
|
|
12557
|
+
stack.push(c === "`" ? "`" : {
|
|
12558
|
+
"[": "]",
|
|
12559
|
+
"{": "}",
|
|
12560
|
+
"(": ")"
|
|
12561
|
+
}[c]);
|
|
12562
|
+
this.i++;
|
|
12563
|
+
} else if (!this.skipOne()) return false;
|
|
12357
12564
|
}
|
|
12358
|
-
return
|
|
12565
|
+
return stack.length === 0;
|
|
12359
12566
|
}
|
|
12360
12567
|
/** Skip one character, or one string, template, comment or group. */
|
|
12361
12568
|
skipOne() {
|
|
@@ -12382,20 +12589,7 @@ var Reader = class {
|
|
|
12382
12589
|
}
|
|
12383
12590
|
/** Skip a template literal, with the expressions in it. */
|
|
12384
12591
|
skipTemplate() {
|
|
12385
|
-
|
|
12386
|
-
this.i++;
|
|
12387
|
-
while (this.i < src.length) {
|
|
12388
|
-
const c = src.charAt(this.i);
|
|
12389
|
-
if (c === "\\") this.i += 2;
|
|
12390
|
-
else if (c === "`") {
|
|
12391
|
-
this.i++;
|
|
12392
|
-
return true;
|
|
12393
|
-
} else if (c === "$" && src.charAt(this.i + 1) === "{") {
|
|
12394
|
-
this.i++;
|
|
12395
|
-
if (!this.skipBalanced()) return false;
|
|
12396
|
-
} else this.i++;
|
|
12397
|
-
}
|
|
12398
|
-
return false;
|
|
12592
|
+
return this.skipNested("`");
|
|
12399
12593
|
}
|
|
12400
12594
|
};
|
|
12401
12595
|
//#endregion
|
|
@@ -13393,6 +13587,7 @@ var ConfigReader = class extends Reader {
|
|
|
13393
13587
|
constructor(..._args) {
|
|
13394
13588
|
super(..._args);
|
|
13395
13589
|
this.failed = false;
|
|
13590
|
+
this.depth = 0;
|
|
13396
13591
|
}
|
|
13397
13592
|
/** The static value of a member or element, whatever follows is skipped. */
|
|
13398
13593
|
member() {
|
|
@@ -13460,22 +13655,31 @@ var ConfigReader = class extends Reader {
|
|
|
13460
13655
|
* after what it read. False if the text ends first, or cannot be read.
|
|
13461
13656
|
*/
|
|
13462
13657
|
elements(close, read) {
|
|
13463
|
-
this.
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
this.i
|
|
13473
|
-
|
|
13658
|
+
if (this.depth >= 64) {
|
|
13659
|
+
if (!this.skipBalanced()) this.fail();
|
|
13660
|
+
return false;
|
|
13661
|
+
}
|
|
13662
|
+
this.depth++;
|
|
13663
|
+
try {
|
|
13664
|
+
this.i++;
|
|
13665
|
+
for (;;) {
|
|
13666
|
+
this.space();
|
|
13667
|
+
const c = this.src.charAt(this.i);
|
|
13668
|
+
if (c === close) {
|
|
13669
|
+
this.i++;
|
|
13670
|
+
return true;
|
|
13671
|
+
}
|
|
13672
|
+
if (c === ",") {
|
|
13673
|
+
this.i++;
|
|
13674
|
+
continue;
|
|
13675
|
+
}
|
|
13676
|
+
if (this.failed || this.i >= this.src.length) return false;
|
|
13677
|
+
const before = this.i;
|
|
13678
|
+
read();
|
|
13679
|
+
if (this.i === before) this.fail();
|
|
13474
13680
|
}
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
read();
|
|
13478
|
-
if (this.i === before) this.fail();
|
|
13681
|
+
} finally {
|
|
13682
|
+
this.depth--;
|
|
13479
13683
|
}
|
|
13480
13684
|
}
|
|
13481
13685
|
array() {
|
|
@@ -25507,4 +25711,4 @@ function validateVariableReferences(passages, declarations, macros = []) {
|
|
|
25507
25711
|
return checkVariableReferences(list.filter((p) => !p.tags?.some((t) => NOT_MARKUP_TAGS.includes(t))), declarations, referenceOptions(macros, false, list));
|
|
25508
25712
|
}
|
|
25509
25713
|
//#endregion
|
|
25510
|
-
export { MarkupError, SIGIL_SCOPES, checkParameterTypes, collectStoryPassageReferences, discoverMacros, effectiveWidgetDefinitions, endsWithOperator, evaluatePassageName, findCodeEnd, formatDiagnostic, formatPassage, isBlockMacro, isSigil, lexJs, lexTemplate, macroArgumentSpans, pairMarkup, parseCode, parseDeclarations, parseSelectors, parseStoryVariables, parseWidgetDef, passagePieces, passagePiecesOfTokens, passageTarget, pieceOffset, readQuoted, scanStringLiteral, splitArgs, splitIncludeFlag, splitTopLevel, stripLooseQuotes, tokenizeMarkup, tokenizeMarkupTolerant, transform, unescapeQuoted, validateStoryMarkup, validateVariableReferences, variableReferences, widgetDefinitions };
|
|
25714
|
+
export { MarkupError, SIGIL_SCOPES, checkParameterTypes, collectStoryPassageReferences, completionContext, discoverMacros, effectiveWidgetDefinitions, endsWithOperator, evaluatePassageName, findCodeEnd, formatDiagnostic, formatPassage, isBlockMacro, isSigil, lexJs, lexTemplate, macroArgumentSpans, pairMarkup, parseCode, parseDeclarations, parseSelectors, parseStoryVariables, parseWidgetDef, passagePieces, passagePiecesOfTokens, passageTarget, pieceOffset, readQuoted, scanStringLiteral, splitArgs, splitIncludeFlag, splitTopLevel, stripLooseQuotes, tokenizeMarkup, tokenizeMarkupTolerant, transform, unescapeQuoted, validateStoryMarkup, validateVariableReferences, variableReferences, widgetDefinitions };
|