apps 0.0.1-beta.2 → 0.0.1-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -44
- package/framework-reference.json +1 -1
- package/js/{chunk-SATWJKN6.js → chunk-27F7W2LG.js} +1 -1
- package/js/{chunk-WFSQXYUT.js → chunk-4QQ62BVS.js} +37 -3
- package/js/{chunk-HDJH3RPR.js → chunk-57RKNWL2.js} +2 -2
- package/js/chunk-625MBYU4.js +524 -0
- package/js/{chunk-RN2MXB4R.js → chunk-BLI53LPN.js} +28 -9
- package/js/{chunk-FW5HBOIK.js → chunk-CDL5PM2Q.js} +307 -169
- package/js/{chunk-J7O55ZV7.js → chunk-CHAK4P5C.js} +317 -176
- package/js/{chunk-HDTGZWP2.js → chunk-CMRKLZZY.js} +8 -8
- package/js/{chunk-OHRT55C4.js → chunk-IJX4CYZO.js} +3 -6
- package/js/{chunk-FDNTX5QJ.js → chunk-IPI4MFSN.js} +2 -2
- package/js/{chunk-YEJOQEII.js → chunk-JU7VHODU.js} +1 -1
- package/js/chunk-KUMBKVJD.js +39 -0
- package/js/{chunk-EVJUVWN2.js → chunk-M3B3DE4K.js} +2 -2
- package/js/{chunk-ZJWDMTE3.js → chunk-MKWZPDR6.js} +3 -3
- package/js/{chunk-BMOIAIVR.js → chunk-N7YDVXYJ.js} +49 -1
- package/js/{chunk-D47C7KG5.js → chunk-NKLWZJLE.js} +2 -2
- package/js/chunk-NMKHTJOQ.js +254 -0
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-ZCAMUXSG.js → chunk-ODEIDRGW.js} +3 -4
- package/js/{chunk-5MQZEB6Y.js → chunk-OZ4UK3CD.js} +37 -12
- package/js/{chunk-M6ZRRIBI.js → chunk-PJJ24GU7.js} +1 -1
- package/js/{chunk-FZJOYIZO.js → chunk-PZB6T6KU.js} +1 -1
- package/js/{chunk-LGIYBDWA.js → chunk-R3EV5FTO.js} +13 -1
- package/js/{chunk-Z5NMEGJN.js → chunk-RAAPJMVZ.js} +21 -9
- package/js/{chunk-QKHR7BMF.js → chunk-UK573G7W.js} +1 -1
- package/js/{chunk-4LPG6RCH.js → chunk-VFZKSM3T.js} +5 -25
- package/js/{chunk-MYYEW3RA.js → chunk-VXWY44LE.js} +780 -55
- package/js/{chunk-JN55AYQH.js → chunk-XNCYIB4D.js} +61 -32
- package/js/{chunk-PLCMJREA.js → chunk-ZQINWV4W.js} +60 -20
- package/js/client.js +10 -26
- package/js/contracts.js +74 -16
- package/js/effect.js +19 -20
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +47 -49
- package/js/host.js +19 -20
- package/js/index.js +232 -201
- package/js/mcp/effect.js +21 -22
- package/js/mcp/stdio.js +25 -26
- package/js/mcp.js +74 -56
- package/js/openapi.js +3428 -1276
- package/js/react.js +3 -3
- package/js/skills/effect.js +3 -3
- package/js/skills.js +12 -13
- package/js/storage/facet.js +4 -4
- package/js/ui/auth/contracts.js +8 -9
- package/js/ui/auth.js +16 -14
- package/js/ui/contracts.js +4 -4
- package/js/ui/serving.js +71 -218
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/app-data/src/contracts/database.d.ts +33 -6
- package/types/app-data/src/implementation/schema.d.ts +2 -17
- package/types/apps/src/contracts/app.d.ts +7 -6
- package/types/apps/src/contracts/failure.d.ts +25 -0
- package/types/apps/src/contracts/host.d.ts +31 -10
- package/types/apps/src/contracts/mcp.d.ts +16 -0
- package/types/apps/src/contracts/openapi.d.ts +5 -1
- package/types/apps/src/contracts/operations.d.ts +0 -5
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +235 -67
- package/types/apps/src/contracts/protocols/2.d.ts +710 -0
- package/types/apps/src/contracts/protocols/3.d.ts +718 -0
- package/types/apps/src/contracts/protocols/4.d.ts +1299 -0
- package/types/apps/src/contracts/protocols/5.d.ts +1174 -0
- package/types/apps/src/contracts/protocols/6.d.ts +1620 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1784 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +89 -0
- package/types/apps/src/contracts/provider.d.ts +109 -10
- package/types/apps/src/contracts/router.d.ts +59 -0
- package/types/apps/src/contracts/storage.d.ts +3 -3
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/contracts/ui.d.ts +18 -0
- package/types/apps/src/contracts/workflows.d.ts +34 -3
- package/types/apps/src/graphql.d.ts +1 -3
- package/types/apps/src/implementation/account-router.d.ts +12 -0
- package/types/apps/src/implementation/app.d.ts +5 -4
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +34 -4
- package/types/apps/src/implementation/elicitation.d.ts +2 -2
- package/types/apps/src/implementation/failure-detail.d.ts +26 -0
- package/types/apps/src/implementation/graphql-catalog.d.ts +4 -7
- package/types/apps/src/implementation/mcp-catalog.d.ts +7 -8
- package/types/apps/src/implementation/mcp-client.d.ts +35 -19
- package/types/apps/src/implementation/mcp.d.ts +35 -19
- package/types/apps/src/implementation/openapi-compile.d.ts +9 -5
- package/types/apps/src/implementation/openapi-document.d.ts +15 -2
- package/types/apps/src/implementation/openapi-request.d.ts +8 -1
- package/types/apps/src/implementation/openapi-source.d.ts +2 -6
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +36 -3
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -4
- package/types/apps/src/implementation/provider.d.ts +19 -5
- package/types/apps/src/implementation/router-catalog.d.ts +225 -0
- package/types/apps/src/implementation/router.d.ts +68 -0
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +44 -1
- package/types/apps/src/implementation/storage.d.ts +5 -3
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +11 -5
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +10 -4
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflow-context.d.ts +11 -3
- package/types/apps/src/index.d.ts +28 -11
- package/types/apps/src/mcp-stdio.d.ts +2 -5
- package/types/apps/src/mcp.d.ts +5 -4
- package/types/apps/src/openapi.d.ts +6 -6
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/types/telemetry/src/browser-operations.d.ts +5 -2
- package/js/chunk-PYUYJRSK.js +0 -93
- package/js/chunk-SWPD52J7.js +0 -35
- package/js/chunk-TE4KO4HI.js +0 -47
- package/js/chunk-W7D7WVSY.js +0 -18
- package/types/apps/src/contracts/dynamic-tools.d.ts +0 -13
- package/types/apps/src/implementation/account-operations.d.ts +0 -151
- package/types/apps/src/implementation/dynamic-tools.d.ts +0 -8
|
@@ -0,0 +1,1617 @@
|
|
|
1
|
+
// ../../node_modules/.bun/apg-lite@1.0.5/node_modules/apg-lite/lib/parser.js
|
|
2
|
+
var Parser = function fnparser() {
|
|
3
|
+
const id = identifiers;
|
|
4
|
+
const utils = utilities;
|
|
5
|
+
const p = this;
|
|
6
|
+
const thisFileName = "parser.js: Parser(): ";
|
|
7
|
+
const systemData = function systemData2() {
|
|
8
|
+
this.state = id.ACTIVE;
|
|
9
|
+
this.phraseLength = 0;
|
|
10
|
+
this.refresh = () => {
|
|
11
|
+
this.state = id.ACTIVE;
|
|
12
|
+
this.phraseLength = 0;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
p.ast = void 0;
|
|
16
|
+
p.stats = void 0;
|
|
17
|
+
p.trace = void 0;
|
|
18
|
+
p.callbacks = [];
|
|
19
|
+
let lookAhead = 0;
|
|
20
|
+
let treeDepth = 0;
|
|
21
|
+
let maxTreeDepth = 0;
|
|
22
|
+
let nodeHits = 0;
|
|
23
|
+
let maxMatched = 0;
|
|
24
|
+
let rules = void 0;
|
|
25
|
+
let udts = void 0;
|
|
26
|
+
let opcodes = void 0;
|
|
27
|
+
let chars = void 0;
|
|
28
|
+
let sysData = new systemData();
|
|
29
|
+
let ruleCallbacks = void 0;
|
|
30
|
+
let udtCallbacks = void 0;
|
|
31
|
+
let userData = void 0;
|
|
32
|
+
const clear = () => {
|
|
33
|
+
lookAhead = 0;
|
|
34
|
+
treeDepth = 0;
|
|
35
|
+
maxTreeDepth = 0;
|
|
36
|
+
nodeHits = 0;
|
|
37
|
+
maxMatched = 0;
|
|
38
|
+
rules = void 0;
|
|
39
|
+
udts = void 0;
|
|
40
|
+
opcodes = void 0;
|
|
41
|
+
chars = void 0;
|
|
42
|
+
sysData.refresh();
|
|
43
|
+
ruleCallbacks = void 0;
|
|
44
|
+
udtCallbacks = void 0;
|
|
45
|
+
userData = void 0;
|
|
46
|
+
};
|
|
47
|
+
const initializeCallbacks = () => {
|
|
48
|
+
const functionName = `${thisFileName}initializeCallbacks(): `;
|
|
49
|
+
let i;
|
|
50
|
+
ruleCallbacks = [];
|
|
51
|
+
udtCallbacks = [];
|
|
52
|
+
for (i = 0; i < rules.length; i += 1) {
|
|
53
|
+
ruleCallbacks[i] = void 0;
|
|
54
|
+
}
|
|
55
|
+
for (i = 0; i < udts.length; i += 1) {
|
|
56
|
+
udtCallbacks[i] = void 0;
|
|
57
|
+
}
|
|
58
|
+
let func;
|
|
59
|
+
const list = [];
|
|
60
|
+
for (i = 0; i < rules.length; i += 1) {
|
|
61
|
+
list.push(rules[i].lower);
|
|
62
|
+
}
|
|
63
|
+
for (i = 0; i < udts.length; i += 1) {
|
|
64
|
+
list.push(udts[i].lower);
|
|
65
|
+
}
|
|
66
|
+
for (const index in p.callbacks) {
|
|
67
|
+
if (p.callbacks.hasOwnProperty(index)) {
|
|
68
|
+
i = list.indexOf(index.toLowerCase());
|
|
69
|
+
if (i < 0) {
|
|
70
|
+
throw new Error(`${functionName}syntax callback '${index}' not a rule or udt name`);
|
|
71
|
+
}
|
|
72
|
+
func = p.callbacks[index] ? p.callbacks[index] : void 0;
|
|
73
|
+
if (typeof func === "function" || func === void 0) {
|
|
74
|
+
if (i < rules.length) {
|
|
75
|
+
ruleCallbacks[i] = func;
|
|
76
|
+
} else {
|
|
77
|
+
udtCallbacks[i - rules.length] = func;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
throw new Error(`${functionName}syntax callback[${index}] must be function reference or falsy)`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
p.parse = (grammar3, startName, inputString, callbackData) => {
|
|
86
|
+
const functionName = `${thisFileName}parse(): `;
|
|
87
|
+
clear();
|
|
88
|
+
chars = utils.stringToChars(inputString);
|
|
89
|
+
rules = grammar3.rules;
|
|
90
|
+
udts = grammar3.udts;
|
|
91
|
+
const lower = startName.toLowerCase();
|
|
92
|
+
let startIndex = void 0;
|
|
93
|
+
for (const i in rules) {
|
|
94
|
+
if (rules.hasOwnProperty(i)) {
|
|
95
|
+
if (lower === rules[i].lower) {
|
|
96
|
+
startIndex = rules[i].index;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (startIndex === void 0) {
|
|
102
|
+
throw new Error(`${functionName}start rule name '${startRule}' not recognized`);
|
|
103
|
+
}
|
|
104
|
+
initializeCallbacks();
|
|
105
|
+
if (p.trace) {
|
|
106
|
+
p.trace.init(rules, udts, chars);
|
|
107
|
+
}
|
|
108
|
+
if (p.stats) {
|
|
109
|
+
p.stats.init(rules, udts);
|
|
110
|
+
}
|
|
111
|
+
if (p.ast) {
|
|
112
|
+
p.ast.init(rules, udts, chars);
|
|
113
|
+
}
|
|
114
|
+
userData = callbackData;
|
|
115
|
+
opcodes = [
|
|
116
|
+
{
|
|
117
|
+
type: id.RNM,
|
|
118
|
+
index: startIndex
|
|
119
|
+
}
|
|
120
|
+
];
|
|
121
|
+
opExecute(0, 0);
|
|
122
|
+
opcodes = void 0;
|
|
123
|
+
let success = false;
|
|
124
|
+
switch (sysData.state) {
|
|
125
|
+
case id.ACTIVE:
|
|
126
|
+
throw new Error(`${functionName}final state should never be 'ACTIVE'`);
|
|
127
|
+
case id.NOMATCH:
|
|
128
|
+
success = false;
|
|
129
|
+
break;
|
|
130
|
+
case id.EMPTY:
|
|
131
|
+
case id.MATCH:
|
|
132
|
+
if (sysData.phraseLength === chars.length) {
|
|
133
|
+
success = true;
|
|
134
|
+
} else {
|
|
135
|
+
success = false;
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
throw new Error("unrecognized state");
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
success,
|
|
143
|
+
state: sysData.state,
|
|
144
|
+
stateName: id.idName(sysData.state),
|
|
145
|
+
length: chars.length,
|
|
146
|
+
matched: sysData.phraseLength,
|
|
147
|
+
maxMatched,
|
|
148
|
+
maxTreeDepth,
|
|
149
|
+
nodeHits
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
const opALT = (opIndex, phraseIndex) => {
|
|
153
|
+
const op = opcodes[opIndex];
|
|
154
|
+
for (let i = 0; i < op.children.length; i += 1) {
|
|
155
|
+
opExecute(op.children[i], phraseIndex);
|
|
156
|
+
if (sysData.state !== id.NOMATCH) {
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const opCAT = (opIndex, phraseIndex) => {
|
|
162
|
+
let success;
|
|
163
|
+
let astLength;
|
|
164
|
+
let catCharIndex;
|
|
165
|
+
let catPhrase;
|
|
166
|
+
const op = opcodes[opIndex];
|
|
167
|
+
if (p.ast) {
|
|
168
|
+
astLength = p.ast.getLength();
|
|
169
|
+
}
|
|
170
|
+
success = true;
|
|
171
|
+
catCharIndex = phraseIndex;
|
|
172
|
+
catPhrase = 0;
|
|
173
|
+
for (let i = 0; i < op.children.length; i += 1) {
|
|
174
|
+
opExecute(op.children[i], catCharIndex);
|
|
175
|
+
if (sysData.state === id.NOMATCH) {
|
|
176
|
+
success = false;
|
|
177
|
+
break;
|
|
178
|
+
} else {
|
|
179
|
+
catCharIndex += sysData.phraseLength;
|
|
180
|
+
catPhrase += sysData.phraseLength;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (success) {
|
|
184
|
+
sysData.state = catPhrase === 0 ? id.EMPTY : id.MATCH;
|
|
185
|
+
sysData.phraseLength = catPhrase;
|
|
186
|
+
} else {
|
|
187
|
+
sysData.state = id.NOMATCH;
|
|
188
|
+
sysData.phraseLength = 0;
|
|
189
|
+
if (p.ast) {
|
|
190
|
+
p.ast.setLength(astLength);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const opREP = (opIndex, phraseIndex) => {
|
|
195
|
+
let astLength;
|
|
196
|
+
let repCharIndex;
|
|
197
|
+
let repPhrase;
|
|
198
|
+
let repCount;
|
|
199
|
+
const op = opcodes[opIndex];
|
|
200
|
+
if (op.max === 0) {
|
|
201
|
+
sysData.state = id.EMPTY;
|
|
202
|
+
sysData.phraseLength = 0;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
repCharIndex = phraseIndex;
|
|
206
|
+
repPhrase = 0;
|
|
207
|
+
repCount = 0;
|
|
208
|
+
if (p.ast) {
|
|
209
|
+
astLength = p.ast.getLength();
|
|
210
|
+
}
|
|
211
|
+
while (1) {
|
|
212
|
+
if (repCharIndex >= chars.length) {
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
opExecute(opIndex + 1, repCharIndex);
|
|
216
|
+
if (sysData.state === id.NOMATCH) {
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
if (sysData.state === id.EMPTY) {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
repCount += 1;
|
|
223
|
+
repPhrase += sysData.phraseLength;
|
|
224
|
+
repCharIndex += sysData.phraseLength;
|
|
225
|
+
if (repCount === op.max) {
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (sysData.state === id.EMPTY) {
|
|
230
|
+
sysData.state = repPhrase === 0 ? id.EMPTY : id.MATCH;
|
|
231
|
+
sysData.phraseLength = repPhrase;
|
|
232
|
+
} else if (repCount >= op.min) {
|
|
233
|
+
sysData.state = repPhrase === 0 ? id.EMPTY : id.MATCH;
|
|
234
|
+
sysData.phraseLength = repPhrase;
|
|
235
|
+
} else {
|
|
236
|
+
sysData.state = id.NOMATCH;
|
|
237
|
+
sysData.phraseLength = 0;
|
|
238
|
+
if (p.ast) {
|
|
239
|
+
p.ast.setLength(astLength);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const validateRnmCallbackResult = (rule, sysData2, charsLeft, down) => {
|
|
244
|
+
if (sysData2.phraseLength > charsLeft) {
|
|
245
|
+
let str = `${thisFileName}opRNM(${rule.name}): callback function error: `;
|
|
246
|
+
str += `sysData.phraseLength: ${sysData2.phraseLength}`;
|
|
247
|
+
str += ` must be <= remaining chars: ${charsLeft}`;
|
|
248
|
+
throw new Error(str);
|
|
249
|
+
}
|
|
250
|
+
switch (sysData2.state) {
|
|
251
|
+
case id.ACTIVE:
|
|
252
|
+
if (!down) {
|
|
253
|
+
throw new Error(
|
|
254
|
+
`${thisFileName}opRNM(${rule.name}): callback function return error. ACTIVE state not allowed.`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
break;
|
|
258
|
+
case id.EMPTY:
|
|
259
|
+
sysData2.phraseLength = 0;
|
|
260
|
+
break;
|
|
261
|
+
case id.MATCH:
|
|
262
|
+
if (sysData2.phraseLength === 0) {
|
|
263
|
+
sysData2.state = id.EMPTY;
|
|
264
|
+
}
|
|
265
|
+
break;
|
|
266
|
+
case id.NOMATCH:
|
|
267
|
+
sysData2.phraseLength = 0;
|
|
268
|
+
break;
|
|
269
|
+
default:
|
|
270
|
+
throw new Error(
|
|
271
|
+
`${thisFileName}opRNM(${rule.name}): callback function return error. Unrecognized return state: ${sysData2.state}`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
const opRNM = (opIndex, phraseIndex) => {
|
|
276
|
+
let astLength;
|
|
277
|
+
let astDefined;
|
|
278
|
+
let savedOpcodes;
|
|
279
|
+
const op = opcodes[opIndex];
|
|
280
|
+
const rule = rules[op.index];
|
|
281
|
+
const callback = ruleCallbacks[rule.index];
|
|
282
|
+
if (!lookAhead) {
|
|
283
|
+
astDefined = p.ast && p.ast.ruleDefined(op.index);
|
|
284
|
+
if (astDefined) {
|
|
285
|
+
astLength = p.ast.getLength();
|
|
286
|
+
p.ast.down(op.index, rules[op.index].name);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (callback) {
|
|
290
|
+
const charsLeft = chars.length - phraseIndex;
|
|
291
|
+
callback(sysData, chars, phraseIndex, userData);
|
|
292
|
+
validateRnmCallbackResult(rule, sysData, charsLeft, true);
|
|
293
|
+
if (sysData.state === id.ACTIVE) {
|
|
294
|
+
savedOpcodes = opcodes;
|
|
295
|
+
opcodes = rule.opcodes;
|
|
296
|
+
opExecute(0, phraseIndex);
|
|
297
|
+
opcodes = savedOpcodes;
|
|
298
|
+
callback(sysData, chars, phraseIndex, userData);
|
|
299
|
+
validateRnmCallbackResult(rule, sysData, charsLeft, false);
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
savedOpcodes = opcodes;
|
|
303
|
+
opcodes = rule.opcodes;
|
|
304
|
+
opExecute(0, phraseIndex, sysData);
|
|
305
|
+
opcodes = savedOpcodes;
|
|
306
|
+
}
|
|
307
|
+
if (!lookAhead) {
|
|
308
|
+
if (astDefined) {
|
|
309
|
+
if (sysData.state === id.NOMATCH) {
|
|
310
|
+
p.ast.setLength(astLength);
|
|
311
|
+
} else {
|
|
312
|
+
p.ast.up(op.index, rule.name, phraseIndex, sysData.phraseLength);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
const opTRG = (opIndex, phraseIndex) => {
|
|
318
|
+
const op = opcodes[opIndex];
|
|
319
|
+
sysData.state = id.NOMATCH;
|
|
320
|
+
if (phraseIndex < chars.length) {
|
|
321
|
+
if (op.min <= chars[phraseIndex] && chars[phraseIndex] <= op.max) {
|
|
322
|
+
sysData.state = id.MATCH;
|
|
323
|
+
sysData.phraseLength = 1;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
const opTBS = (opIndex, phraseIndex) => {
|
|
328
|
+
const op = opcodes[opIndex];
|
|
329
|
+
const len = op.string.length;
|
|
330
|
+
sysData.state = id.NOMATCH;
|
|
331
|
+
if (phraseIndex + len <= chars.length) {
|
|
332
|
+
for (let i = 0; i < len; i += 1) {
|
|
333
|
+
if (chars[phraseIndex + i] !== op.string[i]) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
sysData.state = id.MATCH;
|
|
338
|
+
sysData.phraseLength = len;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
const opTLS = (opIndex, phraseIndex) => {
|
|
342
|
+
let code;
|
|
343
|
+
const op = opcodes[opIndex];
|
|
344
|
+
sysData.state = id.NOMATCH;
|
|
345
|
+
const len = op.string.length;
|
|
346
|
+
if (len === 0) {
|
|
347
|
+
sysData.state = id.EMPTY;
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (phraseIndex + len <= chars.length) {
|
|
351
|
+
for (let i = 0; i < len; i += 1) {
|
|
352
|
+
code = chars[phraseIndex + i];
|
|
353
|
+
if (code >= 65 && code <= 90) {
|
|
354
|
+
code += 32;
|
|
355
|
+
}
|
|
356
|
+
if (code !== op.string[i]) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
sysData.state = id.MATCH;
|
|
361
|
+
sysData.phraseLength = len;
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
const validateUdtCallbackResult = (udt, sysData2, charsLeft) => {
|
|
365
|
+
if (sysData2.phraseLength > charsLeft) {
|
|
366
|
+
let str = `${thisFileName}opUDT(${udt.name}): callback function error: `;
|
|
367
|
+
str += `sysData.phraseLength: ${sysData2.phraseLength}`;
|
|
368
|
+
str += ` must be <= remaining chars: ${charsLeft}`;
|
|
369
|
+
throw new Error(str);
|
|
370
|
+
}
|
|
371
|
+
switch (sysData2.state) {
|
|
372
|
+
case id.ACTIVE:
|
|
373
|
+
throw new Error(`${thisFileName}opUDT(${udt.name}) ACTIVE state return not allowed.`);
|
|
374
|
+
case id.EMPTY:
|
|
375
|
+
if (udt.empty) {
|
|
376
|
+
sysData2.phraseLength = 0;
|
|
377
|
+
} else {
|
|
378
|
+
throw new Error(`${thisFileName}opUDT(${udt.name}) may not return EMPTY.`);
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
case id.MATCH:
|
|
382
|
+
if (sysData2.phraseLength === 0) {
|
|
383
|
+
if (udt.empty) {
|
|
384
|
+
sysData2.state = id.EMPTY;
|
|
385
|
+
} else {
|
|
386
|
+
throw new Error(`${thisFileName}opUDT(${udt.name}) may not return EMPTY.`);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
break;
|
|
390
|
+
case id.NOMATCH:
|
|
391
|
+
sysData2.phraseLength = 0;
|
|
392
|
+
break;
|
|
393
|
+
default:
|
|
394
|
+
throw new Error(
|
|
395
|
+
`${thisFileName}opUDT(${udt.name}): callback function return error. Unrecognized return state: ${sysData2.state}`
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const opUDT = (opIndex, phraseIndex) => {
|
|
400
|
+
let astLength;
|
|
401
|
+
let astIndex;
|
|
402
|
+
let astDefined;
|
|
403
|
+
const op = opcodes[opIndex];
|
|
404
|
+
const udt = udts[op.index];
|
|
405
|
+
sysData.UdtIndex = udt.index;
|
|
406
|
+
if (!lookAhead) {
|
|
407
|
+
astDefined = p.ast && p.ast.udtDefined(op.index);
|
|
408
|
+
if (astDefined) {
|
|
409
|
+
astIndex = rules.length + op.index;
|
|
410
|
+
astLength = p.ast.getLength();
|
|
411
|
+
p.ast.down(astIndex, udt.name);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
const charsLeft = chars.length - phraseIndex;
|
|
415
|
+
udtCallbacks[op.index](sysData, chars, phraseIndex, userData);
|
|
416
|
+
validateUdtCallbackResult(udt, sysData, charsLeft);
|
|
417
|
+
if (!lookAhead) {
|
|
418
|
+
if (astDefined) {
|
|
419
|
+
if (sysData.state === id.NOMATCH) {
|
|
420
|
+
p.ast.setLength(astLength);
|
|
421
|
+
} else {
|
|
422
|
+
p.ast.up(astIndex, udt.name, phraseIndex, sysData.phraseLength);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
const opAND = (opIndex, phraseIndex) => {
|
|
428
|
+
lookAhead += 1;
|
|
429
|
+
opExecute(opIndex + 1, phraseIndex);
|
|
430
|
+
lookAhead -= 1;
|
|
431
|
+
sysData.phraseLength = 0;
|
|
432
|
+
switch (sysData.state) {
|
|
433
|
+
case id.EMPTY:
|
|
434
|
+
sysData.state = id.EMPTY;
|
|
435
|
+
break;
|
|
436
|
+
case id.MATCH:
|
|
437
|
+
sysData.state = id.EMPTY;
|
|
438
|
+
break;
|
|
439
|
+
case id.NOMATCH:
|
|
440
|
+
sysData.state = id.NOMATCH;
|
|
441
|
+
break;
|
|
442
|
+
default:
|
|
443
|
+
throw new Error(`opAND: invalid state ${sysData.state}`);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
const opNOT = (opIndex, phraseIndex) => {
|
|
447
|
+
lookAhead += 1;
|
|
448
|
+
opExecute(opIndex + 1, phraseIndex);
|
|
449
|
+
lookAhead -= 1;
|
|
450
|
+
sysData.phraseLength = 0;
|
|
451
|
+
switch (sysData.state) {
|
|
452
|
+
case id.EMPTY:
|
|
453
|
+
case id.MATCH:
|
|
454
|
+
sysData.state = id.NOMATCH;
|
|
455
|
+
break;
|
|
456
|
+
case id.NOMATCH:
|
|
457
|
+
sysData.state = id.EMPTY;
|
|
458
|
+
break;
|
|
459
|
+
default:
|
|
460
|
+
throw new Error(`opNOT: invalid state ${sysData.state}`);
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
const opExecute = (opIndex, phraseIndex) => {
|
|
464
|
+
const functionName = `${thisFileName}opExecute(): `;
|
|
465
|
+
const op = opcodes[opIndex];
|
|
466
|
+
nodeHits += 1;
|
|
467
|
+
if (treeDepth > maxTreeDepth) {
|
|
468
|
+
maxTreeDepth = treeDepth;
|
|
469
|
+
}
|
|
470
|
+
treeDepth += 1;
|
|
471
|
+
sysData.refresh();
|
|
472
|
+
if (p.trace) {
|
|
473
|
+
p.trace.down(op, phraseIndex);
|
|
474
|
+
}
|
|
475
|
+
switch (op.type) {
|
|
476
|
+
case id.ALT:
|
|
477
|
+
opALT(opIndex, phraseIndex);
|
|
478
|
+
break;
|
|
479
|
+
case id.CAT:
|
|
480
|
+
opCAT(opIndex, phraseIndex);
|
|
481
|
+
break;
|
|
482
|
+
case id.REP:
|
|
483
|
+
opREP(opIndex, phraseIndex);
|
|
484
|
+
break;
|
|
485
|
+
case id.RNM:
|
|
486
|
+
opRNM(opIndex, phraseIndex);
|
|
487
|
+
break;
|
|
488
|
+
case id.TRG:
|
|
489
|
+
opTRG(opIndex, phraseIndex);
|
|
490
|
+
break;
|
|
491
|
+
case id.TBS:
|
|
492
|
+
opTBS(opIndex, phraseIndex);
|
|
493
|
+
break;
|
|
494
|
+
case id.TLS:
|
|
495
|
+
opTLS(opIndex, phraseIndex);
|
|
496
|
+
break;
|
|
497
|
+
case id.UDT:
|
|
498
|
+
opUDT(opIndex, phraseIndex);
|
|
499
|
+
break;
|
|
500
|
+
case id.AND:
|
|
501
|
+
opAND(opIndex, phraseIndex);
|
|
502
|
+
break;
|
|
503
|
+
case id.NOT:
|
|
504
|
+
opNOT(opIndex, phraseIndex);
|
|
505
|
+
break;
|
|
506
|
+
default:
|
|
507
|
+
throw new Error(`${functionName}unrecognized operator`);
|
|
508
|
+
}
|
|
509
|
+
if (!lookAhead) {
|
|
510
|
+
if (phraseIndex + sysData.phraseLength > maxMatched) {
|
|
511
|
+
maxMatched = phraseIndex + sysData.phraseLength;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
if (p.stats) {
|
|
515
|
+
p.stats.collect(op, sysData);
|
|
516
|
+
}
|
|
517
|
+
if (p.trace) {
|
|
518
|
+
p.trace.up(op, sysData.state, phraseIndex, sysData.phraseLength);
|
|
519
|
+
}
|
|
520
|
+
treeDepth -= 1;
|
|
521
|
+
};
|
|
522
|
+
};
|
|
523
|
+
var Ast = function fnast() {
|
|
524
|
+
const thisFileName = "parser.js: Ast()): ";
|
|
525
|
+
const id = identifiers;
|
|
526
|
+
const utils = utilities;
|
|
527
|
+
const a = this;
|
|
528
|
+
let rules = void 0;
|
|
529
|
+
let udts = void 0;
|
|
530
|
+
let chars = void 0;
|
|
531
|
+
let nodeCount = 0;
|
|
532
|
+
const nodeCallbacks = [];
|
|
533
|
+
const stack = [];
|
|
534
|
+
const records = [];
|
|
535
|
+
a.callbacks = [];
|
|
536
|
+
a.init = (rulesIn, udtsIn, charsIn) => {
|
|
537
|
+
stack.length = 0;
|
|
538
|
+
records.length = 0;
|
|
539
|
+
nodeCount = 0;
|
|
540
|
+
rules = rulesIn;
|
|
541
|
+
udts = udtsIn;
|
|
542
|
+
chars = charsIn;
|
|
543
|
+
let i;
|
|
544
|
+
const list = [];
|
|
545
|
+
for (i = 0; i < rules.length; i += 1) {
|
|
546
|
+
list.push(rules[i].lower);
|
|
547
|
+
}
|
|
548
|
+
for (i = 0; i < udts.length; i += 1) {
|
|
549
|
+
list.push(udts[i].lower);
|
|
550
|
+
}
|
|
551
|
+
nodeCount = rules.length + udts.length;
|
|
552
|
+
for (i = 0; i < nodeCount; i += 1) {
|
|
553
|
+
nodeCallbacks[i] = void 0;
|
|
554
|
+
}
|
|
555
|
+
for (const index in a.callbacks) {
|
|
556
|
+
if (a.callbacks.hasOwnProperty(index)) {
|
|
557
|
+
const lower = index.toLowerCase();
|
|
558
|
+
i = list.indexOf(lower);
|
|
559
|
+
if (i < 0) {
|
|
560
|
+
throw new Error(`${thisFileName}init: node '${index}' not a rule or udt name`);
|
|
561
|
+
}
|
|
562
|
+
nodeCallbacks[i] = a.callbacks[index];
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
a.ruleDefined = (index) => !!nodeCallbacks[index];
|
|
567
|
+
a.udtDefined = (index) => !!nodeCallbacks[rules.length + index];
|
|
568
|
+
a.down = (callbackIndex, name) => {
|
|
569
|
+
const thisIndex = records.length;
|
|
570
|
+
stack.push(thisIndex);
|
|
571
|
+
records.push({
|
|
572
|
+
name,
|
|
573
|
+
thisIndex,
|
|
574
|
+
thatIndex: void 0,
|
|
575
|
+
state: id.SEM_PRE,
|
|
576
|
+
callbackIndex,
|
|
577
|
+
phraseIndex: void 0,
|
|
578
|
+
phraseLength: void 0,
|
|
579
|
+
stack: stack.length
|
|
580
|
+
});
|
|
581
|
+
return thisIndex;
|
|
582
|
+
};
|
|
583
|
+
a.up = (callbackIndex, name, phraseIndex, phraseLength) => {
|
|
584
|
+
const thisIndex = records.length;
|
|
585
|
+
const thatIndex = stack.pop();
|
|
586
|
+
records.push({
|
|
587
|
+
name,
|
|
588
|
+
thisIndex,
|
|
589
|
+
thatIndex,
|
|
590
|
+
state: id.SEM_POST,
|
|
591
|
+
callbackIndex,
|
|
592
|
+
phraseIndex,
|
|
593
|
+
phraseLength,
|
|
594
|
+
stack: stack.length
|
|
595
|
+
});
|
|
596
|
+
records[thatIndex].thatIndex = thisIndex;
|
|
597
|
+
records[thatIndex].phraseIndex = phraseIndex;
|
|
598
|
+
records[thatIndex].phraseLength = phraseLength;
|
|
599
|
+
return thisIndex;
|
|
600
|
+
};
|
|
601
|
+
a.translate = (data) => {
|
|
602
|
+
let ret;
|
|
603
|
+
let callback;
|
|
604
|
+
let record;
|
|
605
|
+
for (let i = 0; i < records.length; i += 1) {
|
|
606
|
+
record = records[i];
|
|
607
|
+
callback = nodeCallbacks[record.callbackIndex];
|
|
608
|
+
if (callback) {
|
|
609
|
+
if (record.state === id.SEM_PRE) {
|
|
610
|
+
callback(id.SEM_PRE, chars, record.phraseIndex, record.phraseLength, data);
|
|
611
|
+
} else if (callback) {
|
|
612
|
+
callback(id.SEM_POST, chars, record.phraseIndex, record.phraseLength, data);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
a.setLength = (length) => {
|
|
618
|
+
records.length = length;
|
|
619
|
+
if (length > 0) {
|
|
620
|
+
stack.length = records[length - 1].stack;
|
|
621
|
+
} else {
|
|
622
|
+
stack.length = 0;
|
|
623
|
+
}
|
|
624
|
+
};
|
|
625
|
+
a.getLength = () => records.length;
|
|
626
|
+
function indent(n) {
|
|
627
|
+
let ret = "";
|
|
628
|
+
while (n-- > 0) {
|
|
629
|
+
ret += " ";
|
|
630
|
+
}
|
|
631
|
+
return ret;
|
|
632
|
+
}
|
|
633
|
+
a.toXml = () => {
|
|
634
|
+
let xml = "";
|
|
635
|
+
let depth = 0;
|
|
636
|
+
xml += '<?xml version="1.0" encoding="utf-8"?>\n';
|
|
637
|
+
xml += `<root nodes="${records.length / 2}" characters="${chars.length}">
|
|
638
|
+
`;
|
|
639
|
+
xml += `<!-- input string -->
|
|
640
|
+
`;
|
|
641
|
+
xml += indent(depth + 2);
|
|
642
|
+
xml += utils.charsToString(chars);
|
|
643
|
+
xml += "\n";
|
|
644
|
+
records.forEach((rec) => {
|
|
645
|
+
if (rec.state === id.SEM_PRE) {
|
|
646
|
+
depth += 1;
|
|
647
|
+
xml += indent(depth);
|
|
648
|
+
xml += `<node name="${rec.name}" index="${rec.phraseIndex}" length="${rec.phraseLength}">
|
|
649
|
+
`;
|
|
650
|
+
xml += indent(depth + 2);
|
|
651
|
+
xml += utils.charsToString(chars, rec.phraseIndex, rec.phraseLength);
|
|
652
|
+
xml += "\n";
|
|
653
|
+
} else {
|
|
654
|
+
xml += indent(depth);
|
|
655
|
+
xml += `</node><!-- name="${rec.name}" -->
|
|
656
|
+
`;
|
|
657
|
+
depth -= 1;
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
xml += "</root>\n";
|
|
661
|
+
return xml;
|
|
662
|
+
};
|
|
663
|
+
};
|
|
664
|
+
var Trace = function fntrace() {
|
|
665
|
+
const id = identifiers;
|
|
666
|
+
const utils = utilities;
|
|
667
|
+
const thisFile = "parser.js: Trace(): ";
|
|
668
|
+
let chars = void 0;
|
|
669
|
+
let rules = void 0;
|
|
670
|
+
let udts = void 0;
|
|
671
|
+
let out = "";
|
|
672
|
+
let treeDepth = 0;
|
|
673
|
+
const MAX_PHRASE = 100;
|
|
674
|
+
const t = this;
|
|
675
|
+
const indent = (n) => {
|
|
676
|
+
let ret = "";
|
|
677
|
+
let count = 0;
|
|
678
|
+
if (n >= 0) {
|
|
679
|
+
while (n--) {
|
|
680
|
+
count += 1;
|
|
681
|
+
if (count === 5) {
|
|
682
|
+
ret += "|";
|
|
683
|
+
count = 0;
|
|
684
|
+
} else {
|
|
685
|
+
ret += ".";
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
return ret;
|
|
690
|
+
};
|
|
691
|
+
t.init = (r, u, c) => {
|
|
692
|
+
rules = r;
|
|
693
|
+
udts = u;
|
|
694
|
+
chars = c;
|
|
695
|
+
};
|
|
696
|
+
const opName = (op) => {
|
|
697
|
+
let name;
|
|
698
|
+
switch (op.type) {
|
|
699
|
+
case id.ALT:
|
|
700
|
+
name = "ALT";
|
|
701
|
+
break;
|
|
702
|
+
case id.CAT:
|
|
703
|
+
name = "CAT";
|
|
704
|
+
break;
|
|
705
|
+
case id.REP:
|
|
706
|
+
if (op.max === Infinity) {
|
|
707
|
+
name = `REP(${op.min},inf)`;
|
|
708
|
+
} else {
|
|
709
|
+
name = `REP(${op.min},${op.max})`;
|
|
710
|
+
}
|
|
711
|
+
break;
|
|
712
|
+
case id.RNM:
|
|
713
|
+
name = `RNM(${rules[op.index].name})`;
|
|
714
|
+
break;
|
|
715
|
+
case id.TRG:
|
|
716
|
+
name = `TRG(${op.min},${op.max})`;
|
|
717
|
+
break;
|
|
718
|
+
case id.TBS:
|
|
719
|
+
if (op.string.length > 6) {
|
|
720
|
+
name = `TBS(${utils.charsToString(op.string, 0, 3)}...)`;
|
|
721
|
+
} else {
|
|
722
|
+
name = `TBS(${utils.charsToString(op.string, 0, 6)})`;
|
|
723
|
+
}
|
|
724
|
+
break;
|
|
725
|
+
case id.TLS:
|
|
726
|
+
if (op.string.length > 6) {
|
|
727
|
+
name = `TLS(${utils.charsToString(op.string, 0, 3)}...)`;
|
|
728
|
+
} else {
|
|
729
|
+
name = `TLS(${utils.charsToString(op.string, 0, 6)})`;
|
|
730
|
+
}
|
|
731
|
+
break;
|
|
732
|
+
case id.UDT:
|
|
733
|
+
name = `UDT(${udts[op.index].name})`;
|
|
734
|
+
break;
|
|
735
|
+
case id.AND:
|
|
736
|
+
name = "AND";
|
|
737
|
+
break;
|
|
738
|
+
case id.NOT:
|
|
739
|
+
name = "NOT";
|
|
740
|
+
break;
|
|
741
|
+
default:
|
|
742
|
+
throw new Error(`${thisFile}Trace: opName: unrecognized opcode`);
|
|
743
|
+
}
|
|
744
|
+
return name;
|
|
745
|
+
};
|
|
746
|
+
t.down = (op, offset) => {
|
|
747
|
+
const lead = indent(treeDepth);
|
|
748
|
+
const len = Math.min(MAX_PHRASE, chars.length - offset);
|
|
749
|
+
let phrase = utils.charsToString(chars, offset, len);
|
|
750
|
+
if (len < chars.length - offset) {
|
|
751
|
+
phrase += "...";
|
|
752
|
+
}
|
|
753
|
+
phrase = `${lead}|-|[${opName(op)}]${phrase}
|
|
754
|
+
`;
|
|
755
|
+
out += phrase;
|
|
756
|
+
treeDepth += 1;
|
|
757
|
+
};
|
|
758
|
+
t.up = (op, state, offset, phraseLength) => {
|
|
759
|
+
const thisFunc = `${thisFile}trace.up: `;
|
|
760
|
+
treeDepth -= 1;
|
|
761
|
+
const lead = indent(treeDepth);
|
|
762
|
+
let len;
|
|
763
|
+
let phrase;
|
|
764
|
+
let st;
|
|
765
|
+
switch (state) {
|
|
766
|
+
case id.EMPTY:
|
|
767
|
+
st = "|E|";
|
|
768
|
+
phrase = `''`;
|
|
769
|
+
break;
|
|
770
|
+
case id.MATCH:
|
|
771
|
+
st = "|M|";
|
|
772
|
+
len = Math.min(MAX_PHRASE, phraseLength);
|
|
773
|
+
if (len < phraseLength) {
|
|
774
|
+
phrase = `'${utils.charsToString(chars, offset, len)}...'`;
|
|
775
|
+
} else {
|
|
776
|
+
phrase = `'${utils.charsToString(chars, offset, len)}'`;
|
|
777
|
+
}
|
|
778
|
+
break;
|
|
779
|
+
case id.NOMATCH:
|
|
780
|
+
st = "|N|";
|
|
781
|
+
phrase = "";
|
|
782
|
+
break;
|
|
783
|
+
default:
|
|
784
|
+
throw new Error(`${thisFunc} unrecognized state`);
|
|
785
|
+
}
|
|
786
|
+
phrase = `${lead}${st}[${opName(op)}]${phrase}
|
|
787
|
+
`;
|
|
788
|
+
out += phrase;
|
|
789
|
+
};
|
|
790
|
+
t.displayTrace = () => out;
|
|
791
|
+
};
|
|
792
|
+
var Stats = function fnstats() {
|
|
793
|
+
const id = identifiers;
|
|
794
|
+
const thisFileName = "parser.js: Stats(): ";
|
|
795
|
+
let rules;
|
|
796
|
+
let udts;
|
|
797
|
+
let totals;
|
|
798
|
+
const stats = [];
|
|
799
|
+
const ruleStats = [];
|
|
800
|
+
const udtStats = [];
|
|
801
|
+
this.init = (r, u) => {
|
|
802
|
+
rules = r;
|
|
803
|
+
udts = u;
|
|
804
|
+
clear();
|
|
805
|
+
};
|
|
806
|
+
this.collect = (op, sys) => {
|
|
807
|
+
incStat(totals, sys.state, sys.phraseLength);
|
|
808
|
+
incStat(stats[op.type], sys.state, sys.phraseLength);
|
|
809
|
+
if (op.type === id.RNM) {
|
|
810
|
+
incStat(ruleStats[op.index], sys.state, sys.phraseLength);
|
|
811
|
+
}
|
|
812
|
+
if (op.type === id.UDT) {
|
|
813
|
+
incStat(udtStats[op.index], sys.state, sys.phraseLength);
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
this.displayStats = () => {
|
|
817
|
+
let out = "";
|
|
818
|
+
const totals2 = {
|
|
819
|
+
match: 0,
|
|
820
|
+
empty: 0,
|
|
821
|
+
nomatch: 0,
|
|
822
|
+
total: 0
|
|
823
|
+
};
|
|
824
|
+
const displayRow = (op, m, e, n, t) => {
|
|
825
|
+
totals2.match += m;
|
|
826
|
+
totals2.empty += e;
|
|
827
|
+
totals2.nomatch += n;
|
|
828
|
+
totals2.total += t;
|
|
829
|
+
const mm = normalize(m);
|
|
830
|
+
const ee = normalize(e);
|
|
831
|
+
const nn = normalize(n);
|
|
832
|
+
const tt = normalize(t);
|
|
833
|
+
return `${op} | ${mm} | ${ee} | ${nn} | ${tt} |
|
|
834
|
+
`;
|
|
835
|
+
};
|
|
836
|
+
out += " OPERATOR STATS\n";
|
|
837
|
+
out += " | MATCH | EMPTY | NOMATCH | TOTAL |\n";
|
|
838
|
+
out += displayRow(" ALT", stats[id.ALT].match, stats[id.ALT].empty, stats[id.ALT].nomatch, stats[id.ALT].total);
|
|
839
|
+
out += displayRow(" CAT", stats[id.CAT].match, stats[id.CAT].empty, stats[id.CAT].nomatch, stats[id.CAT].total);
|
|
840
|
+
out += displayRow(" REP", stats[id.REP].match, stats[id.REP].empty, stats[id.REP].nomatch, stats[id.REP].total);
|
|
841
|
+
out += displayRow(" RNM", stats[id.RNM].match, stats[id.RNM].empty, stats[id.RNM].nomatch, stats[id.RNM].total);
|
|
842
|
+
out += displayRow(" TRG", stats[id.TRG].match, stats[id.TRG].empty, stats[id.TRG].nomatch, stats[id.TRG].total);
|
|
843
|
+
out += displayRow(" TBS", stats[id.TBS].match, stats[id.TBS].empty, stats[id.TBS].nomatch, stats[id.TBS].total);
|
|
844
|
+
out += displayRow(" TLS", stats[id.TLS].match, stats[id.TLS].empty, stats[id.TLS].nomatch, stats[id.TLS].total);
|
|
845
|
+
out += displayRow(" UDT", stats[id.UDT].match, stats[id.UDT].empty, stats[id.UDT].nomatch, stats[id.UDT].total);
|
|
846
|
+
out += displayRow(" AND", stats[id.AND].match, stats[id.AND].empty, stats[id.AND].nomatch, stats[id.AND].total);
|
|
847
|
+
out += displayRow(" NOT", stats[id.NOT].match, stats[id.NOT].empty, stats[id.NOT].nomatch, stats[id.NOT].total);
|
|
848
|
+
out += displayRow("TOTAL", totals2.match, totals2.empty, totals2.nomatch, totals2.total);
|
|
849
|
+
return out;
|
|
850
|
+
};
|
|
851
|
+
this.displayHits = (type) => {
|
|
852
|
+
let out = "";
|
|
853
|
+
const displayRow = (m, e, n, t, name) => {
|
|
854
|
+
totals.match += m;
|
|
855
|
+
totals.empty += e;
|
|
856
|
+
totals.nomatch += n;
|
|
857
|
+
totals.total += t;
|
|
858
|
+
const mm = normalize(m);
|
|
859
|
+
const ee = normalize(e);
|
|
860
|
+
const nn = normalize(n);
|
|
861
|
+
const tt = normalize(t);
|
|
862
|
+
return `| ${mm} | ${ee} | ${nn} | ${tt} | ${name}
|
|
863
|
+
`;
|
|
864
|
+
};
|
|
865
|
+
if (typeof type === "string" && type.toLowerCase()[0] === "a") {
|
|
866
|
+
ruleStats.sort(sortAlpha);
|
|
867
|
+
udtStats.sort(sortAlpha);
|
|
868
|
+
out += " RULES/UDTS ALPHABETICALLY\n";
|
|
869
|
+
} else if (typeof type === "string" && type.toLowerCase()[0] === "i") {
|
|
870
|
+
ruleStats.sort(sortIndex);
|
|
871
|
+
udtStats.sort(sortIndex);
|
|
872
|
+
out += " RULES/UDTS BY INDEX\n";
|
|
873
|
+
} else {
|
|
874
|
+
ruleStats.sort(sortHits);
|
|
875
|
+
udtStats.sort(sortHits);
|
|
876
|
+
out += " RULES/UDTS BY HIT COUNT\n";
|
|
877
|
+
}
|
|
878
|
+
out += "| MATCH | EMPTY | NOMATCH | TOTAL | NAME\n";
|
|
879
|
+
for (let i = 0; i < ruleStats.length; i += 1) {
|
|
880
|
+
let r = ruleStats[i];
|
|
881
|
+
if (r.total) {
|
|
882
|
+
out += displayRow(r.match, r.empty, r.nomatch, r.total, r.name);
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
for (let i = 0; i < udtStats.length; i += 1) {
|
|
886
|
+
let r = udtStats[i];
|
|
887
|
+
if (r.total) {
|
|
888
|
+
out += displayRow(r.match, r.empty, r.nomatch, r.total, r.name);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
return out;
|
|
892
|
+
};
|
|
893
|
+
const normalize = (n) => {
|
|
894
|
+
if (n < 10) {
|
|
895
|
+
return ` ${n}`;
|
|
896
|
+
}
|
|
897
|
+
if (n < 100) {
|
|
898
|
+
return ` ${n}`;
|
|
899
|
+
}
|
|
900
|
+
if (n < 1e3) {
|
|
901
|
+
return ` ${n}`;
|
|
902
|
+
}
|
|
903
|
+
if (n < 1e4) {
|
|
904
|
+
return ` ${n}`;
|
|
905
|
+
}
|
|
906
|
+
if (n < 1e5) {
|
|
907
|
+
return ` ${n}`;
|
|
908
|
+
}
|
|
909
|
+
if (n < 1e6) {
|
|
910
|
+
return ` ${n}`;
|
|
911
|
+
}
|
|
912
|
+
return `${n}`;
|
|
913
|
+
};
|
|
914
|
+
const sortAlpha = (lhs, rhs) => {
|
|
915
|
+
if (lhs.lower < rhs.lower) {
|
|
916
|
+
return -1;
|
|
917
|
+
}
|
|
918
|
+
if (lhs.lower > rhs.lower) {
|
|
919
|
+
return 1;
|
|
920
|
+
}
|
|
921
|
+
return 0;
|
|
922
|
+
};
|
|
923
|
+
const sortHits = (lhs, rhs) => {
|
|
924
|
+
if (lhs.total < rhs.total) {
|
|
925
|
+
return 1;
|
|
926
|
+
}
|
|
927
|
+
if (lhs.total > rhs.total) {
|
|
928
|
+
return -1;
|
|
929
|
+
}
|
|
930
|
+
return sortAlpha(lhs, rhs);
|
|
931
|
+
};
|
|
932
|
+
const sortIndex = (lhs, rhs) => {
|
|
933
|
+
if (lhs.index < rhs.index) {
|
|
934
|
+
return -1;
|
|
935
|
+
}
|
|
936
|
+
if (lhs.index > rhs.index) {
|
|
937
|
+
return 1;
|
|
938
|
+
}
|
|
939
|
+
return 0;
|
|
940
|
+
};
|
|
941
|
+
const EmptyStat = function fnempty() {
|
|
942
|
+
this.empty = 0;
|
|
943
|
+
this.match = 0;
|
|
944
|
+
this.nomatch = 0;
|
|
945
|
+
this.total = 0;
|
|
946
|
+
};
|
|
947
|
+
const clear = () => {
|
|
948
|
+
stats.length = 0;
|
|
949
|
+
totals = new EmptyStat();
|
|
950
|
+
stats[id.ALT] = new EmptyStat();
|
|
951
|
+
stats[id.CAT] = new EmptyStat();
|
|
952
|
+
stats[id.REP] = new EmptyStat();
|
|
953
|
+
stats[id.RNM] = new EmptyStat();
|
|
954
|
+
stats[id.TRG] = new EmptyStat();
|
|
955
|
+
stats[id.TBS] = new EmptyStat();
|
|
956
|
+
stats[id.TLS] = new EmptyStat();
|
|
957
|
+
stats[id.UDT] = new EmptyStat();
|
|
958
|
+
stats[id.AND] = new EmptyStat();
|
|
959
|
+
stats[id.NOT] = new EmptyStat();
|
|
960
|
+
ruleStats.length = 0;
|
|
961
|
+
for (let i = 0; i < rules.length; i += 1) {
|
|
962
|
+
ruleStats.push({
|
|
963
|
+
empty: 0,
|
|
964
|
+
match: 0,
|
|
965
|
+
nomatch: 0,
|
|
966
|
+
total: 0,
|
|
967
|
+
name: rules[i].name,
|
|
968
|
+
lower: rules[i].lower,
|
|
969
|
+
index: rules[i].index
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
if (udts.length > 0) {
|
|
973
|
+
udtStats.length = 0;
|
|
974
|
+
for (let i = 0; i < udts.length; i += 1) {
|
|
975
|
+
udtStats.push({
|
|
976
|
+
empty: 0,
|
|
977
|
+
match: 0,
|
|
978
|
+
nomatch: 0,
|
|
979
|
+
total: 0,
|
|
980
|
+
name: udts[i].name,
|
|
981
|
+
lower: udts[i].lower,
|
|
982
|
+
index: udts[i].index
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
const incStat = (stat, state) => {
|
|
988
|
+
stat.total += 1;
|
|
989
|
+
switch (state) {
|
|
990
|
+
case id.EMPTY:
|
|
991
|
+
stat.empty += 1;
|
|
992
|
+
break;
|
|
993
|
+
case id.MATCH:
|
|
994
|
+
stat.match += 1;
|
|
995
|
+
break;
|
|
996
|
+
case id.NOMATCH:
|
|
997
|
+
stat.nomatch += 1;
|
|
998
|
+
break;
|
|
999
|
+
default:
|
|
1000
|
+
throw new Error(`${thisFileName}collect(): incStat(): unrecognized state: ${state}`);
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
};
|
|
1004
|
+
var utilities = {
|
|
1005
|
+
// utility functions
|
|
1006
|
+
stringToChars: (string) => [...string].map((cp) => cp.codePointAt(0)),
|
|
1007
|
+
charsToString: (chars, beg, len) => {
|
|
1008
|
+
let subChars = chars;
|
|
1009
|
+
while (1) {
|
|
1010
|
+
if (beg === void 0 || beg < 0) {
|
|
1011
|
+
break;
|
|
1012
|
+
}
|
|
1013
|
+
if (len === void 0) {
|
|
1014
|
+
subChars = chars.slice(beg);
|
|
1015
|
+
break;
|
|
1016
|
+
}
|
|
1017
|
+
if (len <= 0) {
|
|
1018
|
+
return "";
|
|
1019
|
+
}
|
|
1020
|
+
subChars = chars.slice(beg, beg + len);
|
|
1021
|
+
break;
|
|
1022
|
+
}
|
|
1023
|
+
return String.fromCodePoint(...subChars);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
var identifiers = {
|
|
1027
|
+
// Identifies the operator type.
|
|
1028
|
+
// NB: These must match the values in apg-js 4.3.0, apg-lib/identifiers.
|
|
1029
|
+
/* the original ABNF operators */
|
|
1030
|
+
ALT: 1,
|
|
1031
|
+
CAT: 2,
|
|
1032
|
+
REP: 3,
|
|
1033
|
+
RNM: 4,
|
|
1034
|
+
TRG: 5,
|
|
1035
|
+
TBS: 6,
|
|
1036
|
+
TLS: 7,
|
|
1037
|
+
/* the super set, SABNF operators */
|
|
1038
|
+
UDT: 11,
|
|
1039
|
+
AND: 12,
|
|
1040
|
+
NOT: 13,
|
|
1041
|
+
// Used by the parser and the user's `RNM` and `UDT` callback functions.
|
|
1042
|
+
// Identifies the parser state as it traverses the parse tree nodes.
|
|
1043
|
+
// - *ACTIVE* - indicates the downward direction through the parse tree node.
|
|
1044
|
+
// - *MATCH* - indicates the upward direction and a phrase, of length \> 0, has been successfully matched
|
|
1045
|
+
// - *EMPTY* - indicates the upward direction and a phrase, of length = 0, has been successfully matched
|
|
1046
|
+
// - *NOMATCH* - indicates the upward direction and the parser failed to match any phrase at all
|
|
1047
|
+
ACTIVE: 100,
|
|
1048
|
+
MATCH: 101,
|
|
1049
|
+
EMPTY: 102,
|
|
1050
|
+
NOMATCH: 103,
|
|
1051
|
+
// Used by [`AST` translator](./ast.html) (semantic analysis) and the user's callback functions
|
|
1052
|
+
// to indicate the direction of flow through the `AST` nodes.
|
|
1053
|
+
// - *SEM_PRE* - indicates the downward (pre-branch) direction through the `AST` node.
|
|
1054
|
+
// - *SEM_POST* - indicates the upward (post-branch) direction through the `AST` node.
|
|
1055
|
+
SEM_PRE: 200,
|
|
1056
|
+
SEM_POST: 201,
|
|
1057
|
+
// Ignored. Retained for backwords compatibility.
|
|
1058
|
+
SEM_OK: 300,
|
|
1059
|
+
idName: (s) => {
|
|
1060
|
+
switch (s) {
|
|
1061
|
+
case identifiers.ALT:
|
|
1062
|
+
return "ALT";
|
|
1063
|
+
case identifiers.CAT:
|
|
1064
|
+
return "CAT";
|
|
1065
|
+
case identifiers.REP:
|
|
1066
|
+
return "REP";
|
|
1067
|
+
case identifiers.RNM:
|
|
1068
|
+
return "RNM";
|
|
1069
|
+
case identifiers.TRG:
|
|
1070
|
+
return "TRG";
|
|
1071
|
+
case identifiers.TBS:
|
|
1072
|
+
return "TBS";
|
|
1073
|
+
case identifiers.TLS:
|
|
1074
|
+
return "TLS";
|
|
1075
|
+
case identifiers.UDT:
|
|
1076
|
+
return "UDT";
|
|
1077
|
+
case identifiers.AND:
|
|
1078
|
+
return "AND";
|
|
1079
|
+
case identifiers.NOT:
|
|
1080
|
+
return "NOT";
|
|
1081
|
+
case identifiers.ACTIVE:
|
|
1082
|
+
return "ACTIVE";
|
|
1083
|
+
case identifiers.EMPTY:
|
|
1084
|
+
return "EMPTY";
|
|
1085
|
+
case identifiers.MATCH:
|
|
1086
|
+
return "MATCH";
|
|
1087
|
+
case identifiers.NOMATCH:
|
|
1088
|
+
return "NOMATCH";
|
|
1089
|
+
case identifiers.SEM_PRE:
|
|
1090
|
+
return "SEM_PRE";
|
|
1091
|
+
case identifiers.SEM_POST:
|
|
1092
|
+
return "SEM_POST";
|
|
1093
|
+
case identifiers.SEM_OK:
|
|
1094
|
+
return "SEM_OK";
|
|
1095
|
+
default:
|
|
1096
|
+
return "UNRECOGNIZED STATE";
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
// ../../node_modules/.bun/openapi-server-url-templating@1.3.0/node_modules/openapi-server-url-templating/es/server-url-templating.mjs
|
|
1102
|
+
function grammar() {
|
|
1103
|
+
this.grammarObject = "grammarObject";
|
|
1104
|
+
this.rules = [];
|
|
1105
|
+
this.rules[0] = {
|
|
1106
|
+
name: "server-url-template",
|
|
1107
|
+
lower: "server-url-template",
|
|
1108
|
+
index: 0,
|
|
1109
|
+
isBkr: false
|
|
1110
|
+
};
|
|
1111
|
+
this.rules[1] = {
|
|
1112
|
+
name: "server-variable",
|
|
1113
|
+
lower: "server-variable",
|
|
1114
|
+
index: 1,
|
|
1115
|
+
isBkr: false
|
|
1116
|
+
};
|
|
1117
|
+
this.rules[2] = {
|
|
1118
|
+
name: "server-variable-name",
|
|
1119
|
+
lower: "server-variable-name",
|
|
1120
|
+
index: 2,
|
|
1121
|
+
isBkr: false
|
|
1122
|
+
};
|
|
1123
|
+
this.rules[3] = {
|
|
1124
|
+
name: "literals",
|
|
1125
|
+
lower: "literals",
|
|
1126
|
+
index: 3,
|
|
1127
|
+
isBkr: false
|
|
1128
|
+
};
|
|
1129
|
+
this.rules[4] = {
|
|
1130
|
+
name: "DIGIT",
|
|
1131
|
+
lower: "digit",
|
|
1132
|
+
index: 4,
|
|
1133
|
+
isBkr: false
|
|
1134
|
+
};
|
|
1135
|
+
this.rules[5] = {
|
|
1136
|
+
name: "HEXDIG",
|
|
1137
|
+
lower: "hexdig",
|
|
1138
|
+
index: 5,
|
|
1139
|
+
isBkr: false
|
|
1140
|
+
};
|
|
1141
|
+
this.rules[6] = {
|
|
1142
|
+
name: "pct-encoded",
|
|
1143
|
+
lower: "pct-encoded",
|
|
1144
|
+
index: 6,
|
|
1145
|
+
isBkr: false
|
|
1146
|
+
};
|
|
1147
|
+
this.rules[7] = {
|
|
1148
|
+
name: "ucschar",
|
|
1149
|
+
lower: "ucschar",
|
|
1150
|
+
index: 7,
|
|
1151
|
+
isBkr: false
|
|
1152
|
+
};
|
|
1153
|
+
this.rules[8] = {
|
|
1154
|
+
name: "iprivate",
|
|
1155
|
+
lower: "iprivate",
|
|
1156
|
+
index: 8,
|
|
1157
|
+
isBkr: false
|
|
1158
|
+
};
|
|
1159
|
+
this.udts = [];
|
|
1160
|
+
this.rules[0].opcodes = [];
|
|
1161
|
+
this.rules[0].opcodes[0] = {
|
|
1162
|
+
type: 3,
|
|
1163
|
+
min: 1,
|
|
1164
|
+
max: Infinity
|
|
1165
|
+
};
|
|
1166
|
+
this.rules[0].opcodes[1] = {
|
|
1167
|
+
type: 1,
|
|
1168
|
+
children: [2, 3]
|
|
1169
|
+
};
|
|
1170
|
+
this.rules[0].opcodes[2] = {
|
|
1171
|
+
type: 4,
|
|
1172
|
+
index: 3
|
|
1173
|
+
};
|
|
1174
|
+
this.rules[0].opcodes[3] = {
|
|
1175
|
+
type: 4,
|
|
1176
|
+
index: 1
|
|
1177
|
+
};
|
|
1178
|
+
this.rules[1].opcodes = [];
|
|
1179
|
+
this.rules[1].opcodes[0] = {
|
|
1180
|
+
type: 2,
|
|
1181
|
+
children: [1, 2, 3]
|
|
1182
|
+
};
|
|
1183
|
+
this.rules[1].opcodes[1] = {
|
|
1184
|
+
type: 7,
|
|
1185
|
+
string: [123]
|
|
1186
|
+
};
|
|
1187
|
+
this.rules[1].opcodes[2] = {
|
|
1188
|
+
type: 4,
|
|
1189
|
+
index: 2
|
|
1190
|
+
};
|
|
1191
|
+
this.rules[1].opcodes[3] = {
|
|
1192
|
+
type: 7,
|
|
1193
|
+
string: [125]
|
|
1194
|
+
};
|
|
1195
|
+
this.rules[2].opcodes = [];
|
|
1196
|
+
this.rules[2].opcodes[0] = {
|
|
1197
|
+
type: 3,
|
|
1198
|
+
min: 1,
|
|
1199
|
+
max: Infinity
|
|
1200
|
+
};
|
|
1201
|
+
this.rules[2].opcodes[1] = {
|
|
1202
|
+
type: 1,
|
|
1203
|
+
children: [2, 3, 4]
|
|
1204
|
+
};
|
|
1205
|
+
this.rules[2].opcodes[2] = {
|
|
1206
|
+
type: 5,
|
|
1207
|
+
min: 0,
|
|
1208
|
+
max: 122
|
|
1209
|
+
};
|
|
1210
|
+
this.rules[2].opcodes[3] = {
|
|
1211
|
+
type: 6,
|
|
1212
|
+
string: [124]
|
|
1213
|
+
};
|
|
1214
|
+
this.rules[2].opcodes[4] = {
|
|
1215
|
+
type: 5,
|
|
1216
|
+
min: 126,
|
|
1217
|
+
max: 1114111
|
|
1218
|
+
};
|
|
1219
|
+
this.rules[3].opcodes = [];
|
|
1220
|
+
this.rules[3].opcodes[0] = {
|
|
1221
|
+
type: 3,
|
|
1222
|
+
min: 1,
|
|
1223
|
+
max: Infinity
|
|
1224
|
+
};
|
|
1225
|
+
this.rules[3].opcodes[1] = {
|
|
1226
|
+
type: 1,
|
|
1227
|
+
children: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
|
1228
|
+
};
|
|
1229
|
+
this.rules[3].opcodes[2] = {
|
|
1230
|
+
type: 6,
|
|
1231
|
+
string: [33]
|
|
1232
|
+
};
|
|
1233
|
+
this.rules[3].opcodes[3] = {
|
|
1234
|
+
type: 5,
|
|
1235
|
+
min: 35,
|
|
1236
|
+
max: 36
|
|
1237
|
+
};
|
|
1238
|
+
this.rules[3].opcodes[4] = {
|
|
1239
|
+
type: 5,
|
|
1240
|
+
min: 38,
|
|
1241
|
+
max: 59
|
|
1242
|
+
};
|
|
1243
|
+
this.rules[3].opcodes[5] = {
|
|
1244
|
+
type: 6,
|
|
1245
|
+
string: [61]
|
|
1246
|
+
};
|
|
1247
|
+
this.rules[3].opcodes[6] = {
|
|
1248
|
+
type: 5,
|
|
1249
|
+
min: 63,
|
|
1250
|
+
max: 91
|
|
1251
|
+
};
|
|
1252
|
+
this.rules[3].opcodes[7] = {
|
|
1253
|
+
type: 6,
|
|
1254
|
+
string: [93]
|
|
1255
|
+
};
|
|
1256
|
+
this.rules[3].opcodes[8] = {
|
|
1257
|
+
type: 6,
|
|
1258
|
+
string: [95]
|
|
1259
|
+
};
|
|
1260
|
+
this.rules[3].opcodes[9] = {
|
|
1261
|
+
type: 5,
|
|
1262
|
+
min: 97,
|
|
1263
|
+
max: 122
|
|
1264
|
+
};
|
|
1265
|
+
this.rules[3].opcodes[10] = {
|
|
1266
|
+
type: 6,
|
|
1267
|
+
string: [126]
|
|
1268
|
+
};
|
|
1269
|
+
this.rules[3].opcodes[11] = {
|
|
1270
|
+
type: 4,
|
|
1271
|
+
index: 7
|
|
1272
|
+
};
|
|
1273
|
+
this.rules[3].opcodes[12] = {
|
|
1274
|
+
type: 4,
|
|
1275
|
+
index: 8
|
|
1276
|
+
};
|
|
1277
|
+
this.rules[3].opcodes[13] = {
|
|
1278
|
+
type: 4,
|
|
1279
|
+
index: 6
|
|
1280
|
+
};
|
|
1281
|
+
this.rules[4].opcodes = [];
|
|
1282
|
+
this.rules[4].opcodes[0] = {
|
|
1283
|
+
type: 5,
|
|
1284
|
+
min: 48,
|
|
1285
|
+
max: 57
|
|
1286
|
+
};
|
|
1287
|
+
this.rules[5].opcodes = [];
|
|
1288
|
+
this.rules[5].opcodes[0] = {
|
|
1289
|
+
type: 1,
|
|
1290
|
+
children: [1, 2, 3, 4, 5, 6, 7]
|
|
1291
|
+
};
|
|
1292
|
+
this.rules[5].opcodes[1] = {
|
|
1293
|
+
type: 4,
|
|
1294
|
+
index: 4
|
|
1295
|
+
};
|
|
1296
|
+
this.rules[5].opcodes[2] = {
|
|
1297
|
+
type: 7,
|
|
1298
|
+
string: [97]
|
|
1299
|
+
};
|
|
1300
|
+
this.rules[5].opcodes[3] = {
|
|
1301
|
+
type: 7,
|
|
1302
|
+
string: [98]
|
|
1303
|
+
};
|
|
1304
|
+
this.rules[5].opcodes[4] = {
|
|
1305
|
+
type: 7,
|
|
1306
|
+
string: [99]
|
|
1307
|
+
};
|
|
1308
|
+
this.rules[5].opcodes[5] = {
|
|
1309
|
+
type: 7,
|
|
1310
|
+
string: [100]
|
|
1311
|
+
};
|
|
1312
|
+
this.rules[5].opcodes[6] = {
|
|
1313
|
+
type: 7,
|
|
1314
|
+
string: [101]
|
|
1315
|
+
};
|
|
1316
|
+
this.rules[5].opcodes[7] = {
|
|
1317
|
+
type: 7,
|
|
1318
|
+
string: [102]
|
|
1319
|
+
};
|
|
1320
|
+
this.rules[6].opcodes = [];
|
|
1321
|
+
this.rules[6].opcodes[0] = {
|
|
1322
|
+
type: 2,
|
|
1323
|
+
children: [1, 2, 3]
|
|
1324
|
+
};
|
|
1325
|
+
this.rules[6].opcodes[1] = {
|
|
1326
|
+
type: 7,
|
|
1327
|
+
string: [37]
|
|
1328
|
+
};
|
|
1329
|
+
this.rules[6].opcodes[2] = {
|
|
1330
|
+
type: 4,
|
|
1331
|
+
index: 5
|
|
1332
|
+
};
|
|
1333
|
+
this.rules[6].opcodes[3] = {
|
|
1334
|
+
type: 4,
|
|
1335
|
+
index: 5
|
|
1336
|
+
};
|
|
1337
|
+
this.rules[7].opcodes = [];
|
|
1338
|
+
this.rules[7].opcodes[0] = {
|
|
1339
|
+
type: 1,
|
|
1340
|
+
children: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
|
|
1341
|
+
};
|
|
1342
|
+
this.rules[7].opcodes[1] = {
|
|
1343
|
+
type: 5,
|
|
1344
|
+
min: 160,
|
|
1345
|
+
max: 55295
|
|
1346
|
+
};
|
|
1347
|
+
this.rules[7].opcodes[2] = {
|
|
1348
|
+
type: 5,
|
|
1349
|
+
min: 63744,
|
|
1350
|
+
max: 64975
|
|
1351
|
+
};
|
|
1352
|
+
this.rules[7].opcodes[3] = {
|
|
1353
|
+
type: 5,
|
|
1354
|
+
min: 65008,
|
|
1355
|
+
max: 65519
|
|
1356
|
+
};
|
|
1357
|
+
this.rules[7].opcodes[4] = {
|
|
1358
|
+
type: 5,
|
|
1359
|
+
min: 65536,
|
|
1360
|
+
max: 131069
|
|
1361
|
+
};
|
|
1362
|
+
this.rules[7].opcodes[5] = {
|
|
1363
|
+
type: 5,
|
|
1364
|
+
min: 131072,
|
|
1365
|
+
max: 196605
|
|
1366
|
+
};
|
|
1367
|
+
this.rules[7].opcodes[6] = {
|
|
1368
|
+
type: 5,
|
|
1369
|
+
min: 196608,
|
|
1370
|
+
max: 262141
|
|
1371
|
+
};
|
|
1372
|
+
this.rules[7].opcodes[7] = {
|
|
1373
|
+
type: 5,
|
|
1374
|
+
min: 262144,
|
|
1375
|
+
max: 327677
|
|
1376
|
+
};
|
|
1377
|
+
this.rules[7].opcodes[8] = {
|
|
1378
|
+
type: 5,
|
|
1379
|
+
min: 327680,
|
|
1380
|
+
max: 393213
|
|
1381
|
+
};
|
|
1382
|
+
this.rules[7].opcodes[9] = {
|
|
1383
|
+
type: 5,
|
|
1384
|
+
min: 393216,
|
|
1385
|
+
max: 458749
|
|
1386
|
+
};
|
|
1387
|
+
this.rules[7].opcodes[10] = {
|
|
1388
|
+
type: 5,
|
|
1389
|
+
min: 458752,
|
|
1390
|
+
max: 524285
|
|
1391
|
+
};
|
|
1392
|
+
this.rules[7].opcodes[11] = {
|
|
1393
|
+
type: 5,
|
|
1394
|
+
min: 524288,
|
|
1395
|
+
max: 589821
|
|
1396
|
+
};
|
|
1397
|
+
this.rules[7].opcodes[12] = {
|
|
1398
|
+
type: 5,
|
|
1399
|
+
min: 589824,
|
|
1400
|
+
max: 655357
|
|
1401
|
+
};
|
|
1402
|
+
this.rules[7].opcodes[13] = {
|
|
1403
|
+
type: 5,
|
|
1404
|
+
min: 655360,
|
|
1405
|
+
max: 720893
|
|
1406
|
+
};
|
|
1407
|
+
this.rules[7].opcodes[14] = {
|
|
1408
|
+
type: 5,
|
|
1409
|
+
min: 720896,
|
|
1410
|
+
max: 786429
|
|
1411
|
+
};
|
|
1412
|
+
this.rules[7].opcodes[15] = {
|
|
1413
|
+
type: 5,
|
|
1414
|
+
min: 786432,
|
|
1415
|
+
max: 851965
|
|
1416
|
+
};
|
|
1417
|
+
this.rules[7].opcodes[16] = {
|
|
1418
|
+
type: 5,
|
|
1419
|
+
min: 851968,
|
|
1420
|
+
max: 917501
|
|
1421
|
+
};
|
|
1422
|
+
this.rules[7].opcodes[17] = {
|
|
1423
|
+
type: 5,
|
|
1424
|
+
min: 921600,
|
|
1425
|
+
max: 983037
|
|
1426
|
+
};
|
|
1427
|
+
this.rules[8].opcodes = [];
|
|
1428
|
+
this.rules[8].opcodes[0] = {
|
|
1429
|
+
type: 1,
|
|
1430
|
+
children: [1, 2, 3]
|
|
1431
|
+
};
|
|
1432
|
+
this.rules[8].opcodes[1] = {
|
|
1433
|
+
type: 5,
|
|
1434
|
+
min: 57344,
|
|
1435
|
+
max: 63743
|
|
1436
|
+
};
|
|
1437
|
+
this.rules[8].opcodes[2] = {
|
|
1438
|
+
type: 5,
|
|
1439
|
+
min: 983040,
|
|
1440
|
+
max: 1048573
|
|
1441
|
+
};
|
|
1442
|
+
this.rules[8].opcodes[3] = {
|
|
1443
|
+
type: 5,
|
|
1444
|
+
min: 1048576,
|
|
1445
|
+
max: 1114109
|
|
1446
|
+
};
|
|
1447
|
+
this.toString = function toString() {
|
|
1448
|
+
let str = "";
|
|
1449
|
+
str += "; OpenAPI Server URL templating ABNF syntax\n";
|
|
1450
|
+
str += "server-url-template = 1*( literals / server-variable ) ; variant of https://www.rfc-editor.org/rfc/rfc6570#section-2\n";
|
|
1451
|
+
str += 'server-variable = "{" server-variable-name "}"\n';
|
|
1452
|
+
str += "server-variable-name = 1*( %x00-7A / %x7C / %x7E-10FFFF ) ; every UTF8 character except { and } (from OpenAPI)\n";
|
|
1453
|
+
str += "\n";
|
|
1454
|
+
str += "; https://www.rfc-editor.org/rfc/rfc6570#section-2.1\n";
|
|
1455
|
+
str += "; https://www.rfc-editor.org/errata/eid6937\n";
|
|
1456
|
+
str += "literals = 1*( %x21 / %x23-24 / %x26-3B / %x3D / %x3F-5B\n";
|
|
1457
|
+
str += " / %x5D / %x5F / %x61-7A / %x7E / ucschar / iprivate\n";
|
|
1458
|
+
str += " / pct-encoded)\n";
|
|
1459
|
+
str += " ; any Unicode character except: CTL, SP,\n";
|
|
1460
|
+
str += ' ; DQUOTE, "%" (aside from pct-encoded),\n';
|
|
1461
|
+
str += ' ; "<", ">", "\\", "^", "`", "{", "|", "}"\n';
|
|
1462
|
+
str += "\n";
|
|
1463
|
+
str += "; https://www.rfc-editor.org/rfc/rfc6570#section-1.5\n";
|
|
1464
|
+
str += "DIGIT = %x30-39 ; 0-9\n";
|
|
1465
|
+
str += 'HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F" ; case-insensitive\n';
|
|
1466
|
+
str += "\n";
|
|
1467
|
+
str += 'pct-encoded = "%" HEXDIG HEXDIG\n';
|
|
1468
|
+
str += "\n";
|
|
1469
|
+
str += "ucschar = %xA0-D7FF / %xF900-FDCF / %xFDF0-FFEF\n";
|
|
1470
|
+
str += " / %x10000-1FFFD / %x20000-2FFFD / %x30000-3FFFD\n";
|
|
1471
|
+
str += " / %x40000-4FFFD / %x50000-5FFFD / %x60000-6FFFD\n";
|
|
1472
|
+
str += " / %x70000-7FFFD / %x80000-8FFFD / %x90000-9FFFD\n";
|
|
1473
|
+
str += " / %xA0000-AFFFD / %xB0000-BFFFD / %xC0000-CFFFD\n";
|
|
1474
|
+
str += " / %xD0000-DFFFD / %xE1000-EFFFD\n";
|
|
1475
|
+
str += "\n";
|
|
1476
|
+
str += "iprivate = %xE000-F8FF / %xF0000-FFFFD / %x100000-10FFFD\n";
|
|
1477
|
+
return str;
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
// ../../node_modules/.bun/openapi-server-url-templating@1.3.0/node_modules/openapi-server-url-templating/es/parse/callbacks/server-url-template.mjs
|
|
1482
|
+
var serverUrlTemplate = (state, chars, phraseIndex, phraseLength, data) => {
|
|
1483
|
+
if (state === identifiers.SEM_PRE) {
|
|
1484
|
+
if (Array.isArray(data) === false) {
|
|
1485
|
+
throw new Error("parser's user data must be an array");
|
|
1486
|
+
}
|
|
1487
|
+
data.push(["server-url-template", utilities.charsToString(chars, phraseIndex, phraseLength)]);
|
|
1488
|
+
}
|
|
1489
|
+
return identifiers.SEM_OK;
|
|
1490
|
+
};
|
|
1491
|
+
var server_url_template_default = serverUrlTemplate;
|
|
1492
|
+
|
|
1493
|
+
// ../../node_modules/.bun/openapi-server-url-templating@1.3.0/node_modules/openapi-server-url-templating/es/parse/callbacks/server-variable.mjs
|
|
1494
|
+
var serverVariable = (state, chars, phraseIndex, phraseLength, data) => {
|
|
1495
|
+
if (state === identifiers.SEM_PRE) {
|
|
1496
|
+
if (Array.isArray(data) === false) {
|
|
1497
|
+
throw new Error("parser's user data must be an array");
|
|
1498
|
+
}
|
|
1499
|
+
data.push(["server-variable", utilities.charsToString(chars, phraseIndex, phraseLength)]);
|
|
1500
|
+
}
|
|
1501
|
+
return identifiers.SEM_OK;
|
|
1502
|
+
};
|
|
1503
|
+
var server_variable_default = serverVariable;
|
|
1504
|
+
|
|
1505
|
+
// ../../node_modules/.bun/openapi-server-url-templating@1.3.0/node_modules/openapi-server-url-templating/es/parse/callbacks/server-variable-name.mjs
|
|
1506
|
+
var serverVariableName = (state, chars, phraseIndex, phraseLength, data) => {
|
|
1507
|
+
if (state === identifiers.SEM_PRE) {
|
|
1508
|
+
if (Array.isArray(data) === false) {
|
|
1509
|
+
throw new Error("parser's user data must be an array");
|
|
1510
|
+
}
|
|
1511
|
+
data.push(["server-variable-name", utilities.charsToString(chars, phraseIndex, phraseLength)]);
|
|
1512
|
+
}
|
|
1513
|
+
return identifiers.SEM_OK;
|
|
1514
|
+
};
|
|
1515
|
+
var server_variable_name_default = serverVariableName;
|
|
1516
|
+
|
|
1517
|
+
// ../../node_modules/.bun/openapi-server-url-templating@1.3.0/node_modules/openapi-server-url-templating/es/parse/callbacks/literals.mjs
|
|
1518
|
+
var literals = (state, chars, phraseIndex, phraseLength, data) => {
|
|
1519
|
+
if (state === identifiers.SEM_PRE) {
|
|
1520
|
+
if (Array.isArray(data) === false) {
|
|
1521
|
+
throw new Error("parser's user data must be an array");
|
|
1522
|
+
}
|
|
1523
|
+
data.push(["literals", utilities.charsToString(chars, phraseIndex, phraseLength)]);
|
|
1524
|
+
}
|
|
1525
|
+
return identifiers.SEM_OK;
|
|
1526
|
+
};
|
|
1527
|
+
var literals_default = literals;
|
|
1528
|
+
|
|
1529
|
+
// ../../node_modules/.bun/openapi-server-url-templating@1.3.0/node_modules/openapi-server-url-templating/es/parse/index.mjs
|
|
1530
|
+
var grammar2 = new grammar();
|
|
1531
|
+
var parse = (serverURLTemplate) => {
|
|
1532
|
+
const parser = new Parser();
|
|
1533
|
+
parser.ast = new Ast();
|
|
1534
|
+
parser.ast.callbacks["server-url-template"] = server_url_template_default;
|
|
1535
|
+
parser.ast.callbacks["server-variable"] = server_variable_default;
|
|
1536
|
+
parser.ast.callbacks["server-variable-name"] = server_variable_name_default;
|
|
1537
|
+
parser.ast.callbacks["literals"] = literals_default;
|
|
1538
|
+
const result = parser.parse(grammar2, "server-url-template", serverURLTemplate);
|
|
1539
|
+
return {
|
|
1540
|
+
result,
|
|
1541
|
+
ast: parser.ast
|
|
1542
|
+
};
|
|
1543
|
+
};
|
|
1544
|
+
var parse_default = parse;
|
|
1545
|
+
|
|
1546
|
+
// ../../node_modules/.bun/openapi-server-url-templating@1.3.0/node_modules/openapi-server-url-templating/es/test.mjs
|
|
1547
|
+
var test = (serverURLTemplate, {
|
|
1548
|
+
strict = false
|
|
1549
|
+
} = {}) => {
|
|
1550
|
+
try {
|
|
1551
|
+
const parseResult = parse_default(serverURLTemplate);
|
|
1552
|
+
if (!parseResult.result.success) return false;
|
|
1553
|
+
const parts = [];
|
|
1554
|
+
parseResult.ast.translate(parts);
|
|
1555
|
+
const hasServerVariable = parts.some(([type]) => type === "server-variable");
|
|
1556
|
+
if (!strict && !hasServerVariable) {
|
|
1557
|
+
try {
|
|
1558
|
+
new URL(serverURLTemplate, "https://vladimirgorej.com");
|
|
1559
|
+
return true;
|
|
1560
|
+
} catch {
|
|
1561
|
+
return false;
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
return strict ? hasServerVariable : true;
|
|
1565
|
+
} catch {
|
|
1566
|
+
return false;
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
var test_default = test;
|
|
1570
|
+
|
|
1571
|
+
// ../../node_modules/.bun/openapi-server-url-templating@1.3.0/node_modules/openapi-server-url-templating/es/substitute.mjs
|
|
1572
|
+
var isEncoded = (serverVariableValue) => {
|
|
1573
|
+
try {
|
|
1574
|
+
return typeof serverVariableValue === "string" && decodeURIComponent(serverVariableValue) !== serverVariableValue;
|
|
1575
|
+
} catch {
|
|
1576
|
+
return false;
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
var encodeServerVariable = (serverVariableValue) => {
|
|
1580
|
+
if (isEncoded(serverVariableValue)) {
|
|
1581
|
+
return serverVariableValue;
|
|
1582
|
+
}
|
|
1583
|
+
return encodeURIComponent(serverVariableValue).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
|
1584
|
+
};
|
|
1585
|
+
var significantTypes = ["literals", "server-variable-name"];
|
|
1586
|
+
var substitute = (serverURLTemplate, serverVariables, options = {}) => {
|
|
1587
|
+
const defaultOptions = {
|
|
1588
|
+
encoder: encodeServerVariable
|
|
1589
|
+
};
|
|
1590
|
+
const mergedOptions = {
|
|
1591
|
+
...defaultOptions,
|
|
1592
|
+
...options
|
|
1593
|
+
};
|
|
1594
|
+
const parseResult = parse_default(serverURLTemplate);
|
|
1595
|
+
if (!parseResult.result.success) return serverURLTemplate;
|
|
1596
|
+
const parts = [];
|
|
1597
|
+
parseResult.ast.translate(parts);
|
|
1598
|
+
const substitutedParts = parts.filter(([type]) => significantTypes.includes(type)).map(([type, value]) => {
|
|
1599
|
+
if (type === "server-variable-name") {
|
|
1600
|
+
return Object.hasOwn(serverVariables, value) ? mergedOptions.encoder(serverVariables[value], value) : `{${value}}`;
|
|
1601
|
+
}
|
|
1602
|
+
return value;
|
|
1603
|
+
});
|
|
1604
|
+
return substitutedParts.join("");
|
|
1605
|
+
};
|
|
1606
|
+
var substitute_default = substitute;
|
|
1607
|
+
|
|
1608
|
+
export {
|
|
1609
|
+
Parser,
|
|
1610
|
+
Ast,
|
|
1611
|
+
Trace,
|
|
1612
|
+
Stats,
|
|
1613
|
+
utilities,
|
|
1614
|
+
identifiers,
|
|
1615
|
+
test_default,
|
|
1616
|
+
substitute_default
|
|
1617
|
+
};
|