@zwave-js/config 15.15.3 → 15.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/build/cjs/JsonTemplate.js +2 -2
  2. package/build/cjs/JsonTemplate.js.map +2 -2
  3. package/build/cjs/Logic.d.ts +1 -1
  4. package/build/cjs/Logic.js +6 -7
  5. package/build/cjs/Logic.js.map +2 -2
  6. package/build/cjs/LogicParser.d.ts +66 -84
  7. package/build/cjs/LogicParser.js +410 -1337
  8. package/build/cjs/LogicParser.js.map +3 -3
  9. package/build/cjs/Manufacturers.js +1 -1
  10. package/build/cjs/Manufacturers.js.map +2 -2
  11. package/build/cjs/_version.d.ts +1 -1
  12. package/build/cjs/_version.js +1 -1
  13. package/build/cjs/_version.js.map +1 -1
  14. package/build/cjs/devices/DeviceConfig.d.ts +3 -3
  15. package/build/cjs/devices/DeviceConfig.js +3 -3
  16. package/build/cjs/devices/DeviceConfig.js.map +2 -2
  17. package/build/cjs/devices/DeviceConfig.unit._test.js.map +1 -1
  18. package/build/cjs/devices/ParamInformation.d.ts +2 -0
  19. package/build/cjs/devices/ParamInformation.js +16 -2
  20. package/build/cjs/devices/ParamInformation.js.map +2 -2
  21. package/build/cjs/index.js.map +2 -2
  22. package/build/esm/JsonTemplate.js +2 -2
  23. package/build/esm/JsonTemplate.js.map +1 -1
  24. package/build/esm/Logic.d.ts +1 -1
  25. package/build/esm/Logic.d.ts.map +1 -1
  26. package/build/esm/Logic.js +6 -8
  27. package/build/esm/Logic.js.map +1 -1
  28. package/build/esm/LogicParser.d.ts +66 -84
  29. package/build/esm/LogicParser.d.ts.map +1 -1
  30. package/build/esm/LogicParser.js +432 -2335
  31. package/build/esm/LogicParser.js.map +1 -1
  32. package/build/esm/Manufacturers.js +1 -1
  33. package/build/esm/Manufacturers.js.map +1 -1
  34. package/build/esm/_version.d.ts +1 -1
  35. package/build/esm/_version.js +1 -1
  36. package/build/esm/devices/DeviceConfig.d.ts +3 -3
  37. package/build/esm/devices/DeviceConfig.d.ts.map +1 -1
  38. package/build/esm/devices/DeviceConfig.js +4 -3
  39. package/build/esm/devices/DeviceConfig.js.map +1 -1
  40. package/build/esm/devices/DeviceConfig.unit._test.js +1 -0
  41. package/build/esm/devices/DeviceConfig.unit._test.js.map +1 -1
  42. package/build/esm/devices/ParamInformation.d.ts +2 -0
  43. package/build/esm/devices/ParamInformation.d.ts.map +1 -1
  44. package/build/esm/devices/ParamInformation.js +17 -2
  45. package/build/esm/devices/ParamInformation.js.map +1 -1
  46. package/build/esm/index.d.ts.map +1 -1
  47. package/build/esm/index.js +0 -1
  48. package/build/esm/index.js.map +1 -1
  49. package/config/devices/0x003b/be468zp.json +1 -1
  50. package/config/devices/0x003b/be469.json +2 -3
  51. package/config/devices/0x003b/be469zp.json +2 -3
  52. package/config/devices/0x0063/55258_zw4002.json +34 -1
  53. package/config/devices/0x0090/918.json +101 -0
  54. package/config/devices/0x0090/hc620.json +4 -0
  55. package/config/devices/0x0148/cometz_700.json +1 -1
  56. package/config/devices/0x021d/{ddl240x.json → ddl240x_15hzw.json} +1 -2
  57. package/config/devices/0x021d/ddl240x_1hzw.json +115 -0
  58. package/config/devices/0x027a/zse11.json +134 -0
  59. package/config/devices/0x0460/qlsh-001P10.json +119 -0
  60. package/config/devices/0x0460/qnpl-0A112.json +4 -0
  61. package/config/devices/0x0460/qnsw-001P16.json +15 -0
  62. package/config/devices/0x0460/qnsw-001X16.json +10 -0
  63. package/config/devices/0x0460/templates/wave_template.json +70 -0
  64. package/config/devices/0x0460/{qnsw-002P16.json → wave_2pm.json} +22 -1
  65. package/config/devices/templates/master_template.json +1 -1
  66. package/config/eslint.config.mjs +24 -19
  67. package/package.json +10 -12
@@ -19,1369 +19,442 @@ var __copyProps = (to, from, except, desc) => {
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var LogicParser_exports = {};
21
21
  __export(LogicParser_exports, {
22
- PeggySyntaxError: () => PeggySyntaxError,
23
- parse: () => parse
22
+ Operator: () => Operator,
23
+ SyntaxKind: () => SyntaxKind,
24
+ TokenKind: () => TokenKind,
25
+ parse: () => parse,
26
+ toRulesLogic: () => toRulesLogic,
27
+ tokenize: () => tokenize
24
28
  });
25
29
  module.exports = __toCommonJS(LogicParser_exports);
26
- const peggyParser = (
27
- // Generated by Peggy 3.0.2.
28
- //
29
- // https://peggyjs.org/
30
- // @ts-ignore
31
- (function() {
32
- "use strict";
33
- function peg$subclass(child, parent) {
34
- function C() {
35
- this.constructor = child;
36
- }
37
- __name(C, "C");
38
- C.prototype = parent.prototype;
39
- child.prototype = new C();
40
- }
41
- __name(peg$subclass, "peg$subclass");
42
- function peg$SyntaxError(message, expected, found, location) {
43
- var self = Error.call(this, message);
44
- if (Object.setPrototypeOf) {
45
- Object.setPrototypeOf(self, peg$SyntaxError.prototype);
46
- }
47
- self.expected = expected;
48
- self.found = found;
49
- self.location = location;
50
- self.name = "SyntaxError";
51
- return self;
52
- }
53
- __name(peg$SyntaxError, "peg$SyntaxError");
54
- peg$subclass(peg$SyntaxError, Error);
55
- function peg$padEnd(str, targetLength, padString) {
56
- padString = padString || " ";
57
- if (str.length > targetLength)
58
- return str;
59
- targetLength -= str.length;
60
- padString += padString.repeat(targetLength);
61
- return str + padString.slice(0, targetLength);
62
- }
63
- __name(peg$padEnd, "peg$padEnd");
64
- peg$SyntaxError.prototype.format = function(sources) {
65
- var str = "Error: " + this.message;
66
- if (this.location) {
67
- var src = null;
68
- var k;
69
- for (k = 0; k < sources.length; k++) {
70
- if (sources[k].source === this.location.source) {
71
- src = sources[k].text.split(/\r\n|\n|\r/g);
72
- break;
73
- }
74
- }
75
- var s = this.location.start;
76
- var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
77
- var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
78
- if (src) {
79
- var e = this.location.end;
80
- var filler = peg$padEnd("", offset_s.line.toString().length, " ");
81
- var line = src[s.line - 1];
82
- var last = s.line === e.line ? e.column : line.length + 1;
83
- var hatLen = last - s.column || 1;
84
- str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
85
- } else {
86
- str += "\n at " + loc;
87
- }
88
- }
89
- return str;
90
- };
91
- peg$SyntaxError.buildMessage = function(expected, found) {
92
- var DESCRIBE_EXPECTATION_FNS = {
93
- // @ts-ignore
94
- literal: /* @__PURE__ */ __name(function(expectation) {
95
- return '"' + literalEscape(expectation.text) + '"';
96
- }, "literal"),
97
- // @ts-ignore
98
- class: /* @__PURE__ */ __name(function(expectation) {
99
- var escapedParts = expectation.parts.map(function(part) {
100
- return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
101
- });
102
- return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
103
- }, "class"),
104
- // @ts-ignore
105
- any: /* @__PURE__ */ __name(function() {
106
- return "any character";
107
- }, "any"),
108
- // @ts-ignore
109
- end: /* @__PURE__ */ __name(function() {
110
- return "end of input";
111
- }, "end"),
112
- // @ts-ignore
113
- other: /* @__PURE__ */ __name(function(expectation) {
114
- return expectation.description;
115
- }, "other")
116
- };
117
- function hex(ch) {
118
- return ch.charCodeAt(0).toString(16).toUpperCase();
119
- }
120
- __name(hex, "hex");
121
- function literalEscape(s) {
122
- return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
123
- return "\\x0" + hex(ch);
124
- }).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
125
- return "\\x" + hex(ch);
126
- });
127
- }
128
- __name(literalEscape, "literalEscape");
129
- function classEscape(s) {
130
- return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
131
- return "\\x0" + hex(ch);
132
- }).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
133
- return "\\x" + hex(ch);
134
- });
135
- }
136
- __name(classEscape, "classEscape");
137
- function describeExpectation(expectation) {
138
- return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
139
- }
140
- __name(describeExpectation, "describeExpectation");
141
- function describeExpected(expected2) {
142
- var descriptions = expected2.map(describeExpectation);
143
- var i, j;
144
- descriptions.sort();
145
- if (descriptions.length > 0) {
146
- for (i = 1, j = 1; i < descriptions.length; i++) {
147
- if (descriptions[i - 1] !== descriptions[i]) {
148
- descriptions[j] = descriptions[i];
149
- j++;
150
- }
151
- }
152
- descriptions.length = j;
153
- }
154
- switch (descriptions.length) {
155
- // @ts-ignore
156
- case 1:
157
- return descriptions[0];
158
- // @ts-ignore
159
- case 2:
160
- return descriptions[0] + " or " + descriptions[1];
161
- // @ts-ignore
162
- default:
163
- return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
164
- }
165
- }
166
- __name(describeExpected, "describeExpected");
167
- function describeFound(found2) {
168
- return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
169
- }
170
- __name(describeFound, "describeFound");
171
- return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
172
- };
173
- function peg$parse(input, options) {
174
- options = options !== void 0 ? options : {};
175
- var peg$FAILED = {};
176
- var peg$source = options.grammarSource;
177
- var peg$startRuleFunctions = { start: peg$parsestart };
178
- var peg$startRuleFunction = peg$parsestart;
179
- var peg$c0 = "(";
180
- var peg$c1 = ")";
181
- var peg$c2 = "||";
182
- var peg$c3 = "&&";
183
- var peg$c4 = ">=";
184
- var peg$c5 = ">";
185
- var peg$c6 = "<=";
186
- var peg$c7 = "<";
187
- var peg$c8 = "===";
188
- var peg$c9 = "-";
189
- var peg$c10 = "0x";
190
- var peg$c11 = ".";
191
- var peg$c12 = '"';
192
- var peg$c13 = "'";
193
- var peg$r0 = /^[a-zA-Z]/;
194
- var peg$r1 = /^[a-zA-Z0-9]/;
195
- var peg$r2 = /^[0-9]/;
196
- var peg$r3 = /^[0-9a-f]/i;
197
- var peg$r4 = /^[^"]/;
198
- var peg$r5 = /^[^']/;
199
- var peg$r6 = /^[ \t\n\r]/;
200
- var peg$e0 = peg$otherExpectation("grouped expression");
201
- var peg$e1 = peg$literalExpectation("(", false);
202
- var peg$e2 = peg$literalExpectation(")", false);
203
- var peg$e3 = peg$otherExpectation("logical OR");
204
- var peg$e4 = peg$literalExpectation("||", false);
205
- var peg$e5 = peg$otherExpectation("logical AND");
206
- var peg$e6 = peg$literalExpectation("&&", false);
207
- var peg$e7 = peg$otherExpectation("numeric comparison");
208
- var peg$e8 = peg$literalExpectation(">=", false);
209
- var peg$e9 = peg$literalExpectation(">", false);
210
- var peg$e10 = peg$literalExpectation("<=", false);
211
- var peg$e11 = peg$literalExpectation("<", false);
212
- var peg$e12 = peg$literalExpectation("===", false);
213
- var peg$e13 = peg$otherExpectation("version comparison");
214
- var peg$e14 = peg$otherExpectation("variable");
215
- var peg$e15 = peg$classExpectation([["a", "z"], ["A", "Z"]], false, false);
216
- var peg$e16 = peg$classExpectation([["a", "z"], ["A", "Z"], ["0", "9"]], false, false);
217
- var peg$e17 = peg$otherExpectation("number");
218
- var peg$e18 = peg$literalExpectation("-", false);
219
- var peg$e19 = peg$classExpectation([["0", "9"]], false, false);
220
- var peg$e20 = peg$otherExpectation("hex number");
221
- var peg$e21 = peg$literalExpectation("0x", false);
222
- var peg$e22 = peg$classExpectation([["0", "9"], ["a", "f"]], false, true);
223
- var peg$e23 = peg$otherExpectation("version string");
224
- var peg$e24 = peg$literalExpectation(".", false);
225
- var peg$e25 = peg$otherExpectation("string");
226
- var peg$e26 = peg$literalExpectation('"', false);
227
- var peg$e27 = peg$classExpectation(['"'], true, false);
228
- var peg$e28 = peg$literalExpectation("'", false);
229
- var peg$e29 = peg$classExpectation(["'"], true, false);
230
- var peg$e30 = peg$otherExpectation("whitespace");
231
- var peg$e31 = peg$classExpectation([" ", " ", "\n", "\r"], false, false);
232
- var peg$f0 = /* @__PURE__ */ __name(function(group) {
233
- return group;
234
- }, "peg$f0");
235
- var peg$f1 = /* @__PURE__ */ __name(function(head, tails) {
236
- return { or: [head, ...tails] };
237
- }, "peg$f1");
238
- var peg$f2 = /* @__PURE__ */ __name(function(tail) {
239
- return tail;
240
- }, "peg$f2");
241
- var peg$f3 = /* @__PURE__ */ __name(function(head, tails) {
242
- return { and: [head, ...tails] };
243
- }, "peg$f3");
244
- var peg$f4 = /* @__PURE__ */ __name(function(tail) {
245
- return tail;
246
- }, "peg$f4");
247
- var peg$f5 = /* @__PURE__ */ __name(function(head, expr, tail) {
248
- return { [expr]: [head, tail] };
249
- }, "peg$f5");
250
- var peg$f6 = /* @__PURE__ */ __name(function(head, expr, tail) {
251
- return { ["ver " + expr]: [head, tail] };
252
- }, "peg$f6");
253
- var peg$f7 = /* @__PURE__ */ __name(function(variable) {
254
- return { var: variable[1].join("") };
255
- }, "peg$f7");
256
- var peg$f8 = /* @__PURE__ */ __name(function() {
257
- return parseInt(text(), 10);
258
- }, "peg$f8");
259
- var peg$f9 = /* @__PURE__ */ __name(function() {
260
- return parseInt(text(), 16);
261
- }, "peg$f9");
262
- var peg$f10 = /* @__PURE__ */ __name(function(version) {
263
- return text();
264
- }, "peg$f10");
265
- var peg$f11 = /* @__PURE__ */ __name(function() {
266
- return text();
267
- }, "peg$f11");
268
- var peg$f12 = /* @__PURE__ */ __name(function() {
269
- return text();
270
- }, "peg$f12");
271
- var peg$currPos = 0;
272
- var peg$savedPos = 0;
273
- var peg$posDetailsCache = [{ line: 1, column: 1 }];
274
- var peg$maxFailPos = 0;
275
- var peg$maxFailExpected = [];
276
- var peg$silentFails = 0;
277
- var peg$result;
278
- if ("startRule" in options) {
279
- if (!(options.startRule in peg$startRuleFunctions)) {
280
- throw new Error(`Can't start parsing from rule "` + options.startRule + '".');
281
- }
282
- peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
283
- }
284
- function text() {
285
- return input.substring(peg$savedPos, peg$currPos);
286
- }
287
- __name(text, "text");
288
- function offset() {
289
- return peg$savedPos;
290
- }
291
- __name(offset, "offset");
292
- function range() {
293
- return {
294
- // @ts-ignore
295
- source: peg$source,
296
- // @ts-ignore
297
- start: peg$savedPos,
298
- // @ts-ignore
299
- end: peg$currPos
300
- };
301
- }
302
- __name(range, "range");
303
- function location() {
304
- return peg$computeLocation(peg$savedPos, peg$currPos);
305
- }
306
- __name(location, "location");
307
- function expected(description, location2) {
308
- location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
309
- throw peg$buildStructuredError(
310
- // @ts-ignore
311
- [peg$otherExpectation(description)],
312
- // @ts-ignore
313
- input.substring(peg$savedPos, peg$currPos),
314
- // @ts-ignore
315
- location2
316
- );
317
- }
318
- __name(expected, "expected");
319
- function error(message, location2) {
320
- location2 = location2 !== void 0 ? location2 : peg$computeLocation(peg$savedPos, peg$currPos);
321
- throw peg$buildSimpleError(message, location2);
322
- }
323
- __name(error, "error");
324
- function peg$literalExpectation(text2, ignoreCase) {
325
- return { type: "literal", text: text2, ignoreCase };
326
- }
327
- __name(peg$literalExpectation, "peg$literalExpectation");
328
- function peg$classExpectation(parts, inverted, ignoreCase) {
329
- return {
330
- type: "class",
331
- parts,
332
- inverted,
333
- ignoreCase
334
- };
335
- }
336
- __name(peg$classExpectation, "peg$classExpectation");
337
- function peg$anyExpectation() {
338
- return { type: "any" };
339
- }
340
- __name(peg$anyExpectation, "peg$anyExpectation");
341
- function peg$endExpectation() {
342
- return { type: "end" };
343
- }
344
- __name(peg$endExpectation, "peg$endExpectation");
345
- function peg$otherExpectation(description) {
346
- return { type: "other", description };
347
- }
348
- __name(peg$otherExpectation, "peg$otherExpectation");
349
- function peg$computePosDetails(pos) {
350
- var details = peg$posDetailsCache[pos];
351
- var p;
352
- if (details) {
353
- return details;
354
- } else {
355
- p = pos - 1;
356
- while (!peg$posDetailsCache[p]) {
357
- p--;
358
- }
359
- details = peg$posDetailsCache[p];
360
- details = {
361
- // @ts-ignore
362
- line: details.line,
363
- // @ts-ignore
364
- column: details.column
365
- };
366
- while (p < pos) {
367
- if (input.charCodeAt(p) === 10) {
368
- details.line++;
369
- details.column = 1;
370
- } else {
371
- details.column++;
372
- }
373
- p++;
374
- }
375
- peg$posDetailsCache[pos] = details;
376
- return details;
377
- }
378
- }
379
- __name(peg$computePosDetails, "peg$computePosDetails");
380
- function peg$computeLocation(startPos, endPos, offset2) {
381
- var startPosDetails = peg$computePosDetails(startPos);
382
- var endPosDetails = peg$computePosDetails(endPos);
383
- var res = {
384
- // @ts-ignore
385
- source: peg$source,
386
- // @ts-ignore
387
- start: {
388
- // @ts-ignore
389
- offset: startPos,
390
- // @ts-ignore
391
- line: startPosDetails.line,
392
- // @ts-ignore
393
- column: startPosDetails.column
394
- },
395
- // @ts-ignore
396
- end: {
397
- // @ts-ignore
398
- offset: endPos,
399
- // @ts-ignore
400
- line: endPosDetails.line,
401
- // @ts-ignore
402
- column: endPosDetails.column
403
- }
404
- };
405
- if (offset2 && peg$source && typeof peg$source.offset === "function") {
406
- res.start = peg$source.offset(res.start);
407
- res.end = peg$source.offset(res.end);
408
- }
409
- return res;
410
- }
411
- __name(peg$computeLocation, "peg$computeLocation");
412
- function peg$fail(expected2) {
413
- if (peg$currPos < peg$maxFailPos)
414
- return;
415
- if (peg$currPos > peg$maxFailPos) {
416
- peg$maxFailPos = peg$currPos;
417
- peg$maxFailExpected = [];
418
- }
419
- peg$maxFailExpected.push(expected2);
420
- }
421
- __name(peg$fail, "peg$fail");
422
- function peg$buildSimpleError(message, location2) {
423
- return new peg$SyntaxError(message, null, null, location2);
424
- }
425
- __name(peg$buildSimpleError, "peg$buildSimpleError");
426
- function peg$buildStructuredError(expected2, found, location2) {
427
- return new peg$SyntaxError(
428
- // @ts-ignore
429
- peg$SyntaxError.buildMessage(expected2, found),
430
- // @ts-ignore
431
- expected2,
432
- // @ts-ignore
433
- found,
434
- // @ts-ignore
435
- location2
436
- );
437
- }
438
- __name(peg$buildStructuredError, "peg$buildStructuredError");
439
- function peg$parsestart() {
440
- var s0;
441
- s0 = peg$parsegroup();
442
- if (s0 === peg$FAILED) {
443
- s0 = peg$parseor();
444
- if (s0 === peg$FAILED) {
445
- s0 = peg$parseand();
446
- if (s0 === peg$FAILED) {
447
- s0 = peg$parsecomparison();
448
- }
449
- }
450
- }
451
- return s0;
452
- }
453
- __name(peg$parsestart, "peg$parsestart");
454
- function peg$parsegroup() {
455
- var s0, s1, s2, s3, s4, s5, s6;
456
- peg$silentFails++;
457
- s0 = peg$currPos;
458
- s1 = peg$parse_();
459
- if (input.charCodeAt(peg$currPos) === 40) {
460
- s2 = peg$c0;
461
- peg$currPos++;
462
- } else {
463
- s2 = peg$FAILED;
464
- if (peg$silentFails === 0)
465
- peg$fail(peg$e1);
466
- }
467
- if (s2 !== peg$FAILED) {
468
- s3 = peg$parse_();
469
- s4 = peg$parseor();
470
- if (s4 !== peg$FAILED) {
471
- s5 = peg$parse_();
472
- if (input.charCodeAt(peg$currPos) === 41) {
473
- s6 = peg$c1;
474
- peg$currPos++;
475
- } else {
476
- s6 = peg$FAILED;
477
- if (peg$silentFails === 0)
478
- peg$fail(peg$e2);
479
- }
480
- if (s6 !== peg$FAILED) {
481
- peg$savedPos = s0;
482
- s0 = peg$f0(s4);
483
- } else {
484
- peg$currPos = s0;
485
- s0 = peg$FAILED;
486
- }
487
- } else {
488
- peg$currPos = s0;
489
- s0 = peg$FAILED;
490
- }
491
- } else {
492
- peg$currPos = s0;
493
- s0 = peg$FAILED;
494
- }
495
- peg$silentFails--;
496
- if (s0 === peg$FAILED) {
497
- s1 = peg$FAILED;
498
- if (peg$silentFails === 0)
499
- peg$fail(peg$e0);
500
- }
501
- return s0;
502
- }
503
- __name(peg$parsegroup, "peg$parsegroup");
504
- function peg$parseor() {
505
- var s0, s1, s2, s3, s4;
506
- peg$silentFails++;
507
- s0 = peg$currPos;
508
- s1 = peg$parse_();
509
- s2 = peg$parseand();
510
- if (s2 === peg$FAILED) {
511
- s2 = peg$parsecomparison();
512
- }
513
- if (s2 !== peg$FAILED) {
514
- s3 = [];
515
- s4 = peg$parseor_tails();
516
- if (s4 !== peg$FAILED) {
517
- while (s4 !== peg$FAILED) {
518
- s3.push(s4);
519
- s4 = peg$parseor_tails();
520
- }
521
- } else {
522
- s3 = peg$FAILED;
523
- }
524
- if (s3 !== peg$FAILED) {
525
- peg$savedPos = s0;
526
- s0 = peg$f1(s2, s3);
527
- } else {
528
- peg$currPos = s0;
529
- s0 = peg$FAILED;
530
- }
531
- } else {
532
- peg$currPos = s0;
533
- s0 = peg$FAILED;
534
- }
535
- peg$silentFails--;
536
- if (s0 === peg$FAILED) {
537
- s1 = peg$FAILED;
538
- if (peg$silentFails === 0)
539
- peg$fail(peg$e3);
540
- }
541
- return s0;
542
- }
543
- __name(peg$parseor, "peg$parseor");
544
- function peg$parseor_tails() {
545
- var s0, s1, s2, s3, s4;
546
- s0 = peg$currPos;
547
- s1 = peg$parse_();
548
- if (input.substr(peg$currPos, 2) === peg$c2) {
549
- s2 = peg$c2;
550
- peg$currPos += 2;
551
- } else {
552
- s2 = peg$FAILED;
553
- if (peg$silentFails === 0)
554
- peg$fail(peg$e4);
555
- }
556
- if (s2 !== peg$FAILED) {
557
- s3 = peg$parse_();
558
- s4 = peg$parseand();
559
- if (s4 === peg$FAILED) {
560
- s4 = peg$parsecomparison();
561
- }
562
- if (s4 !== peg$FAILED) {
563
- peg$savedPos = s0;
564
- s0 = peg$f2(s4);
565
- } else {
566
- peg$currPos = s0;
567
- s0 = peg$FAILED;
568
- }
569
- } else {
570
- peg$currPos = s0;
571
- s0 = peg$FAILED;
572
- }
573
- return s0;
574
- }
575
- __name(peg$parseor_tails, "peg$parseor_tails");
576
- function peg$parseand() {
577
- var s0, s1, s2, s3, s4;
578
- peg$silentFails++;
579
- s0 = peg$currPos;
580
- s1 = peg$parse_();
581
- s2 = peg$parsegroup();
582
- if (s2 === peg$FAILED) {
583
- s2 = peg$parsecomparison();
584
- }
585
- if (s2 !== peg$FAILED) {
586
- s3 = [];
587
- s4 = peg$parseand_tails();
588
- if (s4 !== peg$FAILED) {
589
- while (s4 !== peg$FAILED) {
590
- s3.push(s4);
591
- s4 = peg$parseand_tails();
592
- }
30
+ var import_shared = require("@zwave-js/shared");
31
+ var import_helpers = require("alcalzone-shared/helpers");
32
+ var SyntaxKind;
33
+ (function(SyntaxKind2) {
34
+ SyntaxKind2[SyntaxKind2["Group"] = 0] = "Group";
35
+ SyntaxKind2[SyntaxKind2["Or"] = 1] = "Or";
36
+ SyntaxKind2[SyntaxKind2["And"] = 2] = "And";
37
+ SyntaxKind2[SyntaxKind2["Comparison"] = 3] = "Comparison";
38
+ SyntaxKind2[SyntaxKind2["Identifier"] = 4] = "Identifier";
39
+ SyntaxKind2[SyntaxKind2["NumberLiteral"] = 5] = "NumberLiteral";
40
+ SyntaxKind2[SyntaxKind2["Version"] = 6] = "Version";
41
+ })(SyntaxKind || (SyntaxKind = {}));
42
+ var Operator;
43
+ (function(Operator2) {
44
+ Operator2[Operator2["Equal"] = 0] = "Equal";
45
+ Operator2[Operator2["NotEqual"] = 1] = "NotEqual";
46
+ Operator2[Operator2["LessThan"] = 2] = "LessThan";
47
+ Operator2[Operator2["LessThanOrEqual"] = 3] = "LessThanOrEqual";
48
+ Operator2[Operator2["GreaterThan"] = 4] = "GreaterThan";
49
+ Operator2[Operator2["GreaterThanOrEqual"] = 5] = "GreaterThanOrEqual";
50
+ })(Operator || (Operator = {}));
51
+ var TokenKind;
52
+ (function(TokenKind2) {
53
+ TokenKind2[TokenKind2["Identifier"] = 0] = "Identifier";
54
+ TokenKind2[TokenKind2["NumberLiteral"] = 1] = "NumberLiteral";
55
+ TokenKind2[TokenKind2["Dot"] = 2] = "Dot";
56
+ TokenKind2[TokenKind2["LeftParen"] = 3] = "LeftParen";
57
+ TokenKind2[TokenKind2["RightParen"] = 4] = "RightParen";
58
+ TokenKind2[TokenKind2["BarBar"] = 5] = "BarBar";
59
+ TokenKind2[TokenKind2["AmpAmp"] = 6] = "AmpAmp";
60
+ TokenKind2[TokenKind2["EqualsEquals"] = 7] = "EqualsEquals";
61
+ TokenKind2[TokenKind2["EqualsEqualsEquals"] = 8] = "EqualsEqualsEquals";
62
+ TokenKind2[TokenKind2["ExclamationEquals"] = 9] = "ExclamationEquals";
63
+ TokenKind2[TokenKind2["ExclamationEqualsEquals"] = 10] = "ExclamationEqualsEquals";
64
+ TokenKind2[TokenKind2["LessThan"] = 11] = "LessThan";
65
+ TokenKind2[TokenKind2["LessThanEquals"] = 12] = "LessThanEquals";
66
+ TokenKind2[TokenKind2["GreaterThan"] = 13] = "GreaterThan";
67
+ TokenKind2[TokenKind2["GreaterThanEquals"] = 14] = "GreaterThanEquals";
68
+ })(TokenKind || (TokenKind = {}));
69
+ function* tokenize(input) {
70
+ for (let i = 0; i < input.length; i++) {
71
+ switch (input[i]) {
72
+ case ".": {
73
+ yield { kind: TokenKind.Dot, start: i };
74
+ break;
75
+ }
76
+ case "(": {
77
+ yield { kind: TokenKind.LeftParen, start: i };
78
+ break;
79
+ }
80
+ case ")": {
81
+ yield { kind: TokenKind.RightParen, start: i };
82
+ break;
83
+ }
84
+ case "|": {
85
+ if (input[i + 1] === "|") {
86
+ yield { kind: TokenKind.BarBar, start: i };
87
+ i++;
88
+ }
89
+ break;
90
+ }
91
+ case "&": {
92
+ if (input[i + 1] === "&") {
93
+ yield { kind: TokenKind.AmpAmp, start: i };
94
+ i++;
95
+ }
96
+ break;
97
+ }
98
+ case "=": {
99
+ if (input[i + 1] === "=") {
100
+ if (input[i + 2] === "=") {
101
+ yield { kind: TokenKind.EqualsEqualsEquals, start: i };
102
+ i += 2;
593
103
  } else {
594
- s3 = peg$FAILED;
104
+ yield { kind: TokenKind.EqualsEquals, start: i };
105
+ i++;
595
106
  }
596
- if (s3 !== peg$FAILED) {
597
- peg$savedPos = s0;
598
- s0 = peg$f3(s2, s3);
599
- } else {
600
- peg$currPos = s0;
601
- s0 = peg$FAILED;
602
- }
603
- } else {
604
- peg$currPos = s0;
605
- s0 = peg$FAILED;
606
- }
607
- peg$silentFails--;
608
- if (s0 === peg$FAILED) {
609
- s1 = peg$FAILED;
610
- if (peg$silentFails === 0)
611
- peg$fail(peg$e5);
612
107
  }
613
- return s0;
108
+ break;
614
109
  }
615
- __name(peg$parseand, "peg$parseand");
616
- function peg$parseand_tails() {
617
- var s0, s1, s2, s3, s4;
618
- s0 = peg$currPos;
619
- s1 = peg$parse_();
620
- if (input.substr(peg$currPos, 2) === peg$c3) {
621
- s2 = peg$c3;
622
- peg$currPos += 2;
623
- } else {
624
- s2 = peg$FAILED;
625
- if (peg$silentFails === 0)
626
- peg$fail(peg$e6);
627
- }
628
- if (s2 !== peg$FAILED) {
629
- s3 = peg$parse_();
630
- s4 = peg$parsegroup();
631
- if (s4 === peg$FAILED) {
632
- s4 = peg$parsecomparison();
633
- }
634
- if (s4 !== peg$FAILED) {
635
- peg$savedPos = s0;
636
- s0 = peg$f4(s4);
110
+ case "!": {
111
+ if (input[i + 1] === "=") {
112
+ if (input[i + 2] === "=") {
113
+ yield {
114
+ kind: TokenKind.ExclamationEqualsEquals,
115
+ start: i
116
+ };
117
+ i += 2;
637
118
  } else {
638
- peg$currPos = s0;
639
- s0 = peg$FAILED;
119
+ yield { kind: TokenKind.ExclamationEquals, start: i };
120
+ i++;
640
121
  }
641
- } else {
642
- peg$currPos = s0;
643
- s0 = peg$FAILED;
644
- }
645
- return s0;
646
- }
647
- __name(peg$parseand_tails, "peg$parseand_tails");
648
- function peg$parsecomparison() {
649
- var s0;
650
- s0 = peg$parsever_comparison();
651
- if (s0 === peg$FAILED) {
652
- s0 = peg$parseint_comparison();
653
122
  }
654
- return s0;
123
+ break;
655
124
  }
656
- __name(peg$parsecomparison, "peg$parsecomparison");
657
- function peg$parseint_comparison() {
658
- var s0, s1, s2, s3, s4, s5, s6, s7;
659
- peg$silentFails++;
660
- s0 = peg$currPos;
661
- s1 = peg$parse_();
662
- s2 = peg$parseterm();
663
- if (s2 !== peg$FAILED) {
664
- s3 = peg$parse_();
665
- if (input.substr(peg$currPos, 2) === peg$c4) {
666
- s4 = peg$c4;
667
- peg$currPos += 2;
668
- } else {
669
- s4 = peg$FAILED;
670
- if (peg$silentFails === 0)
671
- peg$fail(peg$e8);
672
- }
673
- if (s4 === peg$FAILED) {
674
- if (input.charCodeAt(peg$currPos) === 62) {
675
- s4 = peg$c5;
676
- peg$currPos++;
677
- } else {
678
- s4 = peg$FAILED;
679
- if (peg$silentFails === 0)
680
- peg$fail(peg$e9);
681
- }
682
- if (s4 === peg$FAILED) {
683
- if (input.substr(peg$currPos, 2) === peg$c6) {
684
- s4 = peg$c6;
685
- peg$currPos += 2;
686
- } else {
687
- s4 = peg$FAILED;
688
- if (peg$silentFails === 0)
689
- peg$fail(peg$e10);
690
- }
691
- if (s4 === peg$FAILED) {
692
- if (input.charCodeAt(peg$currPos) === 60) {
693
- s4 = peg$c7;
694
- peg$currPos++;
695
- } else {
696
- s4 = peg$FAILED;
697
- if (peg$silentFails === 0) {
698
- peg$fail(peg$e11);
699
- }
700
- }
701
- if (s4 === peg$FAILED) {
702
- if (input.substr(peg$currPos, 3) === peg$c8) {
703
- s4 = peg$c8;
704
- peg$currPos += 3;
705
- } else {
706
- s4 = peg$FAILED;
707
- if (peg$silentFails === 0) {
708
- peg$fail(peg$e12);
709
- }
710
- }
711
- }
712
- }
713
- }
714
- }
715
- if (s4 !== peg$FAILED) {
716
- s5 = peg$parse_();
717
- s6 = peg$parseterm();
718
- if (s6 !== peg$FAILED) {
719
- s7 = peg$parse_();
720
- peg$savedPos = s0;
721
- s0 = peg$f5(s2, s4, s6);
722
- } else {
723
- peg$currPos = s0;
724
- s0 = peg$FAILED;
725
- }
726
- } else {
727
- peg$currPos = s0;
728
- s0 = peg$FAILED;
729
- }
125
+ case "<": {
126
+ if (input[i + 1] === "=") {
127
+ yield { kind: TokenKind.LessThanEquals, start: i };
128
+ i++;
730
129
  } else {
731
- peg$currPos = s0;
732
- s0 = peg$FAILED;
733
- }
734
- peg$silentFails--;
735
- if (s0 === peg$FAILED) {
736
- s1 = peg$FAILED;
737
- if (peg$silentFails === 0)
738
- peg$fail(peg$e7);
130
+ yield { kind: TokenKind.LessThan, start: i };
739
131
  }
740
- return s0;
132
+ break;
741
133
  }
742
- __name(peg$parseint_comparison, "peg$parseint_comparison");
743
- function peg$parsever_comparison() {
744
- var s0, s1, s2, s3, s4, s5, s6, s7;
745
- peg$silentFails++;
746
- s0 = peg$currPos;
747
- s1 = peg$parse_();
748
- s2 = peg$parseterm();
749
- if (s2 !== peg$FAILED) {
750
- s3 = peg$parse_();
751
- if (input.substr(peg$currPos, 2) === peg$c4) {
752
- s4 = peg$c4;
753
- peg$currPos += 2;
754
- } else {
755
- s4 = peg$FAILED;
756
- if (peg$silentFails === 0)
757
- peg$fail(peg$e8);
758
- }
759
- if (s4 === peg$FAILED) {
760
- if (input.charCodeAt(peg$currPos) === 62) {
761
- s4 = peg$c5;
762
- peg$currPos++;
763
- } else {
764
- s4 = peg$FAILED;
765
- if (peg$silentFails === 0)
766
- peg$fail(peg$e9);
767
- }
768
- if (s4 === peg$FAILED) {
769
- if (input.substr(peg$currPos, 2) === peg$c6) {
770
- s4 = peg$c6;
771
- peg$currPos += 2;
772
- } else {
773
- s4 = peg$FAILED;
774
- if (peg$silentFails === 0)
775
- peg$fail(peg$e10);
776
- }
777
- if (s4 === peg$FAILED) {
778
- if (input.charCodeAt(peg$currPos) === 60) {
779
- s4 = peg$c7;
780
- peg$currPos++;
781
- } else {
782
- s4 = peg$FAILED;
783
- if (peg$silentFails === 0) {
784
- peg$fail(peg$e11);
785
- }
786
- }
787
- if (s4 === peg$FAILED) {
788
- if (input.substr(peg$currPos, 3) === peg$c8) {
789
- s4 = peg$c8;
790
- peg$currPos += 3;
791
- } else {
792
- s4 = peg$FAILED;
793
- if (peg$silentFails === 0) {
794
- peg$fail(peg$e12);
795
- }
796
- }
797
- }
798
- }
799
- }
800
- }
801
- if (s4 !== peg$FAILED) {
802
- s5 = peg$parse_();
803
- s6 = peg$parseversion();
804
- if (s6 !== peg$FAILED) {
805
- s7 = peg$parse_();
806
- peg$savedPos = s0;
807
- s0 = peg$f6(s2, s4, s6);
808
- } else {
809
- peg$currPos = s0;
810
- s0 = peg$FAILED;
811
- }
812
- } else {
813
- peg$currPos = s0;
814
- s0 = peg$FAILED;
815
- }
134
+ case ">": {
135
+ if (input[i + 1] === "=") {
136
+ yield { kind: TokenKind.GreaterThanEquals, start: i };
137
+ i++;
816
138
  } else {
817
- peg$currPos = s0;
818
- s0 = peg$FAILED;
139
+ yield { kind: TokenKind.GreaterThan, start: i };
819
140
  }
820
- peg$silentFails--;
821
- if (s0 === peg$FAILED) {
822
- s1 = peg$FAILED;
823
- if (peg$silentFails === 0)
824
- peg$fail(peg$e13);
825
- }
826
- return s0;
827
- }
828
- __name(peg$parsever_comparison, "peg$parsever_comparison");
829
- function peg$parseterm() {
830
- var s0;
831
- s0 = peg$parseconst();
832
- if (s0 === peg$FAILED) {
833
- s0 = peg$parsestring();
834
- if (s0 === peg$FAILED) {
835
- s0 = peg$parsehex();
836
- if (s0 === peg$FAILED) {
837
- s0 = peg$parseinteger();
838
- }
839
- }
840
- }
841
- return s0;
141
+ break;
842
142
  }
843
- __name(peg$parseterm, "peg$parseterm");
844
- function peg$parseconst() {
845
- var s0, s1, s2, s3, s4, s5;
846
- peg$silentFails++;
847
- s0 = peg$currPos;
848
- s1 = peg$parse_();
849
- s2 = peg$currPos;
850
- s3 = peg$currPos;
851
- peg$silentFails++;
852
- if (peg$r0.test(input.charAt(peg$currPos))) {
853
- s4 = input.charAt(peg$currPos);
854
- peg$currPos++;
855
- } else {
856
- s4 = peg$FAILED;
857
- if (peg$silentFails === 0)
858
- peg$fail(peg$e15);
859
- }
860
- peg$silentFails--;
861
- if (s4 !== peg$FAILED) {
862
- peg$currPos = s3;
863
- s3 = void 0;
864
- } else {
865
- s3 = peg$FAILED;
143
+ default: {
144
+ if (/\s/.test(input[i])) {
145
+ continue;
866
146
  }
867
- if (s3 !== peg$FAILED) {
868
- s4 = [];
869
- if (peg$r1.test(input.charAt(peg$currPos))) {
870
- s5 = input.charAt(peg$currPos);
871
- peg$currPos++;
872
- } else {
873
- s5 = peg$FAILED;
874
- if (peg$silentFails === 0)
875
- peg$fail(peg$e16);
876
- }
877
- if (s5 !== peg$FAILED) {
878
- while (s5 !== peg$FAILED) {
879
- s4.push(s5);
880
- if (peg$r1.test(input.charAt(peg$currPos))) {
881
- s5 = input.charAt(peg$currPos);
882
- peg$currPos++;
883
- } else {
884
- s5 = peg$FAILED;
885
- if (peg$silentFails === 0)
886
- peg$fail(peg$e16);
887
- }
888
- }
889
- } else {
890
- s4 = peg$FAILED;
147
+ if (input[i] === "0" && input[i + 1] === "x") {
148
+ const start = i;
149
+ let hex = "0x";
150
+ i += 2;
151
+ while (i < input.length && /[0-9a-fA-F]/.test(input[i])) {
152
+ hex += input[i];
153
+ i++;
891
154
  }
892
- if (s4 !== peg$FAILED) {
893
- s3 = [s3, s4];
894
- s2 = s3;
895
- } else {
896
- peg$currPos = s2;
897
- s2 = peg$FAILED;
898
- }
899
- } else {
900
- peg$currPos = s2;
901
- s2 = peg$FAILED;
902
- }
903
- if (s2 !== peg$FAILED) {
904
- peg$savedPos = s0;
905
- s0 = peg$f7(s2);
906
- } else {
907
- peg$currPos = s0;
908
- s0 = peg$FAILED;
909
- }
910
- peg$silentFails--;
911
- if (s0 === peg$FAILED) {
912
- s1 = peg$FAILED;
913
- if (peg$silentFails === 0)
914
- peg$fail(peg$e14);
915
- }
916
- return s0;
917
- }
918
- __name(peg$parseconst, "peg$parseconst");
919
- function peg$parseinteger() {
920
- var s0, s1, s2, s3, s4, s5;
921
- peg$silentFails++;
922
- s0 = peg$currPos;
923
- s1 = peg$parse_();
924
- s2 = peg$currPos;
925
- if (input.charCodeAt(peg$currPos) === 45) {
926
- s3 = peg$c9;
927
- peg$currPos++;
928
- } else {
929
- s3 = peg$FAILED;
930
- if (peg$silentFails === 0)
931
- peg$fail(peg$e18);
932
- }
933
- if (s3 === peg$FAILED) {
934
- s3 = null;
935
- }
936
- s4 = [];
937
- if (peg$r2.test(input.charAt(peg$currPos))) {
938
- s5 = input.charAt(peg$currPos);
939
- peg$currPos++;
940
- } else {
941
- s5 = peg$FAILED;
942
- if (peg$silentFails === 0)
943
- peg$fail(peg$e19);
944
- }
945
- if (s5 !== peg$FAILED) {
946
- while (s5 !== peg$FAILED) {
947
- s4.push(s5);
948
- if (peg$r2.test(input.charAt(peg$currPos))) {
949
- s5 = input.charAt(peg$currPos);
950
- peg$currPos++;
951
- } else {
952
- s5 = peg$FAILED;
953
- if (peg$silentFails === 0)
954
- peg$fail(peg$e19);
955
- }
956
- }
957
- } else {
958
- s4 = peg$FAILED;
959
- }
960
- if (s4 !== peg$FAILED) {
961
- s3 = [s3, s4];
962
- s2 = s3;
963
- } else {
964
- peg$currPos = s2;
965
- s2 = peg$FAILED;
966
- }
967
- if (s2 !== peg$FAILED) {
968
- peg$savedPos = s0;
969
- s0 = peg$f8();
970
- } else {
971
- peg$currPos = s0;
972
- s0 = peg$FAILED;
973
- }
974
- peg$silentFails--;
975
- if (s0 === peg$FAILED) {
976
- s1 = peg$FAILED;
977
- if (peg$silentFails === 0)
978
- peg$fail(peg$e17);
979
- }
980
- return s0;
981
- }
982
- __name(peg$parseinteger, "peg$parseinteger");
983
- function peg$parsehex() {
984
- var s0, s1, s2, s3, s4, s5;
985
- peg$silentFails++;
986
- s0 = peg$currPos;
987
- s1 = peg$parse_();
988
- s2 = peg$currPos;
989
- if (input.substr(peg$currPos, 2) === peg$c10) {
990
- s3 = peg$c10;
991
- peg$currPos += 2;
992
- } else {
993
- s3 = peg$FAILED;
994
- if (peg$silentFails === 0)
995
- peg$fail(peg$e21);
996
- }
997
- if (s3 !== peg$FAILED) {
998
- s4 = [];
999
- if (peg$r3.test(input.charAt(peg$currPos))) {
1000
- s5 = input.charAt(peg$currPos);
1001
- peg$currPos++;
1002
- } else {
1003
- s5 = peg$FAILED;
1004
- if (peg$silentFails === 0)
1005
- peg$fail(peg$e22);
1006
- }
1007
- if (s5 !== peg$FAILED) {
1008
- while (s5 !== peg$FAILED) {
1009
- s4.push(s5);
1010
- if (peg$r3.test(input.charAt(peg$currPos))) {
1011
- s5 = input.charAt(peg$currPos);
1012
- peg$currPos++;
1013
- } else {
1014
- s5 = peg$FAILED;
1015
- if (peg$silentFails === 0)
1016
- peg$fail(peg$e22);
1017
- }
1018
- }
1019
- } else {
1020
- s4 = peg$FAILED;
1021
- }
1022
- if (s4 !== peg$FAILED) {
1023
- s3 = [s3, s4];
1024
- s2 = s3;
1025
- } else {
1026
- peg$currPos = s2;
1027
- s2 = peg$FAILED;
1028
- }
1029
- } else {
1030
- peg$currPos = s2;
1031
- s2 = peg$FAILED;
1032
- }
1033
- if (s2 !== peg$FAILED) {
1034
- peg$savedPos = s0;
1035
- s0 = peg$f9();
1036
- } else {
1037
- peg$currPos = s0;
1038
- s0 = peg$FAILED;
1039
- }
1040
- peg$silentFails--;
1041
- if (s0 === peg$FAILED) {
1042
- s1 = peg$FAILED;
1043
- if (peg$silentFails === 0)
1044
- peg$fail(peg$e20);
1045
- }
1046
- return s0;
1047
- }
1048
- __name(peg$parsehex, "peg$parsehex");
1049
- function peg$parseversion() {
1050
- var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9;
1051
- peg$silentFails++;
1052
- s0 = peg$currPos;
1053
- s1 = peg$parse_();
1054
- s2 = peg$currPos;
1055
- s3 = [];
1056
- if (peg$r2.test(input.charAt(peg$currPos))) {
1057
- s4 = input.charAt(peg$currPos);
1058
- peg$currPos++;
1059
- } else {
1060
- s4 = peg$FAILED;
1061
- if (peg$silentFails === 0)
1062
- peg$fail(peg$e19);
1063
- }
1064
- if (s4 !== peg$FAILED) {
1065
- while (s4 !== peg$FAILED) {
1066
- s3.push(s4);
1067
- if (peg$r2.test(input.charAt(peg$currPos))) {
1068
- s4 = input.charAt(peg$currPos);
1069
- peg$currPos++;
1070
- } else {
1071
- s4 = peg$FAILED;
1072
- if (peg$silentFails === 0)
1073
- peg$fail(peg$e19);
1074
- }
1075
- }
1076
- } else {
1077
- s3 = peg$FAILED;
1078
- }
1079
- if (s3 !== peg$FAILED) {
1080
- if (input.charCodeAt(peg$currPos) === 46) {
1081
- s4 = peg$c11;
1082
- peg$currPos++;
1083
- } else {
1084
- s4 = peg$FAILED;
1085
- if (peg$silentFails === 0)
1086
- peg$fail(peg$e24);
1087
- }
1088
- if (s4 !== peg$FAILED) {
1089
- s5 = [];
1090
- if (peg$r2.test(input.charAt(peg$currPos))) {
1091
- s6 = input.charAt(peg$currPos);
1092
- peg$currPos++;
1093
- } else {
1094
- s6 = peg$FAILED;
1095
- if (peg$silentFails === 0)
1096
- peg$fail(peg$e19);
1097
- }
1098
- if (s6 !== peg$FAILED) {
1099
- while (s6 !== peg$FAILED) {
1100
- s5.push(s6);
1101
- if (peg$r2.test(input.charAt(peg$currPos))) {
1102
- s6 = input.charAt(peg$currPos);
1103
- peg$currPos++;
1104
- } else {
1105
- s6 = peg$FAILED;
1106
- if (peg$silentFails === 0) {
1107
- peg$fail(peg$e19);
1108
- }
1109
- }
1110
- }
1111
- } else {
1112
- s5 = peg$FAILED;
1113
- }
1114
- if (s5 !== peg$FAILED) {
1115
- s6 = peg$currPos;
1116
- if (input.charCodeAt(peg$currPos) === 46) {
1117
- s7 = peg$c11;
1118
- peg$currPos++;
1119
- } else {
1120
- s7 = peg$FAILED;
1121
- if (peg$silentFails === 0)
1122
- peg$fail(peg$e24);
1123
- }
1124
- if (s7 !== peg$FAILED) {
1125
- s8 = [];
1126
- if (peg$r2.test(input.charAt(peg$currPos))) {
1127
- s9 = input.charAt(peg$currPos);
1128
- peg$currPos++;
1129
- } else {
1130
- s9 = peg$FAILED;
1131
- if (peg$silentFails === 0) {
1132
- peg$fail(peg$e19);
1133
- }
1134
- }
1135
- if (s9 !== peg$FAILED) {
1136
- while (s9 !== peg$FAILED) {
1137
- s8.push(s9);
1138
- if (peg$r2.test(input.charAt(peg$currPos))) {
1139
- s9 = input.charAt(peg$currPos);
1140
- peg$currPos++;
1141
- } else {
1142
- s9 = peg$FAILED;
1143
- if (peg$silentFails === 0) {
1144
- peg$fail(peg$e19);
1145
- }
1146
- }
1147
- }
1148
- } else {
1149
- s8 = peg$FAILED;
1150
- }
1151
- if (s8 !== peg$FAILED) {
1152
- s7 = [s7, s8];
1153
- s6 = s7;
1154
- } else {
1155
- peg$currPos = s6;
1156
- s6 = peg$FAILED;
1157
- }
1158
- } else {
1159
- peg$currPos = s6;
1160
- s6 = peg$FAILED;
1161
- }
1162
- if (s6 === peg$FAILED) {
1163
- s6 = null;
1164
- }
1165
- s3 = [s3, s4, s5, s6];
1166
- s2 = s3;
1167
- } else {
1168
- peg$currPos = s2;
1169
- s2 = peg$FAILED;
1170
- }
1171
- } else {
1172
- peg$currPos = s2;
1173
- s2 = peg$FAILED;
1174
- }
1175
- } else {
1176
- peg$currPos = s2;
1177
- s2 = peg$FAILED;
1178
- }
1179
- if (s2 !== peg$FAILED) {
1180
- peg$savedPos = s0;
1181
- s0 = peg$f10(s2);
1182
- } else {
1183
- peg$currPos = s0;
1184
- s0 = peg$FAILED;
1185
- }
1186
- peg$silentFails--;
1187
- if (s0 === peg$FAILED) {
1188
- s1 = peg$FAILED;
1189
- if (peg$silentFails === 0)
1190
- peg$fail(peg$e23);
1191
- }
1192
- return s0;
1193
- }
1194
- __name(peg$parseversion, "peg$parseversion");
1195
- function peg$parsestring() {
1196
- var s0, s1, s2, s3, s4, s5;
1197
- peg$silentFails++;
1198
- s0 = peg$currPos;
1199
- s1 = peg$parse_();
1200
- s2 = peg$currPos;
1201
- if (input.charCodeAt(peg$currPos) === 34) {
1202
- s3 = peg$c12;
1203
- peg$currPos++;
1204
- } else {
1205
- s3 = peg$FAILED;
1206
- if (peg$silentFails === 0)
1207
- peg$fail(peg$e26);
1208
- }
1209
- if (s3 !== peg$FAILED) {
1210
- s4 = [];
1211
- if (peg$r4.test(input.charAt(peg$currPos))) {
1212
- s5 = input.charAt(peg$currPos);
1213
- peg$currPos++;
1214
- } else {
1215
- s5 = peg$FAILED;
1216
- if (peg$silentFails === 0)
1217
- peg$fail(peg$e27);
1218
- }
1219
- while (s5 !== peg$FAILED) {
1220
- s4.push(s5);
1221
- if (peg$r4.test(input.charAt(peg$currPos))) {
1222
- s5 = input.charAt(peg$currPos);
1223
- peg$currPos++;
1224
- } else {
1225
- s5 = peg$FAILED;
1226
- if (peg$silentFails === 0)
1227
- peg$fail(peg$e27);
1228
- }
1229
- }
1230
- if (input.charCodeAt(peg$currPos) === 34) {
1231
- s5 = peg$c12;
1232
- peg$currPos++;
1233
- } else {
1234
- s5 = peg$FAILED;
1235
- if (peg$silentFails === 0)
1236
- peg$fail(peg$e26);
1237
- }
1238
- if (s5 !== peg$FAILED) {
1239
- s3 = [s3, s4, s5];
1240
- s2 = s3;
1241
- } else {
1242
- peg$currPos = s2;
1243
- s2 = peg$FAILED;
1244
- }
1245
- } else {
1246
- peg$currPos = s2;
1247
- s2 = peg$FAILED;
1248
- }
1249
- if (s2 !== peg$FAILED) {
1250
- peg$savedPos = s0;
1251
- s0 = peg$f11();
1252
- } else {
1253
- peg$currPos = s0;
1254
- s0 = peg$FAILED;
1255
- }
1256
- if (s0 === peg$FAILED) {
1257
- s0 = peg$currPos;
1258
- s1 = peg$parse_();
1259
- s2 = peg$currPos;
1260
- if (input.charCodeAt(peg$currPos) === 39) {
1261
- s3 = peg$c13;
1262
- peg$currPos++;
1263
- } else {
1264
- s3 = peg$FAILED;
1265
- if (peg$silentFails === 0)
1266
- peg$fail(peg$e28);
1267
- }
1268
- if (s3 !== peg$FAILED) {
1269
- s4 = [];
1270
- if (peg$r5.test(input.charAt(peg$currPos))) {
1271
- s5 = input.charAt(peg$currPos);
1272
- peg$currPos++;
1273
- } else {
1274
- s5 = peg$FAILED;
1275
- if (peg$silentFails === 0)
1276
- peg$fail(peg$e29);
1277
- }
1278
- while (s5 !== peg$FAILED) {
1279
- s4.push(s5);
1280
- if (peg$r5.test(input.charAt(peg$currPos))) {
1281
- s5 = input.charAt(peg$currPos);
1282
- peg$currPos++;
1283
- } else {
1284
- s5 = peg$FAILED;
1285
- if (peg$silentFails === 0)
1286
- peg$fail(peg$e29);
1287
- }
1288
- }
1289
- if (input.charCodeAt(peg$currPos) === 39) {
1290
- s5 = peg$c13;
1291
- peg$currPos++;
1292
- } else {
1293
- s5 = peg$FAILED;
1294
- if (peg$silentFails === 0)
1295
- peg$fail(peg$e28);
1296
- }
1297
- if (s5 !== peg$FAILED) {
1298
- s3 = [s3, s4, s5];
1299
- s2 = s3;
1300
- } else {
1301
- peg$currPos = s2;
1302
- s2 = peg$FAILED;
1303
- }
1304
- } else {
1305
- peg$currPos = s2;
1306
- s2 = peg$FAILED;
1307
- }
1308
- if (s2 !== peg$FAILED) {
1309
- peg$savedPos = s0;
1310
- s0 = peg$f12();
1311
- } else {
1312
- peg$currPos = s0;
1313
- s0 = peg$FAILED;
1314
- }
1315
- }
1316
- peg$silentFails--;
1317
- if (s0 === peg$FAILED) {
1318
- s1 = peg$FAILED;
1319
- if (peg$silentFails === 0)
1320
- peg$fail(peg$e25);
1321
- }
1322
- return s0;
1323
- }
1324
- __name(peg$parsestring, "peg$parsestring");
1325
- function peg$parse_() {
1326
- var s0, s1;
1327
- peg$silentFails++;
1328
- s0 = [];
1329
- if (peg$r6.test(input.charAt(peg$currPos))) {
1330
- s1 = input.charAt(peg$currPos);
1331
- peg$currPos++;
1332
- } else {
1333
- s1 = peg$FAILED;
1334
- if (peg$silentFails === 0)
1335
- peg$fail(peg$e31);
155
+ yield {
156
+ kind: TokenKind.NumberLiteral,
157
+ value: hex,
158
+ start
159
+ };
160
+ i--;
161
+ continue;
162
+ }
163
+ if (/\d/.test(input[i])) {
164
+ const start = i;
165
+ let num = "";
166
+ while (i < input.length && /\d/.test(input[i])) {
167
+ num += input[i];
168
+ i++;
169
+ }
170
+ yield {
171
+ kind: TokenKind.NumberLiteral,
172
+ value: num,
173
+ start
174
+ };
175
+ i--;
176
+ continue;
1336
177
  }
1337
- while (s1 !== peg$FAILED) {
1338
- s0.push(s1);
1339
- if (peg$r6.test(input.charAt(peg$currPos))) {
1340
- s1 = input.charAt(peg$currPos);
1341
- peg$currPos++;
1342
- } else {
1343
- s1 = peg$FAILED;
1344
- if (peg$silentFails === 0)
1345
- peg$fail(peg$e31);
178
+ if (/[a-zA-Z_$]/.test(input[i])) {
179
+ const start = i;
180
+ let id = "";
181
+ while (i < input.length && /[a-zA-Z0-9_$]/.test(input[i])) {
182
+ id += input[i];
183
+ i++;
1346
184
  }
185
+ yield { kind: TokenKind.Identifier, value: id, start };
186
+ i--;
187
+ continue;
1347
188
  }
1348
- peg$silentFails--;
1349
- s1 = peg$FAILED;
1350
- if (peg$silentFails === 0)
1351
- peg$fail(peg$e30);
1352
- return s0;
1353
- }
1354
- __name(peg$parse_, "peg$parse_");
1355
- peg$result = peg$startRuleFunction();
1356
- if (peg$result !== peg$FAILED && peg$currPos === input.length) {
1357
- return peg$result;
1358
- } else {
1359
- if (peg$result !== peg$FAILED && peg$currPos < input.length) {
1360
- peg$fail(peg$endExpectation());
1361
- }
1362
- throw peg$buildStructuredError(
1363
- // @ts-ignore
1364
- peg$maxFailExpected,
1365
- // @ts-ignore
1366
- peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
1367
- // @ts-ignore
1368
- peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
1369
- );
189
+ throw new Error(`Unexpected character '${input[i]}' at index ${i}`);
1370
190
  }
1371
191
  }
1372
- __name(peg$parse, "peg$parse");
192
+ }
193
+ }
194
+ __name(tokenize, "tokenize");
195
+ function parse(input) {
196
+ const tokens = Array.from(tokenize(input));
197
+ const state = { input, tokens, pos: 0 };
198
+ const ret = parseExpression(state);
199
+ if (state.pos < tokens.length) {
200
+ const token = tokens[state.pos];
201
+ throw new Error(`Unexpected token ${(0, import_shared.getEnumMemberName)(TokenKind, token.kind)} at position ` + token.start);
202
+ }
203
+ return ret;
204
+ }
205
+ __name(parse, "parse");
206
+ function parseExpression(s) {
207
+ return parseOr(s) || parseAnd(s) || parseComparison(s) || parseGroup(s);
208
+ }
209
+ __name(parseExpression, "parseExpression");
210
+ function parseAnd(s) {
211
+ let startPos = s.pos;
212
+ const first = parseComparison(s) || parseGroup(s);
213
+ if (!first) {
214
+ s.pos = startPos;
215
+ return;
216
+ }
217
+ if (s.tokens[s.pos]?.kind !== TokenKind.AmpAmp) {
218
+ s.pos = startPos;
219
+ return;
220
+ }
221
+ s.pos++;
222
+ const second = parseComparison(s) || parseGroup(s);
223
+ if (!second) {
224
+ s.pos = startPos;
225
+ return;
226
+ }
227
+ startPos = s.pos;
228
+ const operands = [first, second];
229
+ while (s.tokens[s.pos]?.kind === TokenKind.AmpAmp) {
230
+ s.pos++;
231
+ const next = parseComparison(s) || parseGroup(s);
232
+ if (!next) {
233
+ s.pos = startPos;
234
+ break;
235
+ }
236
+ operands.push(next);
237
+ startPos = s.pos;
238
+ }
239
+ return {
240
+ kind: SyntaxKind.And,
241
+ operands
242
+ };
243
+ }
244
+ __name(parseAnd, "parseAnd");
245
+ function parseOr(s) {
246
+ let startPos = s.pos;
247
+ const first = parseAnd(s) || parseComparison(s) || parseGroup(s);
248
+ if (!first) {
249
+ s.pos = startPos;
250
+ return;
251
+ }
252
+ if (s.tokens[s.pos]?.kind !== TokenKind.BarBar) {
253
+ s.pos = startPos;
254
+ return;
255
+ }
256
+ s.pos++;
257
+ const second = parseAnd(s) || parseComparison(s) || parseGroup(s);
258
+ if (!second) {
259
+ s.pos = startPos;
260
+ return;
261
+ }
262
+ startPos = s.pos;
263
+ const operands = [first, second];
264
+ while (s.tokens[s.pos]?.kind === TokenKind.BarBar) {
265
+ s.pos++;
266
+ const next = parseAnd(s) || parseComparison(s) || parseGroup(s);
267
+ if (!next) {
268
+ s.pos = startPos;
269
+ break;
270
+ }
271
+ operands.push(next);
272
+ startPos = s.pos;
273
+ }
274
+ return {
275
+ kind: SyntaxKind.Or,
276
+ operands
277
+ };
278
+ }
279
+ __name(parseOr, "parseOr");
280
+ function parseGroup(s) {
281
+ const startPos = s.pos;
282
+ if (s.tokens[s.pos]?.kind !== TokenKind.LeftParen) {
283
+ return;
284
+ }
285
+ s.pos++;
286
+ const expression = parseExpression(s);
287
+ if (!expression) {
288
+ s.pos = startPos;
289
+ return;
290
+ }
291
+ if (s.tokens[s.pos]?.kind !== TokenKind.RightParen) {
292
+ s.pos = startPos;
293
+ return;
294
+ }
295
+ s.pos++;
296
+ return expression;
297
+ }
298
+ __name(parseGroup, "parseGroup");
299
+ function parseComparison(s) {
300
+ const startPos = s.pos;
301
+ const left = parseIdentifier(s);
302
+ if (!left) {
303
+ s.pos = startPos;
304
+ return;
305
+ }
306
+ const operator = parseOperator(s);
307
+ if (operator == void 0) {
308
+ s.pos = startPos;
309
+ return;
310
+ }
311
+ const right = parseVersion(s) || parseNumberLiteral(s) || parseIdentifier(s);
312
+ if (!right) {
313
+ s.pos = startPos;
314
+ return;
315
+ } else if (right.kind === SyntaxKind.Identifier) {
316
+ throw new Error(`Right-hand side of comparisons must be a version or number literal`);
317
+ }
318
+ return {
319
+ kind: SyntaxKind.Comparison,
320
+ left,
321
+ operator,
322
+ right
323
+ };
324
+ }
325
+ __name(parseComparison, "parseComparison");
326
+ function parseIdentifier(s) {
327
+ const token = s.tokens[s.pos];
328
+ if (token?.kind === TokenKind.Identifier) {
329
+ s.pos++;
330
+ return { kind: SyntaxKind.Identifier, name: token.value };
331
+ }
332
+ }
333
+ __name(parseIdentifier, "parseIdentifier");
334
+ function parseOperator(s) {
335
+ const token = s.tokens[s.pos];
336
+ if (!token)
337
+ return null;
338
+ switch (token.kind) {
339
+ case TokenKind.EqualsEquals:
340
+ case TokenKind.EqualsEqualsEquals:
341
+ s.pos++;
342
+ return Operator.Equal;
343
+ case TokenKind.ExclamationEquals:
344
+ case TokenKind.ExclamationEqualsEquals:
345
+ s.pos++;
346
+ return Operator.NotEqual;
347
+ case TokenKind.LessThan:
348
+ s.pos++;
349
+ return Operator.LessThan;
350
+ case TokenKind.LessThanEquals:
351
+ s.pos++;
352
+ return Operator.LessThanOrEqual;
353
+ case TokenKind.GreaterThan:
354
+ s.pos++;
355
+ return Operator.GreaterThan;
356
+ case TokenKind.GreaterThanEquals:
357
+ s.pos++;
358
+ return Operator.GreaterThanOrEqual;
359
+ default:
360
+ return null;
361
+ }
362
+ }
363
+ __name(parseOperator, "parseOperator");
364
+ function parseVersion(s) {
365
+ let pos = s.pos;
366
+ if (s.tokens[pos]?.kind !== TokenKind.NumberLiteral) {
367
+ return;
368
+ }
369
+ let version = s.tokens[pos].value;
370
+ pos++;
371
+ if (s.tokens[pos]?.kind !== TokenKind.Dot) {
372
+ return;
373
+ }
374
+ version += ".";
375
+ pos++;
376
+ if (s.tokens[pos]?.kind !== TokenKind.NumberLiteral) {
377
+ return;
378
+ }
379
+ version += s.tokens[pos].value;
380
+ pos++;
381
+ if (s.tokens[pos]?.kind === TokenKind.Dot) {
382
+ version += ".";
383
+ pos++;
384
+ if (s.tokens[pos]?.kind !== TokenKind.NumberLiteral) {
385
+ return;
386
+ }
387
+ version += s.tokens[pos].value;
388
+ pos++;
389
+ }
390
+ s.pos = pos;
391
+ return { kind: SyntaxKind.Version, value: version };
392
+ }
393
+ __name(parseVersion, "parseVersion");
394
+ function parseNumberLiteral(s) {
395
+ if (s.tokens[s.pos]?.kind === TokenKind.NumberLiteral) {
396
+ const token = s.tokens[s.pos];
397
+ s.pos++;
398
+ return {
399
+ kind: SyntaxKind.NumberLiteral,
400
+ value: parseInt(token.value)
401
+ };
402
+ }
403
+ }
404
+ __name(parseNumberLiteral, "parseNumberLiteral");
405
+ function toRulesLogic(expr) {
406
+ if (expr.kind === SyntaxKind.Or) {
407
+ return {
408
+ or: expr.operands.map(toRulesLogic)
409
+ };
410
+ } else if (expr.kind === SyntaxKind.And) {
1373
411
  return {
1374
- SyntaxError: peg$SyntaxError,
1375
- parse: peg$parse
412
+ and: expr.operands.map(toRulesLogic)
1376
413
  };
1377
- })()
1378
- );
1379
- peggyParser.SyntaxError.prototype.name = "PeggySyntaxError";
1380
- const parse = peggyParser.parse;
1381
- const PeggySyntaxError = peggyParser.SyntaxError;
414
+ } else if (expr.kind === SyntaxKind.Comparison) {
415
+ if (expr.right.kind === SyntaxKind.Version) {
416
+ const opMap = {
417
+ [Operator.Equal]: "ver ===",
418
+ [Operator.NotEqual]: "ver !==",
419
+ [Operator.LessThan]: "ver <",
420
+ [Operator.LessThanOrEqual]: "ver <=",
421
+ [Operator.GreaterThan]: "ver >",
422
+ [Operator.GreaterThanOrEqual]: "ver >="
423
+ };
424
+ return {
425
+ [opMap[expr.operator]]: [
426
+ { var: expr.left.name },
427
+ expr.right.value
428
+ ]
429
+ };
430
+ } else {
431
+ const opMap = {
432
+ [Operator.Equal]: "===",
433
+ [Operator.NotEqual]: "!==",
434
+ [Operator.LessThan]: "<",
435
+ [Operator.LessThanOrEqual]: "<=",
436
+ [Operator.GreaterThan]: ">",
437
+ [Operator.GreaterThanOrEqual]: ">="
438
+ };
439
+ return {
440
+ [opMap[expr.operator]]: [
441
+ { var: expr.left.name },
442
+ expr.right.value
443
+ ]
444
+ };
445
+ }
446
+ } else {
447
+ (0, import_helpers.assertNever)(expr);
448
+ }
449
+ }
450
+ __name(toRulesLogic, "toRulesLogic");
1382
451
  // Annotate the CommonJS export names for ESM import in node:
1383
452
  0 && (module.exports = {
1384
- PeggySyntaxError,
1385
- parse
453
+ Operator,
454
+ SyntaxKind,
455
+ TokenKind,
456
+ parse,
457
+ toRulesLogic,
458
+ tokenize
1386
459
  });
1387
460
  //# sourceMappingURL=LogicParser.js.map