From 7cdaea071d0f7152d012246e168e67921779f970 Mon Sep 17 00:00:00 2001 From: m93a Date: Wed, 22 Sep 2021 23:16:30 +0200 Subject: [PATCH] changed % to mod and added deprecation warnings #34 #48 --- README.md | 5 +- dist/browser/filtrex.js | 846 +++++++++++++++++++++++------------- dist/browser/filtrex.min.js | 2 +- dist/cjs/filtrex.js | 846 +++++++++++++++++++++++------------- dist/esm/filtrex.d.ts | 4 +- dist/esm/filtrex.mjs | 38 +- dist/esm/generateParser.mjs | 20 +- dist/esm/parser.mjs | 811 +++++++++++++++++++++------------- package.json | 12 +- src/filtrex.d.ts | 4 +- src/filtrex.mjs | 38 +- src/generateParser.mjs | 20 +- test/arithmetics.js | 10 +- test/misc.js | 16 + yarn.lock | 142 +++--- 15 files changed, 1820 insertions(+), 994 deletions(-) diff --git a/README.md b/README.md index 3f5c330..545d0b9 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,8 @@ x + y | Add x - y | Subtract x * y | Multiply x / y | Divide -x % y | Modulo x ^ y | Power +x mod y | Modulo Comparisons | Description --- | --- @@ -98,6 +98,7 @@ x < y | Less than x <= y | Less than or equal to x > y | Greater than x >= y | Greater than or equal to +x == y <= z | Chained relation, equivalent to (x == y and y <= z) x ~= y | Regular expression match x in (a, b, c) | Equivalent to (x == a or x == b or x == c) x not in (a, b, c) | Equivalent to (x != a and x != b and x != c) @@ -107,7 +108,7 @@ Boolean logic | Description x or y | Boolean or x and y | Boolean and not x | Boolean not -if x then y else z | If boolean x, value y, else z +if x then y else z | If boolean x is true, return value y, else return z ( x ) | Explicity operator precedence Objects and arrays | Description diff --git a/dist/browser/filtrex.js b/dist/browser/filtrex.js index 99f23a6..cf5051b 100644 --- a/dist/browser/filtrex.js +++ b/dist/browser/filtrex.js @@ -15,8 +15,8 @@ var filtrex = (function (exports) { "+": 7, "*": 8, "/": 9, - "%": 10, - "^": 11, + "^": 10, + "mod": 11, "and": 12, "or": 13, "not": 14, @@ -34,14 +34,17 @@ var filtrex = (function (exports) { "String": 26, "of": 27, "Relation": 28, - "RelationalOperator": 29, - "==": 30, - "!=": 31, - "~=": 32, - "<": 33, - "<=": 34, - ">=": 35, - ">": 36, + "%": 29, + "?": 30, + ":": 31, + "RelationalOperator": 32, + "==": 33, + "!=": 34, + "~=": 35, + "<": 36, + "<=": 37, + ">=": 38, + ">": 39, "$accept": 0, "$end": 1 }, @@ -52,8 +55,8 @@ var filtrex = (function (exports) { 7: "+", 8: "*", 9: "/", - 10: "%", - 11: "^", + 10: "^", + 11: "mod", 12: "and", 13: "or", 14: "not", @@ -69,13 +72,16 @@ var filtrex = (function (exports) { 25: "Symbol", 26: "String", 27: "of", - 30: "==", - 31: "!=", - 32: "~=", - 33: "<", - 34: "<=", - 35: ">=", - 36: ">" + 29: "%", + 30: "?", + 31: ":", + 33: "==", + 34: "!=", + 35: "~=", + 36: "<", + 37: "<=", + 38: ">=", + 39: ">" }, productions_: [0, [3, 2], [4, 2], @@ -100,13 +106,15 @@ var filtrex = (function (exports) { [4, 3], [4, 4], [4, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], + [4, 3], + [4, 5], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], [28, 3], [28, 3], [22, 1], @@ -137,7 +145,7 @@ var filtrex = (function (exports) { this.$ = ["(", "ops['", $$[$0 - 1], "'](", $$[$0 - 2], ", ", $$[$0], ")", ")"]; break; case 8: - this.$ = ["(", "ops['", $$[$0 - 1], "'](", $$[$0 - 2], ", ", $$[$0], ")", ")"]; + this.$ = ["(", "ops.mod(", $$[$0 - 2], ", ", $$[$0], ")", ")"]; break; case 9: this.$ = ["(", "", "std.coerceBoolean", "(", $$[$0 - 2], ") && ", "std.coerceBoolean", "(", $$[$0], ")", ")"]; @@ -185,36 +193,42 @@ var filtrex = (function (exports) { this.$ = yy.reduceRelation($$[$0]); break; case 24: - this.$ = ["=="]; + this.$ = ["std.warnDeprecated('modulo', ops['mod'](", $$[$0 - 2], ", ", $$[$0], "))"]; break; case 25: - this.$ = ["!="]; + this.$ = ["std.warnDeprecated('ternary', ", "std.coerceBoolean", "(", $$[$0 - 4], ") ? ", $$[$0 - 2], " : ", $$[$0], ")"]; break; case 26: - this.$ = ["~="]; + this.$ = ["=="]; break; case 27: - this.$ = ["<"]; + this.$ = ["!="]; break; case 28: - this.$ = ["<="]; + this.$ = ["~="]; break; case 29: - this.$ = [">="]; + this.$ = ["<"]; break; case 30: - this.$ = [">"]; + this.$ = ["<="]; break; case 31: - this.$ = [$$[$0 - 2], $$[$0 - 1], ...$$[$0]]; + this.$ = [">="]; break; case 32: - this.$ = [$$[$0 - 2], $$[$0 - 1], $$[$0]]; + this.$ = [">"]; break; case 33: - this.$ = ["", $$[$0], ""]; + this.$ = [$$[$0 - 2], $$[$0 - 1], ...$$[$0]]; break; case 34: + this.$ = [$$[$0 - 2], $$[$0 - 1], $$[$0]]; + break; + case 35: + this.$ = ["", $$[$0], ""]; + break; + case 36: this.$ = ["", $$[$0 - 2], ", ", $$[$0], ""]; break; } @@ -244,16 +258,18 @@ var filtrex = (function (exports) { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] - }, { - 4: 30, + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 32, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -263,7 +279,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 31, + 4: 33, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -273,7 +289,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 32, + 4: 34, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -283,12 +299,12 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 33, + 4: 35, 6: [1, 3], 14: [1, 4], 15: [1, 5], 20: [1, 6], - 22: 34, + 22: 36, 24: [1, 7], 25: [1, 8], 26: [1, 9], @@ -309,13 +325,16 @@ var filtrex = (function (exports) { 19: [2, 17], 21: [2, 17], 23: [2, 17], + 29: [2, 17], 30: [2, 17], 31: [2, 17], - 32: [2, 17], 33: [2, 17], 34: [2, 17], 35: [2, 17], - 36: [2, 17] + 36: [2, 17], + 37: [2, 17], + 38: [2, 17], + 39: [2, 17] }, { 5: [2, 18], 6: [2, 18], @@ -330,17 +349,20 @@ var filtrex = (function (exports) { 17: [2, 18], 18: [2, 18], 19: [2, 18], - 20: [1, 36], + 20: [1, 38], 21: [2, 18], 23: [2, 18], - 27: [1, 35], + 27: [1, 37], + 29: [2, 18], 30: [2, 18], 31: [2, 18], - 32: [2, 18], 33: [2, 18], 34: [2, 18], 35: [2, 18], - 36: [2, 18] + 36: [2, 18], + 37: [2, 18], + 38: [2, 18], + 39: [2, 18] }, { 5: [2, 19], 6: [2, 19], @@ -357,13 +379,16 @@ var filtrex = (function (exports) { 19: [2, 19], 21: [2, 19], 23: [2, 19], + 29: [2, 19], 30: [2, 19], 31: [2, 19], - 32: [2, 19], 33: [2, 19], 34: [2, 19], 35: [2, 19], - 36: [2, 19] + 36: [2, 19], + 37: [2, 19], + 38: [2, 19], + 39: [2, 19] }, { 5: [2, 23], 6: [2, 23], @@ -380,17 +405,20 @@ var filtrex = (function (exports) { 19: [2, 23], 21: [2, 23], 23: [2, 23], + 29: [2, 23], 30: [2, 23], 31: [2, 23], - 32: [2, 23], 33: [2, 23], 34: [2, 23], 35: [2, 23], - 36: [2, 23] + 36: [2, 23], + 37: [2, 23], + 38: [2, 23], + 39: [2, 23] }, { 1: [2, 1] }, { - 4: 37, + 4: 39, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -400,7 +428,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 38, + 4: 40, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -410,7 +438,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 39, + 4: 41, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -420,7 +448,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 40, + 4: 42, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -430,7 +458,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 41, + 4: 43, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -440,7 +468,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 42, + 4: 44, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -450,7 +478,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 43, + 4: 45, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -460,7 +488,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 44, + 4: 46, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -470,7 +498,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 45, + 4: 47, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -480,7 +508,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 46, + 4: 48, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -490,7 +518,7 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 48, + 4: 49, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -498,23 +526,27 @@ var filtrex = (function (exports) { 24: [1, 7], 25: [1, 8], 26: [1, 9], - 28: 47 + 28: 10 }, { - 6: [2, 24], - 14: [2, 24], - 15: [2, 24], - 20: [2, 24], - 24: [2, 24], - 25: [2, 24], - 26: [2, 24] - }, { - 6: [2, 25], - 14: [2, 25], - 15: [2, 25], - 20: [2, 25], - 24: [2, 25], - 25: [2, 25], - 26: [2, 25] + 4: 50, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 10 + }, { + 4: 52, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 51 }, { 6: [2, 26], 14: [2, 26], @@ -555,14 +587,30 @@ var filtrex = (function (exports) { 24: [2, 30], 25: [2, 30], 26: [2, 30] + }, { + 6: [2, 31], + 14: [2, 31], + 15: [2, 31], + 20: [2, 31], + 24: [2, 31], + 25: [2, 31], + 26: [2, 31] + }, { + 6: [2, 32], + 14: [2, 32], + 15: [2, 32], + 20: [2, 32], + 24: [2, 32], + 25: [2, 32], + 26: [2, 32] }, { 5: [2, 2], 6: [2, 2], 7: [2, 2], 8: [2, 2], 9: [2, 2], - 10: [2, 2], - 11: [1, 17], + 10: [1, 16], + 11: [2, 2], 12: [2, 2], 13: [2, 2], 16: [2, 2], @@ -571,22 +619,25 @@ var filtrex = (function (exports) { 19: [2, 2], 21: [2, 2], 23: [2, 2], - 29: 22, + 29: [2, 2], 30: [2, 2], 31: [2, 2], - 32: [2, 2], + 32: 24, 33: [2, 2], 34: [2, 2], 35: [2, 2], - 36: [2, 2] + 36: [2, 2], + 37: [2, 2], + 38: [2, 2], + 39: [2, 2] }, { 5: [2, 11], 6: [2, 11], 7: [2, 11], 8: [2, 11], 9: [2, 11], - 10: [2, 11], - 11: [1, 17], + 10: [1, 16], + 11: [2, 11], 12: [2, 11], 13: [2, 11], 16: [2, 11], @@ -595,14 +646,17 @@ var filtrex = (function (exports) { 19: [2, 11], 21: [2, 11], 23: [2, 11], - 29: 22, + 29: [2, 11], 30: [2, 11], 31: [2, 11], - 32: [2, 11], + 32: 24, 33: [2, 11], 34: [2, 11], 35: [2, 11], - 36: [2, 11] + 36: [2, 11], + 37: [2, 11], + 38: [2, 11], + 39: [2, 11] }, { 6: [1, 13], 7: [1, 12], @@ -612,17 +666,19 @@ var filtrex = (function (exports) { 11: [1, 17], 12: [1, 18], 13: [1, 19], - 16: [1, 49], + 16: [1, 53], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 6: [1, 13], 7: [1, 12], @@ -634,20 +690,22 @@ var filtrex = (function (exports) { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [1, 50], - 23: [2, 33], - 29: 22, + 21: [1, 54], + 23: [2, 35], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { - 23: [1, 51] + 23: [1, 55] }, { - 4: 52, + 4: 56, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -657,13 +715,13 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 55, + 4: 59, 6: [1, 3], 14: [1, 4], 15: [1, 5], 20: [1, 6], - 21: [1, 53], - 22: 54, + 21: [1, 57], + 22: 58, 24: [1, 7], 25: [1, 8], 26: [1, 9], @@ -684,14 +742,17 @@ var filtrex = (function (exports) { 19: [2, 3], 21: [2, 3], 23: [2, 3], - 29: 22, + 29: [1, 22], 30: [2, 3], 31: [2, 3], - 32: [2, 3], + 32: 24, 33: [2, 3], 34: [2, 3], 35: [2, 3], - 36: [2, 3] + 36: [2, 3], + 37: [2, 3], + 38: [2, 3], + 39: [2, 3] }, { 5: [2, 4], 6: [2, 4], @@ -708,22 +769,25 @@ var filtrex = (function (exports) { 19: [2, 4], 21: [2, 4], 23: [2, 4], - 29: 22, + 29: [1, 22], 30: [2, 4], 31: [2, 4], - 32: [2, 4], + 32: 24, 33: [2, 4], 34: [2, 4], 35: [2, 4], - 36: [2, 4] + 36: [2, 4], + 37: [2, 4], + 38: [2, 4], + 39: [2, 4] }, { 5: [2, 5], 6: [2, 5], 7: [2, 5], 8: [2, 5], 9: [2, 5], - 10: [2, 5], - 11: [1, 17], + 10: [1, 16], + 11: [2, 5], 12: [2, 5], 13: [2, 5], 16: [2, 5], @@ -732,22 +796,25 @@ var filtrex = (function (exports) { 19: [2, 5], 21: [2, 5], 23: [2, 5], - 29: 22, + 29: [2, 5], 30: [2, 5], 31: [2, 5], - 32: [2, 5], + 32: 24, 33: [2, 5], 34: [2, 5], 35: [2, 5], - 36: [2, 5] + 36: [2, 5], + 37: [2, 5], + 38: [2, 5], + 39: [2, 5] }, { 5: [2, 6], 6: [2, 6], 7: [2, 6], 8: [2, 6], 9: [2, 6], - 10: [2, 6], - 11: [1, 17], + 10: [1, 16], + 11: [2, 6], 12: [2, 6], 13: [2, 6], 16: [2, 6], @@ -756,22 +823,25 @@ var filtrex = (function (exports) { 19: [2, 6], 21: [2, 6], 23: [2, 6], - 29: 22, + 29: [2, 6], 30: [2, 6], 31: [2, 6], - 32: [2, 6], + 32: 24, 33: [2, 6], 34: [2, 6], 35: [2, 6], - 36: [2, 6] + 36: [2, 6], + 37: [2, 6], + 38: [2, 6], + 39: [2, 6] }, { 5: [2, 7], 6: [2, 7], 7: [2, 7], 8: [2, 7], 9: [2, 7], - 10: [2, 7], - 11: [1, 17], + 10: [1, 16], + 11: [2, 7], 12: [2, 7], 13: [2, 7], 16: [2, 7], @@ -780,22 +850,25 @@ var filtrex = (function (exports) { 19: [2, 7], 21: [2, 7], 23: [2, 7], - 29: 22, + 29: [2, 7], 30: [2, 7], 31: [2, 7], - 32: [2, 7], + 32: 24, 33: [2, 7], 34: [2, 7], 35: [2, 7], - 36: [2, 7] + 36: [2, 7], + 37: [2, 7], + 38: [2, 7], + 39: [2, 7] }, { 5: [2, 8], 6: [2, 8], 7: [2, 8], 8: [2, 8], 9: [2, 8], - 10: [2, 8], - 11: [1, 17], + 10: [1, 16], + 11: [2, 8], 12: [2, 8], 13: [2, 8], 16: [2, 8], @@ -804,14 +877,17 @@ var filtrex = (function (exports) { 19: [2, 8], 21: [2, 8], 23: [2, 8], - 29: 22, + 29: [2, 8], 30: [2, 8], 31: [2, 8], - 32: [2, 8], + 32: 24, 33: [2, 8], 34: [2, 8], 35: [2, 8], - 36: [2, 8] + 36: [2, 8], + 37: [2, 8], + 38: [2, 8], + 39: [2, 8] }, { 5: [2, 9], 6: [1, 13], @@ -828,14 +904,17 @@ var filtrex = (function (exports) { 19: [1, 21], 21: [2, 9], 23: [2, 9], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 9], + 31: [2, 9], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 10], 6: [1, 13], @@ -852,14 +931,17 @@ var filtrex = (function (exports) { 19: [1, 21], 21: [2, 10], 23: [2, 10], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 10], + 31: [2, 10], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 13], 6: [1, 13], @@ -876,14 +958,17 @@ var filtrex = (function (exports) { 19: [2, 13], 21: [2, 13], 23: [2, 13], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 13], + 31: [2, 13], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 14], 6: [1, 13], @@ -900,63 +985,121 @@ var filtrex = (function (exports) { 19: [2, 14], 21: [2, 14], 23: [2, 14], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] - }, { - 5: [2, 31], - 6: [2, 31], - 7: [2, 31], - 8: [2, 31], - 9: [2, 31], - 10: [2, 31], - 11: [2, 31], - 12: [2, 31], - 13: [2, 31], - 16: [2, 31], - 17: [2, 31], - 18: [2, 31], - 19: [2, 31], - 21: [2, 31], - 23: [2, 31], - 30: [2, 31], - 31: [2, 31], - 32: [2, 31], - 33: [2, 31], - 34: [2, 31], - 35: [2, 31], - 36: [2, 31] - }, { - 5: [2, 32], + 29: [1, 22], + 30: [2, 14], + 31: [2, 14], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 5: [2, 24], + 6: [2, 24], + 7: [2, 24], + 8: [2, 24], + 9: [2, 24], + 10: [1, 16], + 11: [2, 24], + 12: [2, 24], + 13: [2, 24], + 16: [2, 24], + 17: [2, 24], + 18: [2, 24], + 19: [2, 24], + 21: [2, 24], + 23: [2, 24], + 29: [2, 24], + 30: [2, 24], + 31: [2, 24], + 32: 24, + 33: [2, 24], + 34: [2, 24], + 35: [2, 24], + 36: [2, 24], + 37: [2, 24], + 38: [2, 24], + 39: [2, 24] + }, { 6: [1, 13], 7: [1, 12], 8: [1, 14], 9: [1, 15], 10: [1, 16], 11: [1, 17], - 12: [2, 32], - 13: [2, 32], - 16: [2, 32], - 17: [2, 32], - 18: [2, 32], - 19: [2, 32], - 21: [2, 32], - 23: [2, 32], - 29: 22, + 12: [1, 18], + 13: [1, 19], + 18: [1, 20], + 19: [1, 21], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 31: [1, 60], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { - 4: 56, + 5: [2, 33], + 6: [2, 33], + 7: [2, 33], + 8: [2, 33], + 9: [2, 33], + 10: [2, 33], + 11: [2, 33], + 12: [2, 33], + 13: [2, 33], + 16: [2, 33], + 17: [2, 33], + 18: [2, 33], + 19: [2, 33], + 21: [2, 33], + 23: [2, 33], + 29: [2, 33], + 30: [2, 33], + 31: [2, 33], + 33: [2, 33], + 34: [2, 33], + 35: [2, 33], + 36: [2, 33], + 37: [2, 33], + 38: [2, 33], + 39: [2, 33] + }, { + 5: [2, 34], + 6: [1, 13], + 7: [1, 12], + 8: [1, 14], + 9: [1, 15], + 10: [1, 16], + 11: [1, 17], + 12: [2, 34], + 13: [2, 34], + 16: [2, 34], + 17: [2, 34], + 18: [2, 34], + 19: [2, 34], + 21: [2, 34], + 23: [2, 34], + 29: [1, 22], + 30: [2, 34], + 31: [2, 34], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 61, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -981,15 +1124,18 @@ var filtrex = (function (exports) { 19: [2, 15], 21: [2, 15], 23: [2, 15], + 29: [2, 15], 30: [2, 15], 31: [2, 15], - 32: [2, 15], 33: [2, 15], 34: [2, 15], 35: [2, 15], - 36: [2, 15] + 36: [2, 15], + 37: [2, 15], + 38: [2, 15], + 39: [2, 15] }, { - 4: 57, + 4: 62, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1014,14 +1160,17 @@ var filtrex = (function (exports) { 19: [2, 20], 21: [2, 20], 23: [2, 20], - 29: 22, + 29: [2, 20], 30: [2, 20], 31: [2, 20], - 32: [2, 20], + 32: 24, 33: [2, 20], 34: [2, 20], 35: [2, 20], - 36: [2, 20] + 36: [2, 20], + 37: [2, 20], + 38: [2, 20], + 39: [2, 20] }, { 5: [2, 21], 6: [2, 21], @@ -1038,16 +1187,19 @@ var filtrex = (function (exports) { 19: [2, 21], 21: [2, 21], 23: [2, 21], + 29: [2, 21], 30: [2, 21], 31: [2, 21], - 32: [2, 21], 33: [2, 21], 34: [2, 21], 35: [2, 21], - 36: [2, 21] + 36: [2, 21], + 37: [2, 21], + 38: [2, 21], + 39: [2, 21] }, { - 21: [1, 58], - 23: [1, 59] + 21: [1, 63], + 23: [1, 64] }, { 6: [1, 13], 7: [1, 12], @@ -1059,16 +1211,28 @@ var filtrex = (function (exports) { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [2, 33], - 23: [2, 33], - 29: 22, + 21: [2, 35], + 23: [2, 35], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 65, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 10 }, { 6: [1, 13], 7: [1, 12], @@ -1078,17 +1242,19 @@ var filtrex = (function (exports) { 11: [1, 17], 12: [1, 18], 13: [1, 19], - 17: [1, 60], + 17: [1, 66], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 6: [1, 13], 7: [1, 12], @@ -1100,16 +1266,18 @@ var filtrex = (function (exports) { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [1, 61], - 23: [2, 34], - 29: 22, + 21: [1, 67], + 23: [2, 36], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 22], 6: [2, 22], @@ -1126,15 +1294,18 @@ var filtrex = (function (exports) { 19: [2, 22], 21: [2, 22], 23: [2, 22], + 29: [2, 22], 30: [2, 22], 31: [2, 22], - 32: [2, 22], 33: [2, 22], 34: [2, 22], 35: [2, 22], - 36: [2, 22] + 36: [2, 22], + 37: [2, 22], + 38: [2, 22], + 39: [2, 22] }, { - 4: 62, + 4: 68, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1144,7 +1315,34 @@ var filtrex = (function (exports) { 26: [1, 9], 28: 10 }, { - 4: 63, + 5: [2, 25], + 6: [1, 13], + 7: [1, 12], + 8: [1, 14], + 9: [1, 15], + 10: [1, 16], + 11: [1, 17], + 12: [1, 18], + 13: [1, 19], + 16: [2, 25], + 17: [2, 25], + 18: [1, 20], + 19: [1, 21], + 21: [2, 25], + 23: [2, 25], + 29: [1, 22], + 30: [1, 23], + 31: [2, 25], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 69, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1169,13 +1367,16 @@ var filtrex = (function (exports) { 19: [2, 16], 21: [2, 16], 23: [2, 16], + 29: [2, 16], 30: [2, 16], 31: [2, 16], - 32: [2, 16], 33: [2, 16], 34: [2, 16], 35: [2, 16], - 36: [2, 16] + 36: [2, 16], + 37: [2, 16], + 38: [2, 16], + 39: [2, 16] }, { 6: [1, 13], 7: [1, 12], @@ -1187,16 +1388,18 @@ var filtrex = (function (exports) { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [2, 34], - 23: [2, 34], - 29: 22, + 21: [2, 36], + 23: [2, 36], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 12], 6: [1, 13], @@ -1213,14 +1416,17 @@ var filtrex = (function (exports) { 19: [1, 21], 21: [2, 12], 23: [2, 12], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 31: [2, 12], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }], defaultActions: { 11: [2, 1] @@ -1618,45 +1824,45 @@ var filtrex = (function (exports) { case 4: return "^"; case 5: - return "%"; - case 6: return "("; - case 7: + case 6: return ")"; - case 8: + case 7: return ","; - case 9: + case 8: return "=="; - case 10: + case 9: return "!="; - case 11: + case 10: return "~="; - case 12: + case 11: return ">="; - case 13: + case 12: return "<="; - case 14: + case 13: return "<"; - case 15: + case 14: return ">"; - case 16: + case 15: return "notIn"; - case 17: + case 16: return "and"; - case 18: + case 17: return "or"; - case 19: + case 18: return "not"; - case 20: + case 19: return "in"; - case 21: + case 20: return "of"; - case 22: + case 21: return "if"; - case 23: + case 22: return "then"; - case 24: + case 23: return "else"; + case 24: + return "mod"; case 25: break; case 26: @@ -1677,13 +1883,19 @@ var filtrex = (function (exports) { yy_.yytext = JSON.stringify(yy.buildString('"', yy_.yytext)); return "String"; case 30: + return "%"; + case 31: + return "?"; + case 32: + return ":"; + case 33: return "EOF"; } }; - lexer.rules = [/^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\%)/, /^(?:\()/, /^(?:\))/, /^(?:\,)/, /^(?:==)/, /^(?:\!=)/, /^(?:\~=)/, /^(?:>=)/, /^(?:<=)/, /^(?:<)/, /^(?:>)/, /^(?:not\s+in[^\w])/, /^(?:and[^\w])/, /^(?:or[^\w])/, /^(?:not[^\w])/, /^(?:in[^\w])/, /^(?:of[^\w])/, /^(?:if[^\w])/, /^(?:then[^\w])/, /^(?:else[^\w])/, /^(?:\s+)/, /^(?:[0-9]+(?:\.[0-9]+)?(?![0-9\.]))/, /^(?:[a-zA-Z$_][\.a-zA-Z0-9$_]*)/, /^(?:'(?:\\'|\\\\|[^'\\])*')/, /^(?:"(?:\\"|\\\\|[^"\\])*")/, /^(?:$)/]; + lexer.rules = [/^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\()/, /^(?:\))/, /^(?:\,)/, /^(?:==)/, /^(?:\!=)/, /^(?:\~=)/, /^(?:>=)/, /^(?:<=)/, /^(?:<)/, /^(?:>)/, /^(?:not\s+in[^\w])/, /^(?:and[^\w])/, /^(?:or[^\w])/, /^(?:not[^\w])/, /^(?:in[^\w])/, /^(?:of[^\w])/, /^(?:if[^\w])/, /^(?:then[^\w])/, /^(?:else[^\w])/, /^(?:mod[^\w])/, /^(?:\s+)/, /^(?:[0-9]+(?:\.[0-9]+)?(?![0-9\.]))/, /^(?:[a-zA-Z$_][\.a-zA-Z0-9$_]*)/, /^(?:'(?:\\'|\\\\|[^'\\])*')/, /^(?:"(?:\\"|\\\\|[^"\\])*")/, /^(?:\%)/, /^(?:\?)/, /^(?::)/, /^(?:$)/]; lexer.conditions = { "INITIAL": { - "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], + "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], "inclusive": true } }; @@ -1957,6 +2169,40 @@ var filtrex = (function (exports) { return A.every( val => B.includes(val) ) }, + warnDeprecated: (function () { + const warnMax = 3; + + let warnedTimes = { + ternary: 0, + modulo: 0 + }; + + return (cause, value) => { + switch (cause) { + case 'ternary': + if (warnedTimes.ternary++ >= warnMax) break + console.warn( + "The use of ? and : as conditional operators has been deprecated " + + "in Filtrex v3 in favor of the if..then..else ternary operator. " + + "See issue #34 for more information." + ); + break + + case 'modulo': + if (warnedTimes.modulo++ >= warnMax) break + console.warn( + "The use of '%' as a modulo operator has been deprecated in Filtrex v3 " + + "in favor of the 'mod' operator. You can use it like this: '3 mod 2 == 1'. " + + "See issue #48 for more information." + ); + break + } + + return value + } + + })(), + buildString(quote, literal) { quote = String(quote)[0]; @@ -2041,8 +2287,8 @@ var filtrex = (function (exports) { * * `x - y` Subtract * * `x * y` Multiply * * `x / y` Divide - * * `x % y` Modulo * * `x ^ y` Power + * * `x mod y` Modulo * * `x == y` Equals * * `x < y` Less than * * `x <= y` Less than or equal to @@ -2113,8 +2359,8 @@ var filtrex = (function (exports) { '*': (a, b) => num(a) * num(b), '/': (a, b) => num(a) / num(b), - '%': (a, b) => mod(num(a), num(b)), '^': (a, b) => Math.pow(num(a), num(b)), + 'mod': (a, b) => mod(num(a), num(b)), '==': (a, b) => a === b, '!=': (a, b) => a !== b, diff --git a/dist/browser/filtrex.min.js b/dist/browser/filtrex.min.js index 78dd7c7..36f566a 100644 --- a/dist/browser/filtrex.min.js +++ b/dist/browser/filtrex.min.js @@ -1 +1 @@ -var filtrex=function(t){"use strict";var e=function(){var t={trace:function(){},yy:{},symbols_:{error:2,expressions:3,e:4,EOF:5,"-":6,"+":7,"*":8,"/":9,"%":10,"^":11,and:12,or:13,not:14,if:15,then:16,else:17,in:18,notIn:19,"(":20,")":21,Arguments:22,",":23,Number:24,Symbol:25,String:26,of:27,Relation:28,RelationalOperator:29,"==":30,"!=":31,"~=":32,"<":33,"<=":34,">=":35,">":36,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",6:"-",7:"+",8:"*",9:"/",10:"%",11:"^",12:"and",13:"or",14:"not",15:"if",16:"then",17:"else",18:"in",19:"notIn",20:"(",21:")",23:",",24:"Number",25:"Symbol",26:"String",27:"of",30:"==",31:"!=",32:"~=",33:"<",34:"<=",35:">=",36:">"},productions_:[0,[3,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,2],[4,6],[4,3],[4,3],[4,3],[4,5],[4,1],[4,1],[4,1],[4,3],[4,3],[4,4],[4,1],[29,1],[29,1],[29,1],[29,1],[29,1],[29,1],[29,1],[28,3],[28,3],[22,1],[22,3]],performAction:function(t,e,n,r,s,i,o){var l=i.length-1;switch(s){case 1:return i[l-1];case 2:this.$=["(","ops['-'](",i[l],")",")"];break;case 3:case 4:case 5:case 6:case 7:case 8:this.$=["(","ops['",i[l-1],"'](",i[l-2],", ",i[l],")",")"];break;case 9:this.$=["(","","std.coerceBoolean","(",i[l-2],") && ","std.coerceBoolean","(",i[l],")",")"];break;case 10:this.$=["(","","std.coerceBoolean","(",i[l-2],") || ","std.coerceBoolean","(",i[l],")",")"];break;case 11:this.$=["(","! ","std.coerceBoolean","(",i[l],")",")"];break;case 12:this.$=["(","","std.coerceBoolean","(",i[l-4],") ? ",i[l-2]," : ",i[l],"",")"];break;case 13:this.$=["(","std.isSubset(",i[l-2],", ",i[l],")",")"];break;case 14:this.$=["(","!std.isSubset(",i[l-2],", ",i[l],")",")"];break;case 15:this.$=["(","",i[l-1],"",")"];break;case 16:this.$=["(","[ ",i[l-3],", ",i[l-1]," ]",")"];break;case 17:this.$=["",i[l],""];break;case 18:this.$=["prop(",i[l],", data)"];break;case 19:this.$=["",i[l],""];break;case 20:this.$=["prop(",i[l-2],", ",i[l],")"];break;case 21:this.$=["call(",i[l-2],")"];break;case 22:this.$=["call(",i[l-3],", ",i[l-1],")"];break;case 23:this.$=r.reduceRelation(i[l]);break;case 24:this.$=["=="];break;case 25:this.$=["!="];break;case 26:this.$=["~="];break;case 27:this.$=["<"];break;case 28:this.$=["<="];break;case 29:this.$=[">="];break;case 30:this.$=[">"];break;case 31:this.$=[i[l-2],i[l-1],...i[l]];break;case 32:this.$=[i[l-2],i[l-1],i[l]];break;case 33:this.$=["",i[l],""];break;case 34:this.$=["",i[l-2],", ",i[l],""]}},table:[{3:1,4:2,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{1:[3]},{5:[1,11],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{4:30,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:31,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:32,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:33,6:[1,3],14:[1,4],15:[1,5],20:[1,6],22:34,24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,17],6:[2,17],7:[2,17],8:[2,17],9:[2,17],10:[2,17],11:[2,17],12:[2,17],13:[2,17],16:[2,17],17:[2,17],18:[2,17],19:[2,17],21:[2,17],23:[2,17],30:[2,17],31:[2,17],32:[2,17],33:[2,17],34:[2,17],35:[2,17],36:[2,17]},{5:[2,18],6:[2,18],7:[2,18],8:[2,18],9:[2,18],10:[2,18],11:[2,18],12:[2,18],13:[2,18],16:[2,18],17:[2,18],18:[2,18],19:[2,18],20:[1,36],21:[2,18],23:[2,18],27:[1,35],30:[2,18],31:[2,18],32:[2,18],33:[2,18],34:[2,18],35:[2,18],36:[2,18]},{5:[2,19],6:[2,19],7:[2,19],8:[2,19],9:[2,19],10:[2,19],11:[2,19],12:[2,19],13:[2,19],16:[2,19],17:[2,19],18:[2,19],19:[2,19],21:[2,19],23:[2,19],30:[2,19],31:[2,19],32:[2,19],33:[2,19],34:[2,19],35:[2,19],36:[2,19]},{5:[2,23],6:[2,23],7:[2,23],8:[2,23],9:[2,23],10:[2,23],11:[2,23],12:[2,23],13:[2,23],16:[2,23],17:[2,23],18:[2,23],19:[2,23],21:[2,23],23:[2,23],30:[2,23],31:[2,23],32:[2,23],33:[2,23],34:[2,23],35:[2,23],36:[2,23]},{1:[2,1]},{4:37,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:38,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:39,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:40,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:41,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:42,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:43,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:44,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:45,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:46,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:48,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:47},{6:[2,24],14:[2,24],15:[2,24],20:[2,24],24:[2,24],25:[2,24],26:[2,24]},{6:[2,25],14:[2,25],15:[2,25],20:[2,25],24:[2,25],25:[2,25],26:[2,25]},{6:[2,26],14:[2,26],15:[2,26],20:[2,26],24:[2,26],25:[2,26],26:[2,26]},{6:[2,27],14:[2,27],15:[2,27],20:[2,27],24:[2,27],25:[2,27],26:[2,27]},{6:[2,28],14:[2,28],15:[2,28],20:[2,28],24:[2,28],25:[2,28],26:[2,28]},{6:[2,29],14:[2,29],15:[2,29],20:[2,29],24:[2,29],25:[2,29],26:[2,29]},{6:[2,30],14:[2,30],15:[2,30],20:[2,30],24:[2,30],25:[2,30],26:[2,30]},{5:[2,2],6:[2,2],7:[2,2],8:[2,2],9:[2,2],10:[2,2],11:[1,17],12:[2,2],13:[2,2],16:[2,2],17:[2,2],18:[2,2],19:[2,2],21:[2,2],23:[2,2],29:22,30:[2,2],31:[2,2],32:[2,2],33:[2,2],34:[2,2],35:[2,2],36:[2,2]},{5:[2,11],6:[2,11],7:[2,11],8:[2,11],9:[2,11],10:[2,11],11:[1,17],12:[2,11],13:[2,11],16:[2,11],17:[2,11],18:[2,11],19:[2,11],21:[2,11],23:[2,11],29:22,30:[2,11],31:[2,11],32:[2,11],33:[2,11],34:[2,11],35:[2,11],36:[2,11]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],16:[1,49],18:[1,20],19:[1,21],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],21:[1,50],23:[2,33],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{23:[1,51]},{4:52,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:55,6:[1,3],14:[1,4],15:[1,5],20:[1,6],21:[1,53],22:54,24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,3],6:[2,3],7:[2,3],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,3],13:[2,3],16:[2,3],17:[2,3],18:[2,3],19:[2,3],21:[2,3],23:[2,3],29:22,30:[2,3],31:[2,3],32:[2,3],33:[2,3],34:[2,3],35:[2,3],36:[2,3]},{5:[2,4],6:[2,4],7:[2,4],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,4],13:[2,4],16:[2,4],17:[2,4],18:[2,4],19:[2,4],21:[2,4],23:[2,4],29:22,30:[2,4],31:[2,4],32:[2,4],33:[2,4],34:[2,4],35:[2,4],36:[2,4]},{5:[2,5],6:[2,5],7:[2,5],8:[2,5],9:[2,5],10:[2,5],11:[1,17],12:[2,5],13:[2,5],16:[2,5],17:[2,5],18:[2,5],19:[2,5],21:[2,5],23:[2,5],29:22,30:[2,5],31:[2,5],32:[2,5],33:[2,5],34:[2,5],35:[2,5],36:[2,5]},{5:[2,6],6:[2,6],7:[2,6],8:[2,6],9:[2,6],10:[2,6],11:[1,17],12:[2,6],13:[2,6],16:[2,6],17:[2,6],18:[2,6],19:[2,6],21:[2,6],23:[2,6],29:22,30:[2,6],31:[2,6],32:[2,6],33:[2,6],34:[2,6],35:[2,6],36:[2,6]},{5:[2,7],6:[2,7],7:[2,7],8:[2,7],9:[2,7],10:[2,7],11:[1,17],12:[2,7],13:[2,7],16:[2,7],17:[2,7],18:[2,7],19:[2,7],21:[2,7],23:[2,7],29:22,30:[2,7],31:[2,7],32:[2,7],33:[2,7],34:[2,7],35:[2,7],36:[2,7]},{5:[2,8],6:[2,8],7:[2,8],8:[2,8],9:[2,8],10:[2,8],11:[1,17],12:[2,8],13:[2,8],16:[2,8],17:[2,8],18:[2,8],19:[2,8],21:[2,8],23:[2,8],29:22,30:[2,8],31:[2,8],32:[2,8],33:[2,8],34:[2,8],35:[2,8],36:[2,8]},{5:[2,9],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,9],13:[2,9],16:[2,9],17:[2,9],18:[1,20],19:[1,21],21:[2,9],23:[2,9],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{5:[2,10],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[2,10],16:[2,10],17:[2,10],18:[1,20],19:[1,21],21:[2,10],23:[2,10],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{5:[2,13],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,13],13:[2,13],16:[2,13],17:[2,13],18:[2,13],19:[2,13],21:[2,13],23:[2,13],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{5:[2,14],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,14],13:[2,14],16:[2,14],17:[2,14],18:[2,14],19:[2,14],21:[2,14],23:[2,14],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{5:[2,31],6:[2,31],7:[2,31],8:[2,31],9:[2,31],10:[2,31],11:[2,31],12:[2,31],13:[2,31],16:[2,31],17:[2,31],18:[2,31],19:[2,31],21:[2,31],23:[2,31],30:[2,31],31:[2,31],32:[2,31],33:[2,31],34:[2,31],35:[2,31],36:[2,31]},{5:[2,32],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,32],13:[2,32],16:[2,32],17:[2,32],18:[2,32],19:[2,32],21:[2,32],23:[2,32],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{4:56,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,15],6:[2,15],7:[2,15],8:[2,15],9:[2,15],10:[2,15],11:[2,15],12:[2,15],13:[2,15],16:[2,15],17:[2,15],18:[2,15],19:[2,15],21:[2,15],23:[2,15],30:[2,15],31:[2,15],32:[2,15],33:[2,15],34:[2,15],35:[2,15],36:[2,15]},{4:57,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,20],6:[2,20],7:[2,20],8:[2,20],9:[2,20],10:[2,20],11:[2,20],12:[2,20],13:[2,20],16:[2,20],17:[2,20],18:[2,20],19:[2,20],21:[2,20],23:[2,20],29:22,30:[2,20],31:[2,20],32:[2,20],33:[2,20],34:[2,20],35:[2,20],36:[2,20]},{5:[2,21],6:[2,21],7:[2,21],8:[2,21],9:[2,21],10:[2,21],11:[2,21],12:[2,21],13:[2,21],16:[2,21],17:[2,21],18:[2,21],19:[2,21],21:[2,21],23:[2,21],30:[2,21],31:[2,21],32:[2,21],33:[2,21],34:[2,21],35:[2,21],36:[2,21]},{21:[1,58],23:[1,59]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],21:[2,33],23:[2,33],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],17:[1,60],18:[1,20],19:[1,21],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],21:[1,61],23:[2,34],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{5:[2,22],6:[2,22],7:[2,22],8:[2,22],9:[2,22],10:[2,22],11:[2,22],12:[2,22],13:[2,22],16:[2,22],17:[2,22],18:[2,22],19:[2,22],21:[2,22],23:[2,22],30:[2,22],31:[2,22],32:[2,22],33:[2,22],34:[2,22],35:[2,22],36:[2,22]},{4:62,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:63,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,16],6:[2,16],7:[2,16],8:[2,16],9:[2,16],10:[2,16],11:[2,16],12:[2,16],13:[2,16],16:[2,16],17:[2,16],18:[2,16],19:[2,16],21:[2,16],23:[2,16],30:[2,16],31:[2,16],32:[2,16],33:[2,16],34:[2,16],35:[2,16],36:[2,16]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],21:[2,34],23:[2,34],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]},{5:[2,12],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],16:[2,12],17:[2,12],18:[1,20],19:[1,21],21:[2,12],23:[2,12],29:22,30:[1,23],31:[1,24],32:[1,25],33:[1,26],34:[1,27],35:[1,28],36:[1,29]}],defaultActions:{11:[2,1]},parseError:function(t,e){throw new Error(t)},parse:function(t){var e=this,n=[0],r=[null],s=[],i=this.table,o="",l=0,h=0,a=0;this.lexer.setInput(t),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var c=this.lexer.yylloc;s.push(c);var u=this.lexer.options&&this.lexer.options.ranges;function y(){var t;return"number"!=typeof(t=e.lexer.lex()||1)&&(t=e.symbols_[t]||t),t}"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var f,p,g,m,d,b,x,_,w,k,$={};;){if(g=n[n.length-1],this.defaultActions[g]?m=this.defaultActions[g]:(null==f&&(f=y()),m=i[g]&&i[g][f]),void 0===m||!m.length||!m[0]){var S="";if(!a){for(b in w=[],i[g])this.terminals_[b]&&b>2&&w.push("'"+this.terminals_[b]+"'");S=this.lexer.showPosition?"Parse error on line "+(l+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[f]||f)+"'":"Parse error on line "+(l+1)+": Unexpected "+(1==f?"end of input":"'"+(this.terminals_[f]||f)+"'"),this.parseError(S,{text:this.lexer.match,token:this.terminals_[f]||f,line:this.lexer.yylineno,loc:c,expected:w})}if(3==a){if(1==f)throw new Error(S||"Parsing halted.");h=this.lexer.yyleng,o=this.lexer.yytext,l=this.lexer.yylineno,c=this.lexer.yylloc,f=y()}for(;!(2..toString()in i[g]);){if(0===g)throw new Error(S||"Parsing halted.");k=1,n.length=n.length-2*k,r.length=r.length-k,s.length=s.length-k,g=n[n.length-1]}p=2==f?null:f,f=2,m=i[g=n[n.length-1]]&&i[g][2],a=3}if(m[0]instanceof Array&&m.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+f);switch(m[0]){case 1:n.push(f),r.push(this.lexer.yytext),s.push(this.lexer.yylloc),n.push(m[1]),f=null,p?(f=p,p=null):(h=this.lexer.yyleng,o=this.lexer.yytext,l=this.lexer.yylineno,c=this.lexer.yylloc,a>0&&a--);break;case 2:if(x=this.productions_[m[1]][1],$.$=r[r.length-x],$._$={first_line:s[s.length-(x||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(x||1)].first_column,last_column:s[s.length-1].last_column},u&&($._$.range=[s[s.length-(x||1)].range[0],s[s.length-1].range[1]]),void 0!==(d=this.performAction.call($,o,h,l,this.yy,m[1],r,s)))return d;x&&(n=n.slice(0,-1*x*2),r=r.slice(0,-1*x),s=s.slice(0,-1*x)),n.push(this.productions_[m[1]][0]),r.push($.$),s.push($._$),_=i[n[n.length-2]][n[n.length-1]],n.push(_);break;case 3:return!0}}return!0}},e=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t){return this._input=t,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e-1),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-e]),this},more:function(){return this._more=!0,this},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},next:function(){if(this.done)return this.EOF;var t,e,n,r,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)||(e=n,r=o,this.options.flex));o++);return e?((s=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],t=this.performAction.call(this,this.yy,this,i[r],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),t||void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return void 0!==t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(t){this.begin(t)},options:{},performAction:function(t,e,n,r){switch(n){case 0:return"*";case 1:return"/";case 2:return"-";case 3:return"+";case 4:return"^";case 5:return"%";case 6:return"(";case 7:return")";case 8:return",";case 9:return"==";case 10:return"!=";case 11:return"~=";case 12:return">=";case 13:return"<=";case 14:return"<";case 15:return">";case 16:return"notIn";case 17:return"and";case 18:return"or";case 19:return"not";case 20:return"in";case 21:return"of";case 22:return"if";case 23:return"then";case 24:return"else";case 25:break;case 26:return"Number";case 27:return e.yytext=JSON.stringify({name:e.yytext,type:"unescaped"}),"Symbol";case 28:return e.yytext=JSON.stringify({name:t.buildString("'",e.yytext),type:"single-quoted"}),"Symbol";case 29:return e.yytext=JSON.stringify(t.buildString('"',e.yytext)),"String";case 30:return"EOF"}},rules:[/^(?:\*)/,/^(?:\/)/,/^(?:-)/,/^(?:\+)/,/^(?:\^)/,/^(?:\%)/,/^(?:\()/,/^(?:\))/,/^(?:\,)/,/^(?:==)/,/^(?:\!=)/,/^(?:\~=)/,/^(?:>=)/,/^(?:<=)/,/^(?:<)/,/^(?:>)/,/^(?:not\s+in[^\w])/,/^(?:and[^\w])/,/^(?:or[^\w])/,/^(?:not[^\w])/,/^(?:in[^\w])/,/^(?:of[^\w])/,/^(?:if[^\w])/,/^(?:then[^\w])/,/^(?:else[^\w])/,/^(?:\s+)/,/^(?:[0-9]+(?:\.[0-9]+)?(?![0-9\.]))/,/^(?:[a-zA-Z$_][\.a-zA-Z0-9$_]*)/,/^(?:'(?:\\'|\\\\|[^'\\])*')/,/^(?:"(?:\\"|\\\\|[^"\\])*")/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],inclusive:!0}}};return t}();function n(){this.yy={}}return t.lexer=e,n.prototype=t,t.Parser=n,new n}();const n=e;e.Parser;class r extends ReferenceError{I18N_STRING="UNKNOWN_FUNCTION";constructor(t){super(`Unknown function: ${t}()`),this.functionName=t}}class s extends ReferenceError{I18N_STRING="UNKNOWN_PROPERTY";constructor(t){super(`Property “${t}” does not exist.`),this.propertyName=t}}class i extends TypeError{I18N_STRING="UNKNOWN_OPTION";constructor(t){super("Unknown option: "+t),this.keyName=t}}class o extends TypeError{I18N_STRING="UNEXPECTED_TYPE";constructor(t,e){super(`Expected a ${t}, but got a ${e} instead.`),this.expectedType=t,this.recievedType=e}}class l extends Error{I18N_STRING="INTERNAL";constructor(t){super(t)}}function h(t,e){return("object"==typeof t||"function"==typeof t)&&Object.prototype.hasOwnProperty.call(t,e)}function a(t,e){return(t%e+e)%e}function c(t){return Array.isArray(t)&&1===t.length&&(t=t[0]),function(t){return"object"!=typeof t?t:t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():void 0}(t)}function u(t){return void 0===(t=c(t))?"undefined":null===t?"null":!0===t?"true":!1===t?"false":"number"==typeof t?"number":"string"==typeof t?"text":"object"!=typeof t&&"function"!=typeof t?"unknown type":Array.isArray(t)?"list":"object"}function y(t){if("number"==typeof(t=c(t)))return t;throw new o("number",u(t))}function f(t){if("string"==typeof(t=c(t)))return t;throw new o("text",u(t))}function p(t){if("string"==typeof(t=c(t))||"number"==typeof t)return t;throw new o("text or number",u(t))}function g(t){if(null==t)throw new o("list",u(t));return Array.isArray(t)?t:[t]}function m(t){const e=[...t],n=[];for(;e.length;){const t=e.pop();Array.isArray(t)?e.push(...t):n.push(t)}return n.reverse()}const d={isfn:(t,e)=>h(t,e)&&"function"==typeof t[e],unknown(t){throw new r(t)},coerceArray:g,coerceNumber:y,coerceNumberOrString:p,coerceBoolean:function(t){if("boolean"==typeof(t=c(t)))return t;throw new o("logical value (“true” or “false”)",u(t))},isSubset(t,e){const n=g(t),r=g(e);return n.every(t=>r.includes(t))},buildString(t,e){t=String(t)[0];let n="";if((e=String(e))[0]!==t||e[e.length-1]!==t)throw new l("Unexpected internal error: String literal doesn't begin/end with the right quotation mark.");for(let r=1;r=e.length-1)throw new l("Unexpected internal error: Unescaped backslash at the end of string literal.");if("\\"===e[r])n+="\\";else{if(e[r]!==t)throw new l("Unexpected internal error: Invalid escaped character in string literal: "+e[r]);n+=t}}else{if(e[r]===t)throw new l("Unexpected internal error: String literal contains unescaped quotation mark.");n+=e[r]}return n},reduceRelation(t){const e=[],n=[];let r=m([t[0]]).join(""),s=0;for(let i=1;i2)throw new TypeError("Too many arguments.");e="object"==typeof e?e:{};const o=["extraFunctions","constants","customProp","operators"];let{extraFunctions:l,constants:c,customProp:u,operators:g}=e;for(const t of Object.keys(e))if(!o.includes(t))throw new i(t);let b={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,log:Math.log,log2:Math.log2,log10:Math.log10,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,exists:t=>null!=t,empty:t=>null==t||""===t||Array.isArray(t)&&0===t.length};if(l)for(const t of Object.keys(l))b[t]=l[t];let x={"+":(t,e)=>p(t)+p(e),"-":(t,e)=>void 0===e?-y(t):y(t)-y(e),"*":(t,e)=>y(t)*y(e),"/":(t,e)=>y(t)/y(e),"%":(t,e)=>a(y(t),y(e)),"^":(t,e)=>Math.pow(y(t),y(e)),"==":(t,e)=>t===e,"!=":(t,e)=>t!==e,"<":(t,e)=>y(t)y(t)<=y(e),">=":(t,e)=>y(t)>=y(e),">":(t,e)=>y(t)>y(e),"~=":(t,e)=>RegExp(f(e)).test(f(t))};if(g)for(const t of Object.keys(g))x[t]=g[t];g=x,c=c??{};let _=m(n.parse(t));function w(t,e){if(h(e??{},t))return e[t];throw new s(t)}function k(t){return function(e){if(h(t??{},e))return t[e];throw new s(e)}}function $(t){return function({name:e},...n){if(h(t,e)&&"function"==typeof t[e])return t[e](...n);throw new r(e)}}function S({name:t,type:e},n){return"unescaped"===e&&h(c,t)?c[t]:w(t,n)}_.unshift("return "),_.push(";"),"function"==typeof u&&(w=(t,e)=>u(t,k(e),e));let N=new Function("call","ops","std","prop","data",_.join(""));return function(t){try{return N($(b),g,d,S,t)}catch(t){return t}}},Object.defineProperty(t,"__esModule",{value:!0}),t}({}); \ No newline at end of file +var filtrex=function(t){"use strict";var e=function(){var t={trace:function(){},yy:{},symbols_:{error:2,expressions:3,e:4,EOF:5,"-":6,"+":7,"*":8,"/":9,"^":10,mod:11,and:12,or:13,not:14,if:15,then:16,else:17,in:18,notIn:19,"(":20,")":21,Arguments:22,",":23,Number:24,Symbol:25,String:26,of:27,Relation:28,"%":29,"?":30,":":31,RelationalOperator:32,"==":33,"!=":34,"~=":35,"<":36,"<=":37,">=":38,">":39,$accept:0,$end:1},terminals_:{2:"error",5:"EOF",6:"-",7:"+",8:"*",9:"/",10:"^",11:"mod",12:"and",13:"or",14:"not",15:"if",16:"then",17:"else",18:"in",19:"notIn",20:"(",21:")",23:",",24:"Number",25:"Symbol",26:"String",27:"of",29:"%",30:"?",31:":",33:"==",34:"!=",35:"~=",36:"<",37:"<=",38:">=",39:">"},productions_:[0,[3,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,2],[4,6],[4,3],[4,3],[4,3],[4,5],[4,1],[4,1],[4,1],[4,3],[4,3],[4,4],[4,1],[4,3],[4,5],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[28,3],[28,3],[22,1],[22,3]],performAction:function(t,e,n,r,s,i,o){var a=i.length-1;switch(s){case 1:return i[a-1];case 2:this.$=["(","ops['-'](",i[a],")",")"];break;case 3:case 4:case 5:case 6:case 7:this.$=["(","ops['",i[a-1],"'](",i[a-2],", ",i[a],")",")"];break;case 8:this.$=["(","ops.mod(",i[a-2],", ",i[a],")",")"];break;case 9:this.$=["(","","std.coerceBoolean","(",i[a-2],") && ","std.coerceBoolean","(",i[a],")",")"];break;case 10:this.$=["(","","std.coerceBoolean","(",i[a-2],") || ","std.coerceBoolean","(",i[a],")",")"];break;case 11:this.$=["(","! ","std.coerceBoolean","(",i[a],")",")"];break;case 12:this.$=["(","","std.coerceBoolean","(",i[a-4],") ? ",i[a-2]," : ",i[a],"",")"];break;case 13:this.$=["(","std.isSubset(",i[a-2],", ",i[a],")",")"];break;case 14:this.$=["(","!std.isSubset(",i[a-2],", ",i[a],")",")"];break;case 15:this.$=["(","",i[a-1],"",")"];break;case 16:this.$=["(","[ ",i[a-3],", ",i[a-1]," ]",")"];break;case 17:this.$=["",i[a],""];break;case 18:this.$=["prop(",i[a],", data)"];break;case 19:this.$=["",i[a],""];break;case 20:this.$=["prop(",i[a-2],", ",i[a],")"];break;case 21:this.$=["call(",i[a-2],")"];break;case 22:this.$=["call(",i[a-3],", ",i[a-1],")"];break;case 23:this.$=r.reduceRelation(i[a]);break;case 24:this.$=["std.warnDeprecated('modulo', ops['mod'](",i[a-2],", ",i[a],"))"];break;case 25:this.$=["std.warnDeprecated('ternary', ","std.coerceBoolean","(",i[a-4],") ? ",i[a-2]," : ",i[a],")"];break;case 26:this.$=["=="];break;case 27:this.$=["!="];break;case 28:this.$=["~="];break;case 29:this.$=["<"];break;case 30:this.$=["<="];break;case 31:this.$=[">="];break;case 32:this.$=[">"];break;case 33:this.$=[i[a-2],i[a-1],...i[a]];break;case 34:this.$=[i[a-2],i[a-1],i[a]];break;case 35:this.$=["",i[a],""];break;case 36:this.$=["",i[a-2],", ",i[a],""]}},table:[{3:1,4:2,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{1:[3]},{5:[1,11],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],29:[1,22],30:[1,23],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{4:32,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:33,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:34,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:35,6:[1,3],14:[1,4],15:[1,5],20:[1,6],22:36,24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,17],6:[2,17],7:[2,17],8:[2,17],9:[2,17],10:[2,17],11:[2,17],12:[2,17],13:[2,17],16:[2,17],17:[2,17],18:[2,17],19:[2,17],21:[2,17],23:[2,17],29:[2,17],30:[2,17],31:[2,17],33:[2,17],34:[2,17],35:[2,17],36:[2,17],37:[2,17],38:[2,17],39:[2,17]},{5:[2,18],6:[2,18],7:[2,18],8:[2,18],9:[2,18],10:[2,18],11:[2,18],12:[2,18],13:[2,18],16:[2,18],17:[2,18],18:[2,18],19:[2,18],20:[1,38],21:[2,18],23:[2,18],27:[1,37],29:[2,18],30:[2,18],31:[2,18],33:[2,18],34:[2,18],35:[2,18],36:[2,18],37:[2,18],38:[2,18],39:[2,18]},{5:[2,19],6:[2,19],7:[2,19],8:[2,19],9:[2,19],10:[2,19],11:[2,19],12:[2,19],13:[2,19],16:[2,19],17:[2,19],18:[2,19],19:[2,19],21:[2,19],23:[2,19],29:[2,19],30:[2,19],31:[2,19],33:[2,19],34:[2,19],35:[2,19],36:[2,19],37:[2,19],38:[2,19],39:[2,19]},{5:[2,23],6:[2,23],7:[2,23],8:[2,23],9:[2,23],10:[2,23],11:[2,23],12:[2,23],13:[2,23],16:[2,23],17:[2,23],18:[2,23],19:[2,23],21:[2,23],23:[2,23],29:[2,23],30:[2,23],31:[2,23],33:[2,23],34:[2,23],35:[2,23],36:[2,23],37:[2,23],38:[2,23],39:[2,23]},{1:[2,1]},{4:39,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:40,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:41,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:42,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:43,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:44,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:45,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:46,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:47,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:48,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:49,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:50,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:52,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:51},{6:[2,26],14:[2,26],15:[2,26],20:[2,26],24:[2,26],25:[2,26],26:[2,26]},{6:[2,27],14:[2,27],15:[2,27],20:[2,27],24:[2,27],25:[2,27],26:[2,27]},{6:[2,28],14:[2,28],15:[2,28],20:[2,28],24:[2,28],25:[2,28],26:[2,28]},{6:[2,29],14:[2,29],15:[2,29],20:[2,29],24:[2,29],25:[2,29],26:[2,29]},{6:[2,30],14:[2,30],15:[2,30],20:[2,30],24:[2,30],25:[2,30],26:[2,30]},{6:[2,31],14:[2,31],15:[2,31],20:[2,31],24:[2,31],25:[2,31],26:[2,31]},{6:[2,32],14:[2,32],15:[2,32],20:[2,32],24:[2,32],25:[2,32],26:[2,32]},{5:[2,2],6:[2,2],7:[2,2],8:[2,2],9:[2,2],10:[1,16],11:[2,2],12:[2,2],13:[2,2],16:[2,2],17:[2,2],18:[2,2],19:[2,2],21:[2,2],23:[2,2],29:[2,2],30:[2,2],31:[2,2],32:24,33:[2,2],34:[2,2],35:[2,2],36:[2,2],37:[2,2],38:[2,2],39:[2,2]},{5:[2,11],6:[2,11],7:[2,11],8:[2,11],9:[2,11],10:[1,16],11:[2,11],12:[2,11],13:[2,11],16:[2,11],17:[2,11],18:[2,11],19:[2,11],21:[2,11],23:[2,11],29:[2,11],30:[2,11],31:[2,11],32:24,33:[2,11],34:[2,11],35:[2,11],36:[2,11],37:[2,11],38:[2,11],39:[2,11]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],16:[1,53],18:[1,20],19:[1,21],29:[1,22],30:[1,23],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],21:[1,54],23:[2,35],29:[1,22],30:[1,23],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{23:[1,55]},{4:56,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{4:59,6:[1,3],14:[1,4],15:[1,5],20:[1,6],21:[1,57],22:58,24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,3],6:[2,3],7:[2,3],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,3],13:[2,3],16:[2,3],17:[2,3],18:[2,3],19:[2,3],21:[2,3],23:[2,3],29:[1,22],30:[2,3],31:[2,3],32:24,33:[2,3],34:[2,3],35:[2,3],36:[2,3],37:[2,3],38:[2,3],39:[2,3]},{5:[2,4],6:[2,4],7:[2,4],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,4],13:[2,4],16:[2,4],17:[2,4],18:[2,4],19:[2,4],21:[2,4],23:[2,4],29:[1,22],30:[2,4],31:[2,4],32:24,33:[2,4],34:[2,4],35:[2,4],36:[2,4],37:[2,4],38:[2,4],39:[2,4]},{5:[2,5],6:[2,5],7:[2,5],8:[2,5],9:[2,5],10:[1,16],11:[2,5],12:[2,5],13:[2,5],16:[2,5],17:[2,5],18:[2,5],19:[2,5],21:[2,5],23:[2,5],29:[2,5],30:[2,5],31:[2,5],32:24,33:[2,5],34:[2,5],35:[2,5],36:[2,5],37:[2,5],38:[2,5],39:[2,5]},{5:[2,6],6:[2,6],7:[2,6],8:[2,6],9:[2,6],10:[1,16],11:[2,6],12:[2,6],13:[2,6],16:[2,6],17:[2,6],18:[2,6],19:[2,6],21:[2,6],23:[2,6],29:[2,6],30:[2,6],31:[2,6],32:24,33:[2,6],34:[2,6],35:[2,6],36:[2,6],37:[2,6],38:[2,6],39:[2,6]},{5:[2,7],6:[2,7],7:[2,7],8:[2,7],9:[2,7],10:[1,16],11:[2,7],12:[2,7],13:[2,7],16:[2,7],17:[2,7],18:[2,7],19:[2,7],21:[2,7],23:[2,7],29:[2,7],30:[2,7],31:[2,7],32:24,33:[2,7],34:[2,7],35:[2,7],36:[2,7],37:[2,7],38:[2,7],39:[2,7]},{5:[2,8],6:[2,8],7:[2,8],8:[2,8],9:[2,8],10:[1,16],11:[2,8],12:[2,8],13:[2,8],16:[2,8],17:[2,8],18:[2,8],19:[2,8],21:[2,8],23:[2,8],29:[2,8],30:[2,8],31:[2,8],32:24,33:[2,8],34:[2,8],35:[2,8],36:[2,8],37:[2,8],38:[2,8],39:[2,8]},{5:[2,9],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,9],13:[2,9],16:[2,9],17:[2,9],18:[1,20],19:[1,21],21:[2,9],23:[2,9],29:[1,22],30:[2,9],31:[2,9],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{5:[2,10],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[2,10],16:[2,10],17:[2,10],18:[1,20],19:[1,21],21:[2,10],23:[2,10],29:[1,22],30:[2,10],31:[2,10],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{5:[2,13],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,13],13:[2,13],16:[2,13],17:[2,13],18:[2,13],19:[2,13],21:[2,13],23:[2,13],29:[1,22],30:[2,13],31:[2,13],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{5:[2,14],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,14],13:[2,14],16:[2,14],17:[2,14],18:[2,14],19:[2,14],21:[2,14],23:[2,14],29:[1,22],30:[2,14],31:[2,14],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{5:[2,24],6:[2,24],7:[2,24],8:[2,24],9:[2,24],10:[1,16],11:[2,24],12:[2,24],13:[2,24],16:[2,24],17:[2,24],18:[2,24],19:[2,24],21:[2,24],23:[2,24],29:[2,24],30:[2,24],31:[2,24],32:24,33:[2,24],34:[2,24],35:[2,24],36:[2,24],37:[2,24],38:[2,24],39:[2,24]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],29:[1,22],30:[1,23],31:[1,60],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{5:[2,33],6:[2,33],7:[2,33],8:[2,33],9:[2,33],10:[2,33],11:[2,33],12:[2,33],13:[2,33],16:[2,33],17:[2,33],18:[2,33],19:[2,33],21:[2,33],23:[2,33],29:[2,33],30:[2,33],31:[2,33],33:[2,33],34:[2,33],35:[2,33],36:[2,33],37:[2,33],38:[2,33],39:[2,33]},{5:[2,34],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[2,34],13:[2,34],16:[2,34],17:[2,34],18:[2,34],19:[2,34],21:[2,34],23:[2,34],29:[1,22],30:[2,34],31:[2,34],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{4:61,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,15],6:[2,15],7:[2,15],8:[2,15],9:[2,15],10:[2,15],11:[2,15],12:[2,15],13:[2,15],16:[2,15],17:[2,15],18:[2,15],19:[2,15],21:[2,15],23:[2,15],29:[2,15],30:[2,15],31:[2,15],33:[2,15],34:[2,15],35:[2,15],36:[2,15],37:[2,15],38:[2,15],39:[2,15]},{4:62,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,20],6:[2,20],7:[2,20],8:[2,20],9:[2,20],10:[2,20],11:[2,20],12:[2,20],13:[2,20],16:[2,20],17:[2,20],18:[2,20],19:[2,20],21:[2,20],23:[2,20],29:[2,20],30:[2,20],31:[2,20],32:24,33:[2,20],34:[2,20],35:[2,20],36:[2,20],37:[2,20],38:[2,20],39:[2,20]},{5:[2,21],6:[2,21],7:[2,21],8:[2,21],9:[2,21],10:[2,21],11:[2,21],12:[2,21],13:[2,21],16:[2,21],17:[2,21],18:[2,21],19:[2,21],21:[2,21],23:[2,21],29:[2,21],30:[2,21],31:[2,21],33:[2,21],34:[2,21],35:[2,21],36:[2,21],37:[2,21],38:[2,21],39:[2,21]},{21:[1,63],23:[1,64]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],21:[2,35],23:[2,35],29:[1,22],30:[1,23],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{4:65,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],17:[1,66],18:[1,20],19:[1,21],29:[1,22],30:[1,23],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],21:[1,67],23:[2,36],29:[1,22],30:[1,23],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{5:[2,22],6:[2,22],7:[2,22],8:[2,22],9:[2,22],10:[2,22],11:[2,22],12:[2,22],13:[2,22],16:[2,22],17:[2,22],18:[2,22],19:[2,22],21:[2,22],23:[2,22],29:[2,22],30:[2,22],31:[2,22],33:[2,22],34:[2,22],35:[2,22],36:[2,22],37:[2,22],38:[2,22],39:[2,22]},{4:68,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,25],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],16:[2,25],17:[2,25],18:[1,20],19:[1,21],21:[2,25],23:[2,25],29:[1,22],30:[1,23],31:[2,25],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{4:69,6:[1,3],14:[1,4],15:[1,5],20:[1,6],24:[1,7],25:[1,8],26:[1,9],28:10},{5:[2,16],6:[2,16],7:[2,16],8:[2,16],9:[2,16],10:[2,16],11:[2,16],12:[2,16],13:[2,16],16:[2,16],17:[2,16],18:[2,16],19:[2,16],21:[2,16],23:[2,16],29:[2,16],30:[2,16],31:[2,16],33:[2,16],34:[2,16],35:[2,16],36:[2,16],37:[2,16],38:[2,16],39:[2,16]},{6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],18:[1,20],19:[1,21],21:[2,36],23:[2,36],29:[1,22],30:[1,23],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]},{5:[2,12],6:[1,13],7:[1,12],8:[1,14],9:[1,15],10:[1,16],11:[1,17],12:[1,18],13:[1,19],16:[2,12],17:[2,12],18:[1,20],19:[1,21],21:[2,12],23:[2,12],29:[1,22],30:[1,23],31:[2,12],32:24,33:[1,25],34:[1,26],35:[1,27],36:[1,28],37:[1,29],38:[1,30],39:[1,31]}],defaultActions:{11:[2,1]},parseError:function(t,e){throw new Error(t)},parse:function(t){var e=this,n=[0],r=[null],s=[],i=this.table,o="",a=0,l=0,h=0;this.lexer.setInput(t),this.lexer.yy=this.yy,this.yy.lexer=this.lexer,this.yy.parser=this,void 0===this.lexer.yylloc&&(this.lexer.yylloc={});var c=this.lexer.yylloc;s.push(c);var u=this.lexer.options&&this.lexer.options.ranges;function y(){var t;return"number"!=typeof(t=e.lexer.lex()||1)&&(t=e.symbols_[t]||t),t}"function"==typeof this.yy.parseError&&(this.parseError=this.yy.parseError);for(var f,p,g,d,m,b,x,_,w,k,$={};;){if(g=n[n.length-1],this.defaultActions[g]?d=this.defaultActions[g]:(null==f&&(f=y()),d=i[g]&&i[g][f]),void 0===d||!d.length||!d[0]){var v="";if(!h){for(b in w=[],i[g])this.terminals_[b]&&b>2&&w.push("'"+this.terminals_[b]+"'");v=this.lexer.showPosition?"Parse error on line "+(a+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+w.join(", ")+", got '"+(this.terminals_[f]||f)+"'":"Parse error on line "+(a+1)+": Unexpected "+(1==f?"end of input":"'"+(this.terminals_[f]||f)+"'"),this.parseError(v,{text:this.lexer.match,token:this.terminals_[f]||f,line:this.lexer.yylineno,loc:c,expected:w})}if(3==h){if(1==f)throw new Error(v||"Parsing halted.");l=this.lexer.yyleng,o=this.lexer.yytext,a=this.lexer.yylineno,c=this.lexer.yylloc,f=y()}for(;!(2..toString()in i[g]);){if(0===g)throw new Error(v||"Parsing halted.");k=1,n.length=n.length-2*k,r.length=r.length-k,s.length=s.length-k,g=n[n.length-1]}p=2==f?null:f,f=2,d=i[g=n[n.length-1]]&&i[g][2],h=3}if(d[0]instanceof Array&&d.length>1)throw new Error("Parse Error: multiple actions possible at state: "+g+", token: "+f);switch(d[0]){case 1:n.push(f),r.push(this.lexer.yytext),s.push(this.lexer.yylloc),n.push(d[1]),f=null,p?(f=p,p=null):(l=this.lexer.yyleng,o=this.lexer.yytext,a=this.lexer.yylineno,c=this.lexer.yylloc,h>0&&h--);break;case 2:if(x=this.productions_[d[1]][1],$.$=r[r.length-x],$._$={first_line:s[s.length-(x||1)].first_line,last_line:s[s.length-1].last_line,first_column:s[s.length-(x||1)].first_column,last_column:s[s.length-1].last_column},u&&($._$.range=[s[s.length-(x||1)].range[0],s[s.length-1].range[1]]),void 0!==(m=this.performAction.call($,o,l,a,this.yy,d[1],r,s)))return m;x&&(n=n.slice(0,-1*x*2),r=r.slice(0,-1*x),s=s.slice(0,-1*x)),n.push(this.productions_[d[1]][0]),r.push($.$),s.push($._$),_=i[n[n.length-2]][n[n.length-1]],n.push(_);break;case 3:return!0}}return!0}},e=function(){var t={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e)},setInput:function(t){return this._input=t,this._more=this._less=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e-1),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var s=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[s[0],s[0]+this.yyleng-e]),this},more:function(){return this._more=!0,this},less:function(t){this.unput(this.match.slice(t))},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},next:function(){if(this.done)return this.EOF;var t,e,n,r,s;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var i=this._currentRules(),o=0;oe[0].length)||(e=n,r=o,this.options.flex));o++);return e?((s=e[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=s.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:s?s[s.length-1].length-s[s.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+e[0].length},this.yytext+=e[0],this.match+=e[0],this.matches=e,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._input=this._input.slice(e[0].length),this.matched+=e[0],t=this.performAction.call(this,this.yy,this,i[r],this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),t||void 0):""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return void 0!==t?t:this.lex()},begin:function(t){this.conditionStack.push(t)},popState:function(){return this.conditionStack.pop()},_currentRules:function(){return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules},topState:function(){return this.conditionStack[this.conditionStack.length-2]},pushState:function(t){this.begin(t)},options:{},performAction:function(t,e,n,r){switch(n){case 0:return"*";case 1:return"/";case 2:return"-";case 3:return"+";case 4:return"^";case 5:return"(";case 6:return")";case 7:return",";case 8:return"==";case 9:return"!=";case 10:return"~=";case 11:return">=";case 12:return"<=";case 13:return"<";case 14:return">";case 15:return"notIn";case 16:return"and";case 17:return"or";case 18:return"not";case 19:return"in";case 20:return"of";case 21:return"if";case 22:return"then";case 23:return"else";case 24:return"mod";case 25:break;case 26:return"Number";case 27:return e.yytext=JSON.stringify({name:e.yytext,type:"unescaped"}),"Symbol";case 28:return e.yytext=JSON.stringify({name:t.buildString("'",e.yytext),type:"single-quoted"}),"Symbol";case 29:return e.yytext=JSON.stringify(t.buildString('"',e.yytext)),"String";case 30:return"%";case 31:return"?";case 32:return":";case 33:return"EOF"}},rules:[/^(?:\*)/,/^(?:\/)/,/^(?:-)/,/^(?:\+)/,/^(?:\^)/,/^(?:\()/,/^(?:\))/,/^(?:\,)/,/^(?:==)/,/^(?:\!=)/,/^(?:\~=)/,/^(?:>=)/,/^(?:<=)/,/^(?:<)/,/^(?:>)/,/^(?:not\s+in[^\w])/,/^(?:and[^\w])/,/^(?:or[^\w])/,/^(?:not[^\w])/,/^(?:in[^\w])/,/^(?:of[^\w])/,/^(?:if[^\w])/,/^(?:then[^\w])/,/^(?:else[^\w])/,/^(?:mod[^\w])/,/^(?:\s+)/,/^(?:[0-9]+(?:\.[0-9]+)?(?![0-9\.]))/,/^(?:[a-zA-Z$_][\.a-zA-Z0-9$_]*)/,/^(?:'(?:\\'|\\\\|[^'\\])*')/,/^(?:"(?:\\"|\\\\|[^"\\])*")/,/^(?:\%)/,/^(?:\?)/,/^(?::)/,/^(?:$)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33],inclusive:!0}}};return t}();function n(){this.yy={}}return t.lexer=e,n.prototype=t,t.Parser=n,new n}();const n=e;e.Parser;class r extends ReferenceError{I18N_STRING="UNKNOWN_FUNCTION";constructor(t){super(`Unknown function: ${t}()`),this.functionName=t}}class s extends ReferenceError{I18N_STRING="UNKNOWN_PROPERTY";constructor(t){super(`Property “${t}” does not exist.`),this.propertyName=t}}class i extends TypeError{I18N_STRING="UNKNOWN_OPTION";constructor(t){super(`Unknown option: ${t}`),this.keyName=t}}class o extends TypeError{I18N_STRING="UNEXPECTED_TYPE";constructor(t,e){super(`Expected a ${t}, but got a ${e} instead.`),this.expectedType=t,this.recievedType=e}}class a extends Error{I18N_STRING="INTERNAL";constructor(t){super(t)}}function l(t,e){return("object"==typeof t||"function"==typeof t)&&Object.prototype.hasOwnProperty.call(t,e)}function h(t,e){return(t%e+e)%e}function c(t){return Array.isArray(t)&&1===t.length&&(t=t[0]),function(t){return"object"!=typeof t?t:t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():void 0}(t)}function u(t){return void 0===(t=c(t))?"undefined":null===t?"null":!0===t?"true":!1===t?"false":"number"==typeof t?"number":"string"==typeof t?"text":"object"!=typeof t&&"function"!=typeof t?"unknown type":Array.isArray(t)?"list":"object"}function y(t){if("number"==typeof(t=c(t)))return t;throw new o("number",u(t))}function f(t){if("string"==typeof(t=c(t)))return t;throw new o("text",u(t))}function p(t){if("string"==typeof(t=c(t))||"number"==typeof t)return t;throw new o("text or number",u(t))}function g(t){if(null==t)throw new o("list",u(t));return Array.isArray(t)?t:[t]}function d(t){const e=[...t],n=[];for(;e.length;){const t=e.pop();Array.isArray(t)?e.push(...t):n.push(t)}return n.reverse()}const m={isfn:(t,e)=>l(t,e)&&"function"==typeof t[e],unknown(t){throw new r(t)},coerceArray:g,coerceNumber:y,coerceNumberOrString:p,coerceBoolean:function(t){if("boolean"==typeof(t=c(t)))return t;throw new o("logical value (“true” or “false”)",u(t))},isSubset(t,e){const n=g(t),r=g(e);return n.every((t=>r.includes(t)))},warnDeprecated:function(){let t={ternary:0,modulo:0};return(e,n)=>{switch(e){case"ternary":if(t.ternary++>=3)break;console.warn("The use of ? and : as conditional operators has been deprecated in Filtrex v3 in favor of the if..then..else ternary operator. See issue #34 for more information.");break;case"modulo":if(t.modulo++>=3)break;console.warn("The use of '%' as a modulo operator has been deprecated in Filtrex v3 in favor of the 'mod' operator. You can use it like this: '3 mod 2 == 1'. See issue #48 for more information.")}return n}}(),buildString(t,e){t=String(t)[0];let n="";if((e=String(e))[0]!==t||e[e.length-1]!==t)throw new a("Unexpected internal error: String literal doesn't begin/end with the right quotation mark.");for(let r=1;r=e.length-1)throw new a("Unexpected internal error: Unescaped backslash at the end of string literal.");if("\\"===e[r])n+="\\";else{if(e[r]!==t)throw new a(`Unexpected internal error: Invalid escaped character in string literal: ${e[r]}`);n+=t}}else{if(e[r]===t)throw new a("Unexpected internal error: String literal contains unescaped quotation mark.");n+=e[r]}return n},reduceRelation(t){const e=[],n=[];let r=d([t[0]]).join(""),s=0;for(let i=1;i2)throw new TypeError("Too many arguments.");e="object"==typeof e?e:{};const o=["extraFunctions","constants","customProp","operators"];let{extraFunctions:a,constants:c,customProp:u,operators:g}=e;for(const t of Object.keys(e))if(!o.includes(t))throw new i(t);let b={abs:Math.abs,ceil:Math.ceil,floor:Math.floor,log:Math.log,log2:Math.log2,log10:Math.log10,max:Math.max,min:Math.min,round:Math.round,sqrt:Math.sqrt,exists:t=>null!=t,empty:t=>null==t||""===t||Array.isArray(t)&&0===t.length};if(a)for(const t of Object.keys(a))b[t]=a[t];let x={"+":(t,e)=>p(t)+p(e),"-":(t,e)=>void 0===e?-y(t):y(t)-y(e),"*":(t,e)=>y(t)*y(e),"/":(t,e)=>y(t)/y(e),"^":(t,e)=>Math.pow(y(t),y(e)),mod:(t,e)=>h(y(t),y(e)),"==":(t,e)=>t===e,"!=":(t,e)=>t!==e,"<":(t,e)=>y(t)y(t)<=y(e),">=":(t,e)=>y(t)>=y(e),">":(t,e)=>y(t)>y(e),"~=":(t,e)=>RegExp(f(e)).test(f(t))};if(g)for(const t of Object.keys(g))x[t]=g[t];g=x,c=c??{};let _=d(n.parse(t));function w(t,e){if(l(e??{},t))return e[t];throw new s(t)}function k(t){return function(e){if(l(t??{},e))return t[e];throw new s(e)}}function $(t){return function({name:e},...n){if(l(t,e)&&"function"==typeof t[e])return t[e](...n);throw new r(e)}}function v({name:t,type:e},n){return"unescaped"===e&&l(c,t)?c[t]:w(t,n)}_.unshift("return "),_.push(";"),"function"==typeof u&&(w=(t,e)=>u(t,k(e),e));let S=new Function("call","ops","std","prop","data",_.join(""));return function(t){try{return S($(b),g,m,v,t)}catch(t){return t}}},Object.defineProperty(t,"__esModule",{value:!0}),t}({}); \ No newline at end of file diff --git a/dist/cjs/filtrex.js b/dist/cjs/filtrex.js index a045035..72c75fb 100644 --- a/dist/cjs/filtrex.js +++ b/dist/cjs/filtrex.js @@ -16,8 +16,8 @@ var _parser = (function() { "+": 7, "*": 8, "/": 9, - "%": 10, - "^": 11, + "^": 10, + "mod": 11, "and": 12, "or": 13, "not": 14, @@ -35,14 +35,17 @@ var _parser = (function() { "String": 26, "of": 27, "Relation": 28, - "RelationalOperator": 29, - "==": 30, - "!=": 31, - "~=": 32, - "<": 33, - "<=": 34, - ">=": 35, - ">": 36, + "%": 29, + "?": 30, + ":": 31, + "RelationalOperator": 32, + "==": 33, + "!=": 34, + "~=": 35, + "<": 36, + "<=": 37, + ">=": 38, + ">": 39, "$accept": 0, "$end": 1 }, @@ -53,8 +56,8 @@ var _parser = (function() { 7: "+", 8: "*", 9: "/", - 10: "%", - 11: "^", + 10: "^", + 11: "mod", 12: "and", 13: "or", 14: "not", @@ -70,13 +73,16 @@ var _parser = (function() { 25: "Symbol", 26: "String", 27: "of", - 30: "==", - 31: "!=", - 32: "~=", - 33: "<", - 34: "<=", - 35: ">=", - 36: ">" + 29: "%", + 30: "?", + 31: ":", + 33: "==", + 34: "!=", + 35: "~=", + 36: "<", + 37: "<=", + 38: ">=", + 39: ">" }, productions_: [0, [3, 2], [4, 2], @@ -101,13 +107,15 @@ var _parser = (function() { [4, 3], [4, 4], [4, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], + [4, 3], + [4, 5], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], [28, 3], [28, 3], [22, 1], @@ -138,7 +146,7 @@ var _parser = (function() { this.$ = ["(", "ops['", $$[$0 - 1], "'](", $$[$0 - 2], ", ", $$[$0], ")", ")"]; break; case 8: - this.$ = ["(", "ops['", $$[$0 - 1], "'](", $$[$0 - 2], ", ", $$[$0], ")", ")"]; + this.$ = ["(", "ops.mod(", $$[$0 - 2], ", ", $$[$0], ")", ")"]; break; case 9: this.$ = ["(", "", "std.coerceBoolean", "(", $$[$0 - 2], ") && ", "std.coerceBoolean", "(", $$[$0], ")", ")"]; @@ -186,36 +194,42 @@ var _parser = (function() { this.$ = yy.reduceRelation($$[$0]); break; case 24: - this.$ = ["=="]; + this.$ = ["std.warnDeprecated('modulo', ops['mod'](", $$[$0 - 2], ", ", $$[$0], "))"]; break; case 25: - this.$ = ["!="]; + this.$ = ["std.warnDeprecated('ternary', ", "std.coerceBoolean", "(", $$[$0 - 4], ") ? ", $$[$0 - 2], " : ", $$[$0], ")"]; break; case 26: - this.$ = ["~="]; + this.$ = ["=="]; break; case 27: - this.$ = ["<"]; + this.$ = ["!="]; break; case 28: - this.$ = ["<="]; + this.$ = ["~="]; break; case 29: - this.$ = [">="]; + this.$ = ["<"]; break; case 30: - this.$ = [">"]; + this.$ = ["<="]; break; case 31: - this.$ = [$$[$0 - 2], $$[$0 - 1], ...$$[$0]]; + this.$ = [">="]; break; case 32: - this.$ = [$$[$0 - 2], $$[$0 - 1], $$[$0]]; + this.$ = [">"]; break; case 33: - this.$ = ["", $$[$0], ""]; + this.$ = [$$[$0 - 2], $$[$0 - 1], ...$$[$0]]; break; case 34: + this.$ = [$$[$0 - 2], $$[$0 - 1], $$[$0]]; + break; + case 35: + this.$ = ["", $$[$0], ""]; + break; + case 36: this.$ = ["", $$[$0 - 2], ", ", $$[$0], ""]; break; } @@ -245,16 +259,18 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] - }, { - 4: 30, + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 32, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -264,7 +280,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 31, + 4: 33, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -274,7 +290,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 32, + 4: 34, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -284,12 +300,12 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 33, + 4: 35, 6: [1, 3], 14: [1, 4], 15: [1, 5], 20: [1, 6], - 22: 34, + 22: 36, 24: [1, 7], 25: [1, 8], 26: [1, 9], @@ -310,13 +326,16 @@ var _parser = (function() { 19: [2, 17], 21: [2, 17], 23: [2, 17], + 29: [2, 17], 30: [2, 17], 31: [2, 17], - 32: [2, 17], 33: [2, 17], 34: [2, 17], 35: [2, 17], - 36: [2, 17] + 36: [2, 17], + 37: [2, 17], + 38: [2, 17], + 39: [2, 17] }, { 5: [2, 18], 6: [2, 18], @@ -331,17 +350,20 @@ var _parser = (function() { 17: [2, 18], 18: [2, 18], 19: [2, 18], - 20: [1, 36], + 20: [1, 38], 21: [2, 18], 23: [2, 18], - 27: [1, 35], + 27: [1, 37], + 29: [2, 18], 30: [2, 18], 31: [2, 18], - 32: [2, 18], 33: [2, 18], 34: [2, 18], 35: [2, 18], - 36: [2, 18] + 36: [2, 18], + 37: [2, 18], + 38: [2, 18], + 39: [2, 18] }, { 5: [2, 19], 6: [2, 19], @@ -358,13 +380,16 @@ var _parser = (function() { 19: [2, 19], 21: [2, 19], 23: [2, 19], + 29: [2, 19], 30: [2, 19], 31: [2, 19], - 32: [2, 19], 33: [2, 19], 34: [2, 19], 35: [2, 19], - 36: [2, 19] + 36: [2, 19], + 37: [2, 19], + 38: [2, 19], + 39: [2, 19] }, { 5: [2, 23], 6: [2, 23], @@ -381,17 +406,20 @@ var _parser = (function() { 19: [2, 23], 21: [2, 23], 23: [2, 23], + 29: [2, 23], 30: [2, 23], 31: [2, 23], - 32: [2, 23], 33: [2, 23], 34: [2, 23], 35: [2, 23], - 36: [2, 23] + 36: [2, 23], + 37: [2, 23], + 38: [2, 23], + 39: [2, 23] }, { 1: [2, 1] }, { - 4: 37, + 4: 39, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -401,7 +429,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 38, + 4: 40, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -411,7 +439,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 39, + 4: 41, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -421,7 +449,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 40, + 4: 42, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -431,7 +459,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 41, + 4: 43, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -441,7 +469,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 42, + 4: 44, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -451,7 +479,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 43, + 4: 45, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -461,7 +489,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 44, + 4: 46, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -471,7 +499,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 45, + 4: 47, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -481,7 +509,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 46, + 4: 48, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -491,7 +519,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 48, + 4: 49, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -499,23 +527,27 @@ var _parser = (function() { 24: [1, 7], 25: [1, 8], 26: [1, 9], - 28: 47 + 28: 10 }, { - 6: [2, 24], - 14: [2, 24], - 15: [2, 24], - 20: [2, 24], - 24: [2, 24], - 25: [2, 24], - 26: [2, 24] - }, { - 6: [2, 25], - 14: [2, 25], - 15: [2, 25], - 20: [2, 25], - 24: [2, 25], - 25: [2, 25], - 26: [2, 25] + 4: 50, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 10 + }, { + 4: 52, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 51 }, { 6: [2, 26], 14: [2, 26], @@ -556,14 +588,30 @@ var _parser = (function() { 24: [2, 30], 25: [2, 30], 26: [2, 30] + }, { + 6: [2, 31], + 14: [2, 31], + 15: [2, 31], + 20: [2, 31], + 24: [2, 31], + 25: [2, 31], + 26: [2, 31] + }, { + 6: [2, 32], + 14: [2, 32], + 15: [2, 32], + 20: [2, 32], + 24: [2, 32], + 25: [2, 32], + 26: [2, 32] }, { 5: [2, 2], 6: [2, 2], 7: [2, 2], 8: [2, 2], 9: [2, 2], - 10: [2, 2], - 11: [1, 17], + 10: [1, 16], + 11: [2, 2], 12: [2, 2], 13: [2, 2], 16: [2, 2], @@ -572,22 +620,25 @@ var _parser = (function() { 19: [2, 2], 21: [2, 2], 23: [2, 2], - 29: 22, + 29: [2, 2], 30: [2, 2], 31: [2, 2], - 32: [2, 2], + 32: 24, 33: [2, 2], 34: [2, 2], 35: [2, 2], - 36: [2, 2] + 36: [2, 2], + 37: [2, 2], + 38: [2, 2], + 39: [2, 2] }, { 5: [2, 11], 6: [2, 11], 7: [2, 11], 8: [2, 11], 9: [2, 11], - 10: [2, 11], - 11: [1, 17], + 10: [1, 16], + 11: [2, 11], 12: [2, 11], 13: [2, 11], 16: [2, 11], @@ -596,14 +647,17 @@ var _parser = (function() { 19: [2, 11], 21: [2, 11], 23: [2, 11], - 29: 22, + 29: [2, 11], 30: [2, 11], 31: [2, 11], - 32: [2, 11], + 32: 24, 33: [2, 11], 34: [2, 11], 35: [2, 11], - 36: [2, 11] + 36: [2, 11], + 37: [2, 11], + 38: [2, 11], + 39: [2, 11] }, { 6: [1, 13], 7: [1, 12], @@ -613,17 +667,19 @@ var _parser = (function() { 11: [1, 17], 12: [1, 18], 13: [1, 19], - 16: [1, 49], + 16: [1, 53], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 6: [1, 13], 7: [1, 12], @@ -635,20 +691,22 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [1, 50], - 23: [2, 33], - 29: 22, + 21: [1, 54], + 23: [2, 35], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { - 23: [1, 51] + 23: [1, 55] }, { - 4: 52, + 4: 56, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -658,13 +716,13 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 55, + 4: 59, 6: [1, 3], 14: [1, 4], 15: [1, 5], 20: [1, 6], - 21: [1, 53], - 22: 54, + 21: [1, 57], + 22: 58, 24: [1, 7], 25: [1, 8], 26: [1, 9], @@ -685,14 +743,17 @@ var _parser = (function() { 19: [2, 3], 21: [2, 3], 23: [2, 3], - 29: 22, + 29: [1, 22], 30: [2, 3], 31: [2, 3], - 32: [2, 3], + 32: 24, 33: [2, 3], 34: [2, 3], 35: [2, 3], - 36: [2, 3] + 36: [2, 3], + 37: [2, 3], + 38: [2, 3], + 39: [2, 3] }, { 5: [2, 4], 6: [2, 4], @@ -709,22 +770,25 @@ var _parser = (function() { 19: [2, 4], 21: [2, 4], 23: [2, 4], - 29: 22, + 29: [1, 22], 30: [2, 4], 31: [2, 4], - 32: [2, 4], + 32: 24, 33: [2, 4], 34: [2, 4], 35: [2, 4], - 36: [2, 4] + 36: [2, 4], + 37: [2, 4], + 38: [2, 4], + 39: [2, 4] }, { 5: [2, 5], 6: [2, 5], 7: [2, 5], 8: [2, 5], 9: [2, 5], - 10: [2, 5], - 11: [1, 17], + 10: [1, 16], + 11: [2, 5], 12: [2, 5], 13: [2, 5], 16: [2, 5], @@ -733,22 +797,25 @@ var _parser = (function() { 19: [2, 5], 21: [2, 5], 23: [2, 5], - 29: 22, + 29: [2, 5], 30: [2, 5], 31: [2, 5], - 32: [2, 5], + 32: 24, 33: [2, 5], 34: [2, 5], 35: [2, 5], - 36: [2, 5] + 36: [2, 5], + 37: [2, 5], + 38: [2, 5], + 39: [2, 5] }, { 5: [2, 6], 6: [2, 6], 7: [2, 6], 8: [2, 6], 9: [2, 6], - 10: [2, 6], - 11: [1, 17], + 10: [1, 16], + 11: [2, 6], 12: [2, 6], 13: [2, 6], 16: [2, 6], @@ -757,22 +824,25 @@ var _parser = (function() { 19: [2, 6], 21: [2, 6], 23: [2, 6], - 29: 22, + 29: [2, 6], 30: [2, 6], 31: [2, 6], - 32: [2, 6], + 32: 24, 33: [2, 6], 34: [2, 6], 35: [2, 6], - 36: [2, 6] + 36: [2, 6], + 37: [2, 6], + 38: [2, 6], + 39: [2, 6] }, { 5: [2, 7], 6: [2, 7], 7: [2, 7], 8: [2, 7], 9: [2, 7], - 10: [2, 7], - 11: [1, 17], + 10: [1, 16], + 11: [2, 7], 12: [2, 7], 13: [2, 7], 16: [2, 7], @@ -781,22 +851,25 @@ var _parser = (function() { 19: [2, 7], 21: [2, 7], 23: [2, 7], - 29: 22, + 29: [2, 7], 30: [2, 7], 31: [2, 7], - 32: [2, 7], + 32: 24, 33: [2, 7], 34: [2, 7], 35: [2, 7], - 36: [2, 7] + 36: [2, 7], + 37: [2, 7], + 38: [2, 7], + 39: [2, 7] }, { 5: [2, 8], 6: [2, 8], 7: [2, 8], 8: [2, 8], 9: [2, 8], - 10: [2, 8], - 11: [1, 17], + 10: [1, 16], + 11: [2, 8], 12: [2, 8], 13: [2, 8], 16: [2, 8], @@ -805,14 +878,17 @@ var _parser = (function() { 19: [2, 8], 21: [2, 8], 23: [2, 8], - 29: 22, + 29: [2, 8], 30: [2, 8], 31: [2, 8], - 32: [2, 8], + 32: 24, 33: [2, 8], 34: [2, 8], 35: [2, 8], - 36: [2, 8] + 36: [2, 8], + 37: [2, 8], + 38: [2, 8], + 39: [2, 8] }, { 5: [2, 9], 6: [1, 13], @@ -829,14 +905,17 @@ var _parser = (function() { 19: [1, 21], 21: [2, 9], 23: [2, 9], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 9], + 31: [2, 9], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 10], 6: [1, 13], @@ -853,14 +932,17 @@ var _parser = (function() { 19: [1, 21], 21: [2, 10], 23: [2, 10], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 10], + 31: [2, 10], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 13], 6: [1, 13], @@ -877,14 +959,17 @@ var _parser = (function() { 19: [2, 13], 21: [2, 13], 23: [2, 13], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 13], + 31: [2, 13], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 14], 6: [1, 13], @@ -901,63 +986,121 @@ var _parser = (function() { 19: [2, 14], 21: [2, 14], 23: [2, 14], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] - }, { - 5: [2, 31], - 6: [2, 31], - 7: [2, 31], - 8: [2, 31], - 9: [2, 31], - 10: [2, 31], - 11: [2, 31], - 12: [2, 31], - 13: [2, 31], - 16: [2, 31], - 17: [2, 31], - 18: [2, 31], - 19: [2, 31], - 21: [2, 31], - 23: [2, 31], - 30: [2, 31], - 31: [2, 31], - 32: [2, 31], - 33: [2, 31], - 34: [2, 31], - 35: [2, 31], - 36: [2, 31] - }, { - 5: [2, 32], + 29: [1, 22], + 30: [2, 14], + 31: [2, 14], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 5: [2, 24], + 6: [2, 24], + 7: [2, 24], + 8: [2, 24], + 9: [2, 24], + 10: [1, 16], + 11: [2, 24], + 12: [2, 24], + 13: [2, 24], + 16: [2, 24], + 17: [2, 24], + 18: [2, 24], + 19: [2, 24], + 21: [2, 24], + 23: [2, 24], + 29: [2, 24], + 30: [2, 24], + 31: [2, 24], + 32: 24, + 33: [2, 24], + 34: [2, 24], + 35: [2, 24], + 36: [2, 24], + 37: [2, 24], + 38: [2, 24], + 39: [2, 24] + }, { 6: [1, 13], 7: [1, 12], 8: [1, 14], 9: [1, 15], 10: [1, 16], 11: [1, 17], - 12: [2, 32], - 13: [2, 32], - 16: [2, 32], - 17: [2, 32], - 18: [2, 32], - 19: [2, 32], - 21: [2, 32], - 23: [2, 32], - 29: 22, + 12: [1, 18], + 13: [1, 19], + 18: [1, 20], + 19: [1, 21], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 31: [1, 60], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { - 4: 56, + 5: [2, 33], + 6: [2, 33], + 7: [2, 33], + 8: [2, 33], + 9: [2, 33], + 10: [2, 33], + 11: [2, 33], + 12: [2, 33], + 13: [2, 33], + 16: [2, 33], + 17: [2, 33], + 18: [2, 33], + 19: [2, 33], + 21: [2, 33], + 23: [2, 33], + 29: [2, 33], + 30: [2, 33], + 31: [2, 33], + 33: [2, 33], + 34: [2, 33], + 35: [2, 33], + 36: [2, 33], + 37: [2, 33], + 38: [2, 33], + 39: [2, 33] + }, { + 5: [2, 34], + 6: [1, 13], + 7: [1, 12], + 8: [1, 14], + 9: [1, 15], + 10: [1, 16], + 11: [1, 17], + 12: [2, 34], + 13: [2, 34], + 16: [2, 34], + 17: [2, 34], + 18: [2, 34], + 19: [2, 34], + 21: [2, 34], + 23: [2, 34], + 29: [1, 22], + 30: [2, 34], + 31: [2, 34], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 61, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -982,15 +1125,18 @@ var _parser = (function() { 19: [2, 15], 21: [2, 15], 23: [2, 15], + 29: [2, 15], 30: [2, 15], 31: [2, 15], - 32: [2, 15], 33: [2, 15], 34: [2, 15], 35: [2, 15], - 36: [2, 15] + 36: [2, 15], + 37: [2, 15], + 38: [2, 15], + 39: [2, 15] }, { - 4: 57, + 4: 62, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1015,14 +1161,17 @@ var _parser = (function() { 19: [2, 20], 21: [2, 20], 23: [2, 20], - 29: 22, + 29: [2, 20], 30: [2, 20], 31: [2, 20], - 32: [2, 20], + 32: 24, 33: [2, 20], 34: [2, 20], 35: [2, 20], - 36: [2, 20] + 36: [2, 20], + 37: [2, 20], + 38: [2, 20], + 39: [2, 20] }, { 5: [2, 21], 6: [2, 21], @@ -1039,16 +1188,19 @@ var _parser = (function() { 19: [2, 21], 21: [2, 21], 23: [2, 21], + 29: [2, 21], 30: [2, 21], 31: [2, 21], - 32: [2, 21], 33: [2, 21], 34: [2, 21], 35: [2, 21], - 36: [2, 21] + 36: [2, 21], + 37: [2, 21], + 38: [2, 21], + 39: [2, 21] }, { - 21: [1, 58], - 23: [1, 59] + 21: [1, 63], + 23: [1, 64] }, { 6: [1, 13], 7: [1, 12], @@ -1060,16 +1212,28 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [2, 33], - 23: [2, 33], - 29: 22, + 21: [2, 35], + 23: [2, 35], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 65, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 10 }, { 6: [1, 13], 7: [1, 12], @@ -1079,17 +1243,19 @@ var _parser = (function() { 11: [1, 17], 12: [1, 18], 13: [1, 19], - 17: [1, 60], + 17: [1, 66], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 6: [1, 13], 7: [1, 12], @@ -1101,16 +1267,18 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [1, 61], - 23: [2, 34], - 29: 22, + 21: [1, 67], + 23: [2, 36], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 22], 6: [2, 22], @@ -1127,15 +1295,18 @@ var _parser = (function() { 19: [2, 22], 21: [2, 22], 23: [2, 22], + 29: [2, 22], 30: [2, 22], 31: [2, 22], - 32: [2, 22], 33: [2, 22], 34: [2, 22], 35: [2, 22], - 36: [2, 22] + 36: [2, 22], + 37: [2, 22], + 38: [2, 22], + 39: [2, 22] }, { - 4: 62, + 4: 68, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1145,7 +1316,34 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 63, + 5: [2, 25], + 6: [1, 13], + 7: [1, 12], + 8: [1, 14], + 9: [1, 15], + 10: [1, 16], + 11: [1, 17], + 12: [1, 18], + 13: [1, 19], + 16: [2, 25], + 17: [2, 25], + 18: [1, 20], + 19: [1, 21], + 21: [2, 25], + 23: [2, 25], + 29: [1, 22], + 30: [1, 23], + 31: [2, 25], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 69, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1170,13 +1368,16 @@ var _parser = (function() { 19: [2, 16], 21: [2, 16], 23: [2, 16], + 29: [2, 16], 30: [2, 16], 31: [2, 16], - 32: [2, 16], 33: [2, 16], 34: [2, 16], 35: [2, 16], - 36: [2, 16] + 36: [2, 16], + 37: [2, 16], + 38: [2, 16], + 39: [2, 16] }, { 6: [1, 13], 7: [1, 12], @@ -1188,16 +1389,18 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [2, 34], - 23: [2, 34], - 29: 22, + 21: [2, 36], + 23: [2, 36], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 12], 6: [1, 13], @@ -1214,14 +1417,17 @@ var _parser = (function() { 19: [1, 21], 21: [2, 12], 23: [2, 12], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 31: [2, 12], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }], defaultActions: { 11: [2, 1] @@ -1619,45 +1825,45 @@ var _parser = (function() { case 4: return "^"; case 5: - return "%"; - case 6: return "("; - case 7: + case 6: return ")"; - case 8: + case 7: return ","; - case 9: + case 8: return "=="; - case 10: + case 9: return "!="; - case 11: + case 10: return "~="; - case 12: + case 11: return ">="; - case 13: + case 12: return "<="; - case 14: + case 13: return "<"; - case 15: + case 14: return ">"; - case 16: + case 15: return "notIn"; - case 17: + case 16: return "and"; - case 18: + case 17: return "or"; - case 19: + case 18: return "not"; - case 20: + case 19: return "in"; - case 21: + case 20: return "of"; - case 22: + case 21: return "if"; - case 23: + case 22: return "then"; - case 24: + case 23: return "else"; + case 24: + return "mod"; case 25: break; case 26: @@ -1678,13 +1884,19 @@ var _parser = (function() { yy_.yytext = JSON.stringify(yy.buildString('"', yy_.yytext)); return "String"; case 30: + return "%"; + case 31: + return "?"; + case 32: + return ":"; + case 33: return "EOF"; } }; - lexer.rules = [/^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\%)/, /^(?:\()/, /^(?:\))/, /^(?:\,)/, /^(?:==)/, /^(?:\!=)/, /^(?:\~=)/, /^(?:>=)/, /^(?:<=)/, /^(?:<)/, /^(?:>)/, /^(?:not\s+in[^\w])/, /^(?:and[^\w])/, /^(?:or[^\w])/, /^(?:not[^\w])/, /^(?:in[^\w])/, /^(?:of[^\w])/, /^(?:if[^\w])/, /^(?:then[^\w])/, /^(?:else[^\w])/, /^(?:\s+)/, /^(?:[0-9]+(?:\.[0-9]+)?(?![0-9\.]))/, /^(?:[a-zA-Z$_][\.a-zA-Z0-9$_]*)/, /^(?:'(?:\\'|\\\\|[^'\\])*')/, /^(?:"(?:\\"|\\\\|[^"\\])*")/, /^(?:$)/]; + lexer.rules = [/^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\()/, /^(?:\))/, /^(?:\,)/, /^(?:==)/, /^(?:\!=)/, /^(?:\~=)/, /^(?:>=)/, /^(?:<=)/, /^(?:<)/, /^(?:>)/, /^(?:not\s+in[^\w])/, /^(?:and[^\w])/, /^(?:or[^\w])/, /^(?:not[^\w])/, /^(?:in[^\w])/, /^(?:of[^\w])/, /^(?:if[^\w])/, /^(?:then[^\w])/, /^(?:else[^\w])/, /^(?:mod[^\w])/, /^(?:\s+)/, /^(?:[0-9]+(?:\.[0-9]+)?(?![0-9\.]))/, /^(?:[a-zA-Z$_][\.a-zA-Z0-9$_]*)/, /^(?:'(?:\\'|\\\\|[^'\\])*')/, /^(?:"(?:\\"|\\\\|[^"\\])*")/, /^(?:\%)/, /^(?:\?)/, /^(?::)/, /^(?:$)/]; lexer.conditions = { "INITIAL": { - "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], + "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], "inclusive": true } }; @@ -1958,6 +2170,40 @@ const std = return A.every( val => B.includes(val) ) }, + warnDeprecated: (function () { + const warnMax = 3; + + let warnedTimes = { + ternary: 0, + modulo: 0 + }; + + return (cause, value) => { + switch (cause) { + case 'ternary': + if (warnedTimes.ternary++ >= warnMax) break + console.warn( + "The use of ? and : as conditional operators has been deprecated " + + "in Filtrex v3 in favor of the if..then..else ternary operator. " + + "See issue #34 for more information." + ); + break + + case 'modulo': + if (warnedTimes.modulo++ >= warnMax) break + console.warn( + "The use of '%' as a modulo operator has been deprecated in Filtrex v3 " + + "in favor of the 'mod' operator. You can use it like this: '3 mod 2 == 1'. " + + "See issue #48 for more information." + ); + break + } + + return value + } + + })(), + buildString(quote, literal) { quote = String(quote)[0]; @@ -2042,8 +2288,8 @@ parser.yy = Object.create(std); * * `x - y` Subtract * * `x * y` Multiply * * `x / y` Divide - * * `x % y` Modulo * * `x ^ y` Power + * * `x mod y` Modulo * * `x == y` Equals * * `x < y` Less than * * `x <= y` Less than or equal to @@ -2114,8 +2360,8 @@ function compileExpression(expression, options) { '*': (a, b) => num(a) * num(b), '/': (a, b) => num(a) / num(b), - '%': (a, b) => mod(num(a), num(b)), '^': (a, b) => Math.pow(num(a), num(b)), + 'mod': (a, b) => mod(num(a), num(b)), '==': (a, b) => a === b, '!=': (a, b) => a !== b, diff --git a/dist/esm/filtrex.d.ts b/dist/esm/filtrex.d.ts index d88bda4..11f42db 100644 --- a/dist/esm/filtrex.d.ts +++ b/dist/esm/filtrex.d.ts @@ -23,8 +23,8 @@ * * `x - y` Subtract * * `x * y` Multiply * * `x / y` Divide - * * `x % y` Modulo * * `x ^ y` Power + * * `x mod y` Modulo * * `x == y` Equals * * `x < y` Less than * * `x <= y` Less than or equal to @@ -37,7 +37,7 @@ * * `x or y` Boolean or * * `x and y` Boolean and * * `not x` Boolean not - * * `if x then y else z` If boolean x, value y, else z + * * `if x then y else z` If boolean x is true, return value y, else return z * * `( x )` Explicity operator precedence * * `( x, y, z )` Array of elements x, y and z * * `abs(x)` Absolute value diff --git a/dist/esm/filtrex.mjs b/dist/esm/filtrex.mjs index d8bf9e1..848e208 100644 --- a/dist/esm/filtrex.mjs +++ b/dist/esm/filtrex.mjs @@ -26,6 +26,40 @@ const std = return A.every( val => B.includes(val) ) }, + warnDeprecated: (function () { + const warnMax = 3 + + let warnedTimes = { + ternary: 0, + modulo: 0 + } + + return (cause, value) => { + switch (cause) { + case 'ternary': + if (warnedTimes.ternary++ >= warnMax) break + console.warn( + "The use of ? and : as conditional operators has been deprecated " + + "in Filtrex v3 in favor of the if..then..else ternary operator. " + + "See issue #34 for more information." + ) + break + + case 'modulo': + if (warnedTimes.modulo++ >= warnMax) break + console.warn( + "The use of '%' as a modulo operator has been deprecated in Filtrex v3 " + + "in favor of the 'mod' operator. You can use it like this: '3 mod 2 == 1'. " + + "See issue #48 for more information." + ) + break + } + + return value + } + + })(), + buildString(quote, literal) { quote = String(quote)[0] @@ -110,8 +144,8 @@ parser.yy = Object.create(std) * * `x - y` Subtract * * `x * y` Multiply * * `x / y` Divide - * * `x % y` Modulo * * `x ^ y` Power + * * `x mod y` Modulo * * `x == y` Equals * * `x < y` Less than * * `x <= y` Less than or equal to @@ -182,8 +216,8 @@ export function compileExpression(expression, options) { '*': (a, b) => num(a) * num(b), '/': (a, b) => num(a) / num(b), - '%': (a, b) => mod(num(a), num(b)), '^': (a, b) => Math.pow(num(a), num(b)), + 'mod': (a, b) => mod(num(a), num(b)), '==': (a, b) => a === b, '!=': (a, b) => a !== b, diff --git a/dist/esm/generateParser.mjs b/dist/esm/generateParser.mjs index 0c0bccb..6ca210a 100644 --- a/dist/esm/generateParser.mjs +++ b/dist/esm/generateParser.mjs @@ -15,7 +15,6 @@ const grammar = { [_`-` , `return "-" ;`], [_`\+`, `return "+" ;`], [_`\^`, `return "^" ;`], - [_`\%`, `return "%" ;`], [_`\(`, `return "(" ;`], [_`\)`, `return ")" ;`], [_`\,`, `return "," ;`], @@ -35,6 +34,7 @@ const grammar = { [_`if[^\w]` , `return "if" ;`], [_`then[^\w]`, `return "then";`], [_`else[^\w]`, `return "else";`], + [_`mod[^\w]` , `return "mod" ;`], [_`\s+`, ''], // skip whitespace [_`[0-9]+(?:\.[0-9]+)?(?![0-9\.])`, `return "Number";`], // 212.321 @@ -60,6 +60,13 @@ const grammar = { return "String";` ], // "any \"escaped\" string" + + // Deprecated syntax + [_`\%`, `return "%" ;`], + [_`\?`, `return "?" ;`], + [_`:`, `return ":" ;`], + + // End [_`$`, 'return "EOF";'], ] @@ -70,7 +77,7 @@ const grammar = { // Different languages have different rules, but this seems a good starting // point: http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages operators: [ - ['left', 'if', 'then', 'else'], + ['right', 'if', 'then', 'else', /* deprecated: */ '?', ':'], ['left', 'or'], ['left', 'and'], ['left', 'in', 'notIn'], @@ -78,7 +85,7 @@ const grammar = { ['left', '==', '!=', '<', '<=', '>', '>=', '~='], ['left', 'CHAINEDREL'], ['left', '+', '-'], - ['left', '*', '/', '%'], + ['left', '*', '/', 'mod', /* deprecated: */ '%'], ['left', 'not', 'UMINUS'], ['right', '^'], ['left', 'of'], @@ -94,8 +101,8 @@ const grammar = { ['e - e' , operatorCode], ['e * e' , operatorCode], ['e / e' , operatorCode], - ['e % e' , operatorCode], ['e ^ e' , operatorCode], + ['e mod e', code`ops.mod(${1}, ${3})`], ['e and e', code`${bool}(${1}) && ${bool}(${3})`], ['e or e' , code`${bool}(${1}) || ${bool}(${3})`], @@ -117,6 +124,11 @@ const grammar = { ['Symbol ( Arguments )', parenless`call(${1}, ${3})`], ['Relation' , `$$ = yy.reduceRelation($1);`, {prec: '=='}], + + // Deprecated + ['e % e' , parenless`std.warnDeprecated('modulo', ops['mod'](${1}, ${3}))`], + ['e ? e : e', parenless`std.warnDeprecated('ternary', ${bool}(${1}) ? ${3} : ${5})`], + ], RelationalOperator: [ noop`==`, noop`!=`, noop`~=`, noop`<`, diff --git a/dist/esm/parser.mjs b/dist/esm/parser.mjs index 2667416..ab7b6f3 100644 --- a/dist/esm/parser.mjs +++ b/dist/esm/parser.mjs @@ -12,8 +12,8 @@ var _parser = (function() { "+": 7, "*": 8, "/": 9, - "%": 10, - "^": 11, + "^": 10, + "mod": 11, "and": 12, "or": 13, "not": 14, @@ -31,14 +31,17 @@ var _parser = (function() { "String": 26, "of": 27, "Relation": 28, - "RelationalOperator": 29, - "==": 30, - "!=": 31, - "~=": 32, - "<": 33, - "<=": 34, - ">=": 35, - ">": 36, + "%": 29, + "?": 30, + ":": 31, + "RelationalOperator": 32, + "==": 33, + "!=": 34, + "~=": 35, + "<": 36, + "<=": 37, + ">=": 38, + ">": 39, "$accept": 0, "$end": 1 }, @@ -49,8 +52,8 @@ var _parser = (function() { 7: "+", 8: "*", 9: "/", - 10: "%", - 11: "^", + 10: "^", + 11: "mod", 12: "and", 13: "or", 14: "not", @@ -66,13 +69,16 @@ var _parser = (function() { 25: "Symbol", 26: "String", 27: "of", - 30: "==", - 31: "!=", - 32: "~=", - 33: "<", - 34: "<=", - 35: ">=", - 36: ">" + 29: "%", + 30: "?", + 31: ":", + 33: "==", + 34: "!=", + 35: "~=", + 36: "<", + 37: "<=", + 38: ">=", + 39: ">" }, productions_: [0, [3, 2], [4, 2], @@ -97,13 +103,15 @@ var _parser = (function() { [4, 3], [4, 4], [4, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], - [29, 1], + [4, 3], + [4, 5], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], + [32, 1], [28, 3], [28, 3], [22, 1], @@ -135,7 +143,7 @@ var _parser = (function() { this.$ = ["(", "ops['", $$[$0 - 1], "'](", $$[$0 - 2], ", ", $$[$0], ")", ")"]; break; case 8: - this.$ = ["(", "ops['", $$[$0 - 1], "'](", $$[$0 - 2], ", ", $$[$0], ")", ")"]; + this.$ = ["(", "ops.mod(", $$[$0 - 2], ", ", $$[$0], ")", ")"]; break; case 9: this.$ = ["(", "", "std.coerceBoolean", "(", $$[$0 - 2], ") && ", "std.coerceBoolean", "(", $$[$0], ")", ")"]; @@ -183,36 +191,42 @@ var _parser = (function() { this.$ = yy.reduceRelation($$[$0]); break; case 24: - this.$ = ["=="]; + this.$ = ["std.warnDeprecated('modulo', ops['mod'](", $$[$0 - 2], ", ", $$[$0], "))"]; break; case 25: - this.$ = ["!="]; + this.$ = ["std.warnDeprecated('ternary', ", "std.coerceBoolean", "(", $$[$0 - 4], ") ? ", $$[$0 - 2], " : ", $$[$0], ")"]; break; case 26: - this.$ = ["~="]; + this.$ = ["=="]; break; case 27: - this.$ = ["<"]; + this.$ = ["!="]; break; case 28: - this.$ = ["<="]; + this.$ = ["~="]; break; case 29: - this.$ = [">="]; + this.$ = ["<"]; break; case 30: - this.$ = [">"]; + this.$ = ["<="]; break; case 31: - this.$ = [$$[$0 - 2], $$[$0 - 1], ...$$[$0]] + this.$ = [">="]; break; case 32: - this.$ = [$$[$0 - 2], $$[$0 - 1], $$[$0]]; + this.$ = [">"]; break; case 33: - this.$ = ["", $$[$0], ""]; + this.$ = [$$[$0 - 2], $$[$0 - 1], ...$$[$0]] break; case 34: + this.$ = [$$[$0 - 2], $$[$0 - 1], $$[$0]]; + break; + case 35: + this.$ = ["", $$[$0], ""]; + break; + case 36: this.$ = ["", $$[$0 - 2], ", ", $$[$0], ""]; break; } @@ -242,16 +256,18 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] - }, { - 4: 30, + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 32, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -261,7 +277,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 31, + 4: 33, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -271,7 +287,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 32, + 4: 34, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -281,12 +297,12 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 33, + 4: 35, 6: [1, 3], 14: [1, 4], 15: [1, 5], 20: [1, 6], - 22: 34, + 22: 36, 24: [1, 7], 25: [1, 8], 26: [1, 9], @@ -307,13 +323,16 @@ var _parser = (function() { 19: [2, 17], 21: [2, 17], 23: [2, 17], + 29: [2, 17], 30: [2, 17], 31: [2, 17], - 32: [2, 17], 33: [2, 17], 34: [2, 17], 35: [2, 17], - 36: [2, 17] + 36: [2, 17], + 37: [2, 17], + 38: [2, 17], + 39: [2, 17] }, { 5: [2, 18], 6: [2, 18], @@ -328,17 +347,20 @@ var _parser = (function() { 17: [2, 18], 18: [2, 18], 19: [2, 18], - 20: [1, 36], + 20: [1, 38], 21: [2, 18], 23: [2, 18], - 27: [1, 35], + 27: [1, 37], + 29: [2, 18], 30: [2, 18], 31: [2, 18], - 32: [2, 18], 33: [2, 18], 34: [2, 18], 35: [2, 18], - 36: [2, 18] + 36: [2, 18], + 37: [2, 18], + 38: [2, 18], + 39: [2, 18] }, { 5: [2, 19], 6: [2, 19], @@ -355,13 +377,16 @@ var _parser = (function() { 19: [2, 19], 21: [2, 19], 23: [2, 19], + 29: [2, 19], 30: [2, 19], 31: [2, 19], - 32: [2, 19], 33: [2, 19], 34: [2, 19], 35: [2, 19], - 36: [2, 19] + 36: [2, 19], + 37: [2, 19], + 38: [2, 19], + 39: [2, 19] }, { 5: [2, 23], 6: [2, 23], @@ -378,17 +403,20 @@ var _parser = (function() { 19: [2, 23], 21: [2, 23], 23: [2, 23], + 29: [2, 23], 30: [2, 23], 31: [2, 23], - 32: [2, 23], 33: [2, 23], 34: [2, 23], 35: [2, 23], - 36: [2, 23] + 36: [2, 23], + 37: [2, 23], + 38: [2, 23], + 39: [2, 23] }, { 1: [2, 1] }, { - 4: 37, + 4: 39, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -398,7 +426,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 38, + 4: 40, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -408,7 +436,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 39, + 4: 41, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -418,7 +446,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 40, + 4: 42, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -428,7 +456,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 41, + 4: 43, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -438,7 +466,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 42, + 4: 44, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -448,7 +476,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 43, + 4: 45, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -458,7 +486,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 44, + 4: 46, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -468,7 +496,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 45, + 4: 47, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -478,7 +506,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 46, + 4: 48, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -488,7 +516,7 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 48, + 4: 49, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -496,23 +524,27 @@ var _parser = (function() { 24: [1, 7], 25: [1, 8], 26: [1, 9], - 28: 47 + 28: 10 }, { - 6: [2, 24], - 14: [2, 24], - 15: [2, 24], - 20: [2, 24], - 24: [2, 24], - 25: [2, 24], - 26: [2, 24] - }, { - 6: [2, 25], - 14: [2, 25], - 15: [2, 25], - 20: [2, 25], - 24: [2, 25], - 25: [2, 25], - 26: [2, 25] + 4: 50, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 10 + }, { + 4: 52, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 51 }, { 6: [2, 26], 14: [2, 26], @@ -553,14 +585,30 @@ var _parser = (function() { 24: [2, 30], 25: [2, 30], 26: [2, 30] + }, { + 6: [2, 31], + 14: [2, 31], + 15: [2, 31], + 20: [2, 31], + 24: [2, 31], + 25: [2, 31], + 26: [2, 31] + }, { + 6: [2, 32], + 14: [2, 32], + 15: [2, 32], + 20: [2, 32], + 24: [2, 32], + 25: [2, 32], + 26: [2, 32] }, { 5: [2, 2], 6: [2, 2], 7: [2, 2], 8: [2, 2], 9: [2, 2], - 10: [2, 2], - 11: [1, 17], + 10: [1, 16], + 11: [2, 2], 12: [2, 2], 13: [2, 2], 16: [2, 2], @@ -569,22 +617,25 @@ var _parser = (function() { 19: [2, 2], 21: [2, 2], 23: [2, 2], - 29: 22, + 29: [2, 2], 30: [2, 2], 31: [2, 2], - 32: [2, 2], + 32: 24, 33: [2, 2], 34: [2, 2], 35: [2, 2], - 36: [2, 2] + 36: [2, 2], + 37: [2, 2], + 38: [2, 2], + 39: [2, 2] }, { 5: [2, 11], 6: [2, 11], 7: [2, 11], 8: [2, 11], 9: [2, 11], - 10: [2, 11], - 11: [1, 17], + 10: [1, 16], + 11: [2, 11], 12: [2, 11], 13: [2, 11], 16: [2, 11], @@ -593,14 +644,17 @@ var _parser = (function() { 19: [2, 11], 21: [2, 11], 23: [2, 11], - 29: 22, + 29: [2, 11], 30: [2, 11], 31: [2, 11], - 32: [2, 11], + 32: 24, 33: [2, 11], 34: [2, 11], 35: [2, 11], - 36: [2, 11] + 36: [2, 11], + 37: [2, 11], + 38: [2, 11], + 39: [2, 11] }, { 6: [1, 13], 7: [1, 12], @@ -610,17 +664,19 @@ var _parser = (function() { 11: [1, 17], 12: [1, 18], 13: [1, 19], - 16: [1, 49], + 16: [1, 53], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 6: [1, 13], 7: [1, 12], @@ -632,20 +688,22 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [1, 50], - 23: [2, 33], - 29: 22, + 21: [1, 54], + 23: [2, 35], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { - 23: [1, 51] + 23: [1, 55] }, { - 4: 52, + 4: 56, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -655,13 +713,13 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 55, + 4: 59, 6: [1, 3], 14: [1, 4], 15: [1, 5], 20: [1, 6], - 21: [1, 53], - 22: 54, + 21: [1, 57], + 22: 58, 24: [1, 7], 25: [1, 8], 26: [1, 9], @@ -682,14 +740,17 @@ var _parser = (function() { 19: [2, 3], 21: [2, 3], 23: [2, 3], - 29: 22, + 29: [1, 22], 30: [2, 3], 31: [2, 3], - 32: [2, 3], + 32: 24, 33: [2, 3], 34: [2, 3], 35: [2, 3], - 36: [2, 3] + 36: [2, 3], + 37: [2, 3], + 38: [2, 3], + 39: [2, 3] }, { 5: [2, 4], 6: [2, 4], @@ -706,22 +767,25 @@ var _parser = (function() { 19: [2, 4], 21: [2, 4], 23: [2, 4], - 29: 22, + 29: [1, 22], 30: [2, 4], 31: [2, 4], - 32: [2, 4], + 32: 24, 33: [2, 4], 34: [2, 4], 35: [2, 4], - 36: [2, 4] + 36: [2, 4], + 37: [2, 4], + 38: [2, 4], + 39: [2, 4] }, { 5: [2, 5], 6: [2, 5], 7: [2, 5], 8: [2, 5], 9: [2, 5], - 10: [2, 5], - 11: [1, 17], + 10: [1, 16], + 11: [2, 5], 12: [2, 5], 13: [2, 5], 16: [2, 5], @@ -730,22 +794,25 @@ var _parser = (function() { 19: [2, 5], 21: [2, 5], 23: [2, 5], - 29: 22, + 29: [2, 5], 30: [2, 5], 31: [2, 5], - 32: [2, 5], + 32: 24, 33: [2, 5], 34: [2, 5], 35: [2, 5], - 36: [2, 5] + 36: [2, 5], + 37: [2, 5], + 38: [2, 5], + 39: [2, 5] }, { 5: [2, 6], 6: [2, 6], 7: [2, 6], 8: [2, 6], 9: [2, 6], - 10: [2, 6], - 11: [1, 17], + 10: [1, 16], + 11: [2, 6], 12: [2, 6], 13: [2, 6], 16: [2, 6], @@ -754,22 +821,25 @@ var _parser = (function() { 19: [2, 6], 21: [2, 6], 23: [2, 6], - 29: 22, + 29: [2, 6], 30: [2, 6], 31: [2, 6], - 32: [2, 6], + 32: 24, 33: [2, 6], 34: [2, 6], 35: [2, 6], - 36: [2, 6] + 36: [2, 6], + 37: [2, 6], + 38: [2, 6], + 39: [2, 6] }, { 5: [2, 7], 6: [2, 7], 7: [2, 7], 8: [2, 7], 9: [2, 7], - 10: [2, 7], - 11: [1, 17], + 10: [1, 16], + 11: [2, 7], 12: [2, 7], 13: [2, 7], 16: [2, 7], @@ -778,22 +848,25 @@ var _parser = (function() { 19: [2, 7], 21: [2, 7], 23: [2, 7], - 29: 22, + 29: [2, 7], 30: [2, 7], 31: [2, 7], - 32: [2, 7], + 32: 24, 33: [2, 7], 34: [2, 7], 35: [2, 7], - 36: [2, 7] + 36: [2, 7], + 37: [2, 7], + 38: [2, 7], + 39: [2, 7] }, { 5: [2, 8], 6: [2, 8], 7: [2, 8], 8: [2, 8], 9: [2, 8], - 10: [2, 8], - 11: [1, 17], + 10: [1, 16], + 11: [2, 8], 12: [2, 8], 13: [2, 8], 16: [2, 8], @@ -802,14 +875,17 @@ var _parser = (function() { 19: [2, 8], 21: [2, 8], 23: [2, 8], - 29: 22, + 29: [2, 8], 30: [2, 8], 31: [2, 8], - 32: [2, 8], + 32: 24, 33: [2, 8], 34: [2, 8], 35: [2, 8], - 36: [2, 8] + 36: [2, 8], + 37: [2, 8], + 38: [2, 8], + 39: [2, 8] }, { 5: [2, 9], 6: [1, 13], @@ -826,14 +902,17 @@ var _parser = (function() { 19: [1, 21], 21: [2, 9], 23: [2, 9], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 9], + 31: [2, 9], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 10], 6: [1, 13], @@ -850,14 +929,17 @@ var _parser = (function() { 19: [1, 21], 21: [2, 10], 23: [2, 10], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 10], + 31: [2, 10], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 13], 6: [1, 13], @@ -874,14 +956,17 @@ var _parser = (function() { 19: [2, 13], 21: [2, 13], 23: [2, 13], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 29: [1, 22], + 30: [2, 13], + 31: [2, 13], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 14], 6: [1, 13], @@ -898,63 +983,121 @@ var _parser = (function() { 19: [2, 14], 21: [2, 14], 23: [2, 14], - 29: 22, - 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] - }, { - 5: [2, 31], - 6: [2, 31], - 7: [2, 31], - 8: [2, 31], - 9: [2, 31], - 10: [2, 31], - 11: [2, 31], - 12: [2, 31], - 13: [2, 31], - 16: [2, 31], - 17: [2, 31], - 18: [2, 31], - 19: [2, 31], - 21: [2, 31], - 23: [2, 31], - 30: [2, 31], - 31: [2, 31], - 32: [2, 31], - 33: [2, 31], - 34: [2, 31], - 35: [2, 31], - 36: [2, 31] - }, { - 5: [2, 32], + 29: [1, 22], + 30: [2, 14], + 31: [2, 14], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 5: [2, 24], + 6: [2, 24], + 7: [2, 24], + 8: [2, 24], + 9: [2, 24], + 10: [1, 16], + 11: [2, 24], + 12: [2, 24], + 13: [2, 24], + 16: [2, 24], + 17: [2, 24], + 18: [2, 24], + 19: [2, 24], + 21: [2, 24], + 23: [2, 24], + 29: [2, 24], + 30: [2, 24], + 31: [2, 24], + 32: 24, + 33: [2, 24], + 34: [2, 24], + 35: [2, 24], + 36: [2, 24], + 37: [2, 24], + 38: [2, 24], + 39: [2, 24] + }, { 6: [1, 13], 7: [1, 12], 8: [1, 14], 9: [1, 15], 10: [1, 16], 11: [1, 17], - 12: [2, 32], - 13: [2, 32], - 16: [2, 32], - 17: [2, 32], - 18: [2, 32], - 19: [2, 32], - 21: [2, 32], - 23: [2, 32], - 29: 22, + 12: [1, 18], + 13: [1, 19], + 18: [1, 20], + 19: [1, 21], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 31: [1, 60], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { - 4: 56, + 5: [2, 33], + 6: [2, 33], + 7: [2, 33], + 8: [2, 33], + 9: [2, 33], + 10: [2, 33], + 11: [2, 33], + 12: [2, 33], + 13: [2, 33], + 16: [2, 33], + 17: [2, 33], + 18: [2, 33], + 19: [2, 33], + 21: [2, 33], + 23: [2, 33], + 29: [2, 33], + 30: [2, 33], + 31: [2, 33], + 33: [2, 33], + 34: [2, 33], + 35: [2, 33], + 36: [2, 33], + 37: [2, 33], + 38: [2, 33], + 39: [2, 33] + }, { + 5: [2, 34], + 6: [1, 13], + 7: [1, 12], + 8: [1, 14], + 9: [1, 15], + 10: [1, 16], + 11: [1, 17], + 12: [2, 34], + 13: [2, 34], + 16: [2, 34], + 17: [2, 34], + 18: [2, 34], + 19: [2, 34], + 21: [2, 34], + 23: [2, 34], + 29: [1, 22], + 30: [2, 34], + 31: [2, 34], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 61, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -979,15 +1122,18 @@ var _parser = (function() { 19: [2, 15], 21: [2, 15], 23: [2, 15], + 29: [2, 15], 30: [2, 15], 31: [2, 15], - 32: [2, 15], 33: [2, 15], 34: [2, 15], 35: [2, 15], - 36: [2, 15] + 36: [2, 15], + 37: [2, 15], + 38: [2, 15], + 39: [2, 15] }, { - 4: 57, + 4: 62, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1012,14 +1158,17 @@ var _parser = (function() { 19: [2, 20], 21: [2, 20], 23: [2, 20], - 29: 22, + 29: [2, 20], 30: [2, 20], 31: [2, 20], - 32: [2, 20], + 32: 24, 33: [2, 20], 34: [2, 20], 35: [2, 20], - 36: [2, 20] + 36: [2, 20], + 37: [2, 20], + 38: [2, 20], + 39: [2, 20] }, { 5: [2, 21], 6: [2, 21], @@ -1036,16 +1185,19 @@ var _parser = (function() { 19: [2, 21], 21: [2, 21], 23: [2, 21], + 29: [2, 21], 30: [2, 21], 31: [2, 21], - 32: [2, 21], 33: [2, 21], 34: [2, 21], 35: [2, 21], - 36: [2, 21] + 36: [2, 21], + 37: [2, 21], + 38: [2, 21], + 39: [2, 21] }, { - 21: [1, 58], - 23: [1, 59] + 21: [1, 63], + 23: [1, 64] }, { 6: [1, 13], 7: [1, 12], @@ -1057,16 +1209,28 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [2, 33], - 23: [2, 33], - 29: 22, + 21: [2, 35], + 23: [2, 35], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 65, + 6: [1, 3], + 14: [1, 4], + 15: [1, 5], + 20: [1, 6], + 24: [1, 7], + 25: [1, 8], + 26: [1, 9], + 28: 10 }, { 6: [1, 13], 7: [1, 12], @@ -1076,17 +1240,19 @@ var _parser = (function() { 11: [1, 17], 12: [1, 18], 13: [1, 19], - 17: [1, 60], + 17: [1, 66], 18: [1, 20], 19: [1, 21], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 6: [1, 13], 7: [1, 12], @@ -1098,16 +1264,18 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [1, 61], - 23: [2, 34], - 29: 22, + 21: [1, 67], + 23: [2, 36], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 22], 6: [2, 22], @@ -1124,15 +1292,18 @@ var _parser = (function() { 19: [2, 22], 21: [2, 22], 23: [2, 22], + 29: [2, 22], 30: [2, 22], 31: [2, 22], - 32: [2, 22], 33: [2, 22], 34: [2, 22], 35: [2, 22], - 36: [2, 22] + 36: [2, 22], + 37: [2, 22], + 38: [2, 22], + 39: [2, 22] }, { - 4: 62, + 4: 68, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1142,7 +1313,34 @@ var _parser = (function() { 26: [1, 9], 28: 10 }, { - 4: 63, + 5: [2, 25], + 6: [1, 13], + 7: [1, 12], + 8: [1, 14], + 9: [1, 15], + 10: [1, 16], + 11: [1, 17], + 12: [1, 18], + 13: [1, 19], + 16: [2, 25], + 17: [2, 25], + 18: [1, 20], + 19: [1, 21], + 21: [2, 25], + 23: [2, 25], + 29: [1, 22], + 30: [1, 23], + 31: [2, 25], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] + }, { + 4: 69, 6: [1, 3], 14: [1, 4], 15: [1, 5], @@ -1167,13 +1365,16 @@ var _parser = (function() { 19: [2, 16], 21: [2, 16], 23: [2, 16], + 29: [2, 16], 30: [2, 16], 31: [2, 16], - 32: [2, 16], 33: [2, 16], 34: [2, 16], 35: [2, 16], - 36: [2, 16] + 36: [2, 16], + 37: [2, 16], + 38: [2, 16], + 39: [2, 16] }, { 6: [1, 13], 7: [1, 12], @@ -1185,16 +1386,18 @@ var _parser = (function() { 13: [1, 19], 18: [1, 20], 19: [1, 21], - 21: [2, 34], - 23: [2, 34], - 29: 22, + 21: [2, 36], + 23: [2, 36], + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }, { 5: [2, 12], 6: [1, 13], @@ -1211,14 +1414,17 @@ var _parser = (function() { 19: [1, 21], 21: [2, 12], 23: [2, 12], - 29: 22, + 29: [1, 22], 30: [1, 23], - 31: [1, 24], - 32: [1, 25], - 33: [1, 26], - 34: [1, 27], - 35: [1, 28], - 36: [1, 29] + 31: [2, 12], + 32: 24, + 33: [1, 25], + 34: [1, 26], + 35: [1, 27], + 36: [1, 28], + 37: [1, 29], + 38: [1, 30], + 39: [1, 31] }], defaultActions: { 11: [2, 1] @@ -1626,64 +1832,64 @@ var _parser = (function() { return "^"; break; case 5: - return "%"; + return "("; break; case 6: - return "("; + return ")"; break; case 7: - return ")"; + return ","; break; case 8: - return ","; + return "=="; break; case 9: - return "=="; + return "!="; break; case 10: - return "!="; + return "~="; break; case 11: - return "~="; + return ">="; break; case 12: - return ">="; + return "<="; break; case 13: - return "<="; + return "<"; break; case 14: - return "<"; + return ">"; break; case 15: - return ">"; + return "notIn"; break; case 16: - return "notIn"; + return "and"; break; case 17: - return "and"; + return "or"; break; case 18: - return "or"; + return "not"; break; case 19: - return "not"; + return "in"; break; case 20: - return "in"; + return "of"; break; case 21: - return "of"; + return "if"; break; case 22: - return "if"; + return "then"; break; case 23: - return "then"; + return "else"; break; case 24: - return "else"; + return "mod"; break; case 25: break; @@ -1709,14 +1915,23 @@ var _parser = (function() { return "String"; break; case 30: + return "%"; + break; + case 31: + return "?"; + break; + case 32: + return ":"; + break; + case 33: return "EOF"; break; } }; - lexer.rules = [/^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\%)/, /^(?:\()/, /^(?:\))/, /^(?:\,)/, /^(?:==)/, /^(?:\!=)/, /^(?:\~=)/, /^(?:>=)/, /^(?:<=)/, /^(?:<)/, /^(?:>)/, /^(?:not\s+in[^\w])/, /^(?:and[^\w])/, /^(?:or[^\w])/, /^(?:not[^\w])/, /^(?:in[^\w])/, /^(?:of[^\w])/, /^(?:if[^\w])/, /^(?:then[^\w])/, /^(?:else[^\w])/, /^(?:\s+)/, /^(?:[0-9]+(?:\.[0-9]+)?(?![0-9\.]))/, /^(?:[a-zA-Z$_][\.a-zA-Z0-9$_]*)/, /^(?:'(?:\\'|\\\\|[^'\\])*')/, /^(?:"(?:\\"|\\\\|[^"\\])*")/, /^(?:$)/]; + lexer.rules = [/^(?:\*)/, /^(?:\/)/, /^(?:-)/, /^(?:\+)/, /^(?:\^)/, /^(?:\()/, /^(?:\))/, /^(?:\,)/, /^(?:==)/, /^(?:\!=)/, /^(?:\~=)/, /^(?:>=)/, /^(?:<=)/, /^(?:<)/, /^(?:>)/, /^(?:not\s+in[^\w])/, /^(?:and[^\w])/, /^(?:or[^\w])/, /^(?:not[^\w])/, /^(?:in[^\w])/, /^(?:of[^\w])/, /^(?:if[^\w])/, /^(?:then[^\w])/, /^(?:else[^\w])/, /^(?:mod[^\w])/, /^(?:\s+)/, /^(?:[0-9]+(?:\.[0-9]+)?(?![0-9\.]))/, /^(?:[a-zA-Z$_][\.a-zA-Z0-9$_]*)/, /^(?:'(?:\\'|\\\\|[^'\\])*')/, /^(?:"(?:\\"|\\\\|[^"\\])*")/, /^(?:\%)/, /^(?:\?)/, /^(?::)/, /^(?:$)/]; lexer.conditions = { "INITIAL": { - "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], + "rules": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], "inclusive": true } }; diff --git a/package.json b/package.json index e601281..3878480 100644 --- a/package.json +++ b/package.json @@ -23,19 +23,19 @@ "debug": "./node_modules/mocha/bin/mocha test --inspect-brk" }, "devDependencies": { - "@types/chai": "^4.2.18", + "@types/chai": "^4.2.22", "@types/chai-arrays": "^2.0.0", - "@types/mocha": "^8.2.2", - "@types/node": "^15.12.2", + "@types/mocha": "^9.0.0", + "@types/node": "^16.9.4", "chai": "^4.3.4", "chai-arrays": "^2.2.0", "del": "^6.0.0", "gulp": "^4.0.2", "gulp-beautify": "^3.0.0", "gulp-rename": "^2.0.0", - "gulp-uglify-es": "^2.0.0", - "mocha": "^9.0.0", - "rollup": "^2.52.0", + "gulp-uglify-es": "^3.0.0", + "mocha": "^9.1.1", + "rollup": "^2.56.3", "vinyl": "^2.2.1" } } diff --git a/src/filtrex.d.ts b/src/filtrex.d.ts index d88bda4..11f42db 100644 --- a/src/filtrex.d.ts +++ b/src/filtrex.d.ts @@ -23,8 +23,8 @@ * * `x - y` Subtract * * `x * y` Multiply * * `x / y` Divide - * * `x % y` Modulo * * `x ^ y` Power + * * `x mod y` Modulo * * `x == y` Equals * * `x < y` Less than * * `x <= y` Less than or equal to @@ -37,7 +37,7 @@ * * `x or y` Boolean or * * `x and y` Boolean and * * `not x` Boolean not - * * `if x then y else z` If boolean x, value y, else z + * * `if x then y else z` If boolean x is true, return value y, else return z * * `( x )` Explicity operator precedence * * `( x, y, z )` Array of elements x, y and z * * `abs(x)` Absolute value diff --git a/src/filtrex.mjs b/src/filtrex.mjs index d8bf9e1..848e208 100644 --- a/src/filtrex.mjs +++ b/src/filtrex.mjs @@ -26,6 +26,40 @@ const std = return A.every( val => B.includes(val) ) }, + warnDeprecated: (function () { + const warnMax = 3 + + let warnedTimes = { + ternary: 0, + modulo: 0 + } + + return (cause, value) => { + switch (cause) { + case 'ternary': + if (warnedTimes.ternary++ >= warnMax) break + console.warn( + "The use of ? and : as conditional operators has been deprecated " + + "in Filtrex v3 in favor of the if..then..else ternary operator. " + + "See issue #34 for more information." + ) + break + + case 'modulo': + if (warnedTimes.modulo++ >= warnMax) break + console.warn( + "The use of '%' as a modulo operator has been deprecated in Filtrex v3 " + + "in favor of the 'mod' operator. You can use it like this: '3 mod 2 == 1'. " + + "See issue #48 for more information." + ) + break + } + + return value + } + + })(), + buildString(quote, literal) { quote = String(quote)[0] @@ -110,8 +144,8 @@ parser.yy = Object.create(std) * * `x - y` Subtract * * `x * y` Multiply * * `x / y` Divide - * * `x % y` Modulo * * `x ^ y` Power + * * `x mod y` Modulo * * `x == y` Equals * * `x < y` Less than * * `x <= y` Less than or equal to @@ -182,8 +216,8 @@ export function compileExpression(expression, options) { '*': (a, b) => num(a) * num(b), '/': (a, b) => num(a) / num(b), - '%': (a, b) => mod(num(a), num(b)), '^': (a, b) => Math.pow(num(a), num(b)), + 'mod': (a, b) => mod(num(a), num(b)), '==': (a, b) => a === b, '!=': (a, b) => a !== b, diff --git a/src/generateParser.mjs b/src/generateParser.mjs index 0c0bccb..6ca210a 100644 --- a/src/generateParser.mjs +++ b/src/generateParser.mjs @@ -15,7 +15,6 @@ const grammar = { [_`-` , `return "-" ;`], [_`\+`, `return "+" ;`], [_`\^`, `return "^" ;`], - [_`\%`, `return "%" ;`], [_`\(`, `return "(" ;`], [_`\)`, `return ")" ;`], [_`\,`, `return "," ;`], @@ -35,6 +34,7 @@ const grammar = { [_`if[^\w]` , `return "if" ;`], [_`then[^\w]`, `return "then";`], [_`else[^\w]`, `return "else";`], + [_`mod[^\w]` , `return "mod" ;`], [_`\s+`, ''], // skip whitespace [_`[0-9]+(?:\.[0-9]+)?(?![0-9\.])`, `return "Number";`], // 212.321 @@ -60,6 +60,13 @@ const grammar = { return "String";` ], // "any \"escaped\" string" + + // Deprecated syntax + [_`\%`, `return "%" ;`], + [_`\?`, `return "?" ;`], + [_`:`, `return ":" ;`], + + // End [_`$`, 'return "EOF";'], ] @@ -70,7 +77,7 @@ const grammar = { // Different languages have different rules, but this seems a good starting // point: http://en.wikipedia.org/wiki/Order_of_operations#Programming_languages operators: [ - ['left', 'if', 'then', 'else'], + ['right', 'if', 'then', 'else', /* deprecated: */ '?', ':'], ['left', 'or'], ['left', 'and'], ['left', 'in', 'notIn'], @@ -78,7 +85,7 @@ const grammar = { ['left', '==', '!=', '<', '<=', '>', '>=', '~='], ['left', 'CHAINEDREL'], ['left', '+', '-'], - ['left', '*', '/', '%'], + ['left', '*', '/', 'mod', /* deprecated: */ '%'], ['left', 'not', 'UMINUS'], ['right', '^'], ['left', 'of'], @@ -94,8 +101,8 @@ const grammar = { ['e - e' , operatorCode], ['e * e' , operatorCode], ['e / e' , operatorCode], - ['e % e' , operatorCode], ['e ^ e' , operatorCode], + ['e mod e', code`ops.mod(${1}, ${3})`], ['e and e', code`${bool}(${1}) && ${bool}(${3})`], ['e or e' , code`${bool}(${1}) || ${bool}(${3})`], @@ -117,6 +124,11 @@ const grammar = { ['Symbol ( Arguments )', parenless`call(${1}, ${3})`], ['Relation' , `$$ = yy.reduceRelation($1);`, {prec: '=='}], + + // Deprecated + ['e % e' , parenless`std.warnDeprecated('modulo', ops['mod'](${1}, ${3}))`], + ['e ? e : e', parenless`std.warnDeprecated('ternary', ${bool}(${1}) ? ${3} : ${5})`], + ], RelationalOperator: [ noop`==`, noop`!=`, noop`~=`, noop`<`, diff --git a/test/arithmetics.js b/test/arithmetics.js index de9f988..851b735 100644 --- a/test/arithmetics.js +++ b/test/arithmetics.js @@ -17,7 +17,7 @@ describe('Arithmetics', () => { expect( eval('(1 + 2) * 3') ).equals(9); expect( eval('((1 + 2) * 3 / 2 + 1 - 4 + 2 ^ 3) * -2') ).equals(-19); expect( eval('1.4 * 1.1') ).equals(1.54); - expect( eval('97 % 10') ).equals(7); + expect( eval('97 mod 10') ).equals(7); expect( eval('2 * 3 ^ 2') ).equals(18) }); @@ -107,10 +107,10 @@ describe('Arithmetics', () => { it('does modulo correctly', () => { - expect( eval('10 % 2') ).equals(0) - expect( eval('11 % 2') ).equals(1) - expect( eval('-1 % 2') ).equals(1) - expect( eval('-0.1 % 5') ).equals(4.9) + expect( eval('10 mod 2') ).equals(0) + expect( eval('11 mod 2') ).equals(1) + expect( eval('-1 mod 2') ).equals(1) + expect( eval('-0.1 mod 5') ).equals(4.9) }) diff --git a/test/misc.js b/test/misc.js index 0ab4286..4211c55 100644 --- a/test/misc.js +++ b/test/misc.js @@ -68,6 +68,11 @@ describe('Various other things', () => { it('ternary operator', () => { expect( eval('if 1 > 2 then 3 else 4') ).equals(4); expect( eval('if 1 < 2 then 3 else 4') ).equals(3); + + expect( eval('if 1 < 2 then if 3 < 4 then 42 else 420 else if 5 < 6 then 69 else -1/12') ).equals(42); + expect( eval('if 1 < 2 then if 3 > 4 then 42 else 420 else if 5 < 6 then 69 else -1/12') ).equals(420); + expect( eval('if 1 > 2 then if 3 < 4 then 42 else 420 else if 5 < 6 then 69 else -1/12') ).equals(69); + expect( eval('if 1 > 2 then if 3 < 4 then 42 else 420 else if 5 > 6 then 69 else -1/12') ).equals(-1/12); }); it('kitchensink', () => { @@ -185,7 +190,18 @@ describe('Various other things', () => { const expr = `'a' + a + 'b' + b` expect( compileExpression(expr, options2)(data) ).equals("a_data a_const b_data b_data ") + }) + + it('deprecated syntax still works', () => { + expect( eval('10 % 2') ).equals(0) + expect( eval('11 % 2') ).equals(1) + expect( eval('-1 % 2') ).equals(1) + expect( eval('-0.1 % 5') ).equals(4.9) + expect( eval('1 < 2 ? 3 < 4 ? 42 : 420 : 5 < 6 ? 69 : -1/12') ).equals(42); + expect( eval('1 < 2 ? 3 > 4 ? 42 : 420 : 5 < 6 ? 69 : -1/12') ).equals(420); + expect( eval('1 > 2 ? 3 < 4 ? 42 : 420 : 5 < 6 ? 69 : -1/12') ).equals(69); + expect( eval('1 > 2 ? 3 < 4 ? 42 : 420 : 5 > 6 ? 69 : -1/12') ).equals(-1/12); }) }); diff --git a/yarn.lock b/yarn.lock index cd9d8aa..249a925 100644 --- a/yarn.lock +++ b/yarn.lock @@ -30,20 +30,25 @@ dependencies: "@types/chai" "*" -"@types/chai@*", "@types/chai@^4.2.18": +"@types/chai@*": version "4.2.18" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.18.tgz#0c8e298dbff8205e2266606c1ea5fbdba29b46e4" integrity sha512-rS27+EkB/RE1Iz3u0XtVL5q36MGDWbgYe7zWiodyKNUnthxY0rukK5V36eiUCtCisB7NN8zKYH6DO2M37qxFEQ== -"@types/mocha@^8.2.2": - version "8.2.2" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0" - integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw== +"@types/chai@^4.2.22": + version "4.2.22" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.22.tgz#47020d7e4cf19194d43b5202f35f75bd2ad35ce7" + integrity sha512-tFfcE+DSTzWAgifkjik9AySNqIyNoYwmR+uecPwwD/XRNfvOjmC/FjCxpiUGDkDVDphPfCUecSQVFw+lN3M3kQ== -"@types/node@^15.12.2": - version "15.12.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.2.tgz#1f2b42c4be7156ff4a6f914b2fb03d05fa84e38d" - integrity sha512-zjQ69G564OCIWIOHSXyQEEDpdpGl+G348RAKY0XXy9Z5kU9Vzv1GMNnkar/ZJ8dzXB3COzD9Mo9NtRZ4xfgUww== +"@types/mocha@^9.0.0": + version "9.0.0" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297" + integrity sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA== + +"@types/node@^16.9.4": + version "16.9.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.9.4.tgz#a12f0ee7847cf17a97f6fdf1093cb7a9af23cca4" + integrity sha512-KDazLNYAGIuJugdbULwFZULF9qQ13yNWEBFnfVpqlpgAAo6H/qnM9RjBgh0A0kmHf3XxAKLdN5mTIng9iUvVLA== "@ungap/promise-all-settled@1.1.2": version "1.1.2" @@ -117,7 +122,7 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" -anymatch@~3.1.1: +anymatch@~3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== @@ -411,20 +416,20 @@ check-error@^1.0.2: resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= -chokidar@3.5.1: - version "3.5.1" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.1.tgz#ee9ce7bbebd2b79f49f304799d5468e31e14e68a" - integrity sha512-9+s+Od+W0VJJzawDma/gvBNQqkTiqYTWLuZoyAsivsI4AaWTCzHG06/TMjsf1cYe9Cb97UCEhjz7HvnPk2p/tw== +chokidar@3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75" + integrity sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ== dependencies: - anymatch "~3.1.1" + anymatch "~3.1.2" braces "~3.0.2" - glob-parent "~5.1.0" + glob-parent "~5.1.2" is-binary-path "~2.1.0" is-glob "~4.0.1" normalize-path "~3.0.0" - readdirp "~3.5.0" + readdirp "~3.6.0" optionalDependencies: - fsevents "~2.3.1" + fsevents "~2.3.2" chokidar@^2.0.0: version "2.1.8" @@ -1030,7 +1035,7 @@ fsevents@^1.2.7: bindings "^1.5.0" nan "^2.12.1" -fsevents@~2.3.1, fsevents@~2.3.2: +fsevents@~2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== @@ -1077,7 +1082,7 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" -glob-parent@^5.1.0, glob-parent@~5.1.0: +glob-parent@^5.1.0, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== @@ -1211,15 +1216,15 @@ gulp-rename@^2.0.0: resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-2.0.0.tgz#9bbc3962b0c0f52fc67cd5eaff6c223ec5b9cf6c" integrity sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ== -gulp-uglify-es@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/gulp-uglify-es/-/gulp-uglify-es-2.0.0.tgz#0a48d9f352393397e78cf2be44bf0fb66a353031" - integrity sha512-00KkawzjWdjPo1YfD1FXKijVxZkyr6YSwJ2cJQgD1fNKFZCFPNjGc5sTyzyW8tZns8FmZafgHMrg7LUDNvIQ5A== +gulp-uglify-es@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/gulp-uglify-es/-/gulp-uglify-es-3.0.0.tgz#00466e0e3b0486057c552b8b0d3e326791f2f832" + integrity sha512-dQ3czMFFojNgCajcrYl0oa98+YayaQ8kXRdaacpZRZ3iw2sdVURfdt8y8Ki1ogZGQqw8BUawnB7V6NkanxqnDg== dependencies: - o-stream "^0.2.2" + o-stream "^0.3.0" plugin-error "^1.0.1" - terser "^4.3.9" - vinyl "^2.2.0" + terser "^5.7.1" + vinyl "^2.2.1" vinyl-sourcemaps-apply "^0.2.1" gulp@^4.0.2: @@ -1784,15 +1789,15 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" -mocha@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.0.0.tgz#67ce848170cb6426f9e84c57e38376dc9017bab4" - integrity sha512-GRGG/q9bIaUkHJB9NL+KZNjDhMBHB30zW3bZW9qOiYr+QChyLjPzswaxFWkI1q6lGlSL28EQYzAi2vKWNkPx+g== +mocha@^9.1.1: + version "9.1.1" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-9.1.1.tgz#33df2eb9c6262434630510c5f4283b36efda9b61" + integrity sha512-0wE74YMgOkCgBUj8VyIDwmLUjTsS13WV1Pg7l0SHea2qzZzlq7MDnfbPsHKcELBRk3+izEVkRofjmClpycudCA== dependencies: "@ungap/promise-all-settled" "1.1.2" ansi-colors "4.1.1" browser-stdout "1.3.1" - chokidar "3.5.1" + chokidar "3.5.2" debug "4.3.1" diff "5.0.0" escape-string-regexp "4.0.0" @@ -1805,12 +1810,12 @@ mocha@^9.0.0: minimatch "3.0.4" ms "2.1.3" nanoid "3.1.23" - serialize-javascript "5.0.1" + serialize-javascript "6.0.0" strip-json-comments "3.1.1" supports-color "8.1.1" which "2.0.2" wide-align "1.1.3" - workerpool "6.1.4" + workerpool "6.1.5" yargs "16.2.0" yargs-parser "20.2.4" yargs-unparser "2.0.0" @@ -1908,10 +1913,10 @@ number-is-nan@^1.0.0: resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= -o-stream@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/o-stream/-/o-stream-0.2.2.tgz#7fe03af870b8f9537af33b312b381b3034ab410f" - integrity sha512-V3j76KU3g/Gyl8rpdi2z72rn5zguMvTCQgAXfBe3pxEefKqXmOUOD7mvx/mNjykdxGqDVfpSoo8r+WdrkWg/1Q== +o-stream@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/o-stream/-/o-stream-0.3.0.tgz#204d27bc3fb395164507d79b381e91752e8daedc" + integrity sha512-gbzl6qCJZ609x/M2t25HqCYQagFzWYCtQ84jcuObGr+V8D1Am4EVubkF4J+XFs6ukfiv96vNeiBb8FrbbMZYiQ== object-copy@^0.1.0: version "0.1.0" @@ -2233,10 +2238,10 @@ readdirp@^2.2.1: micromatch "^3.1.10" readable-stream "^2.0.2" -readdirp@~3.5.0: - version "3.5.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.5.0.tgz#9ba74c019b15d365278d2e91bb8c48d7b4d42c9e" - integrity sha512-cMhu7c/8rdhkHXWsY+osBhfSy0JikwpHK/5+imo+LpeasTF8ouErHrlYkwT0++njiyuDvc7OFY5T3ukvZ8qmFQ== +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== dependencies: picomatch "^2.2.1" @@ -2356,10 +2361,10 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -rollup@^2.52.0: - version "2.52.0" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.52.0.tgz#9df3de6028fae79569a985942b81110205a5a411" - integrity sha512-lSkBDGsVoXjqaBf7dsHwxBJz+p+hJEP72P+LOitA0yVs+Nzxj76FidkZE2thrmhjwGqLYiJo39opi7mAfaQ/Vg== +rollup@^2.56.3: + version "2.56.3" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.56.3.tgz#b63edadd9851b0d618a6d0e6af8201955a77aeff" + integrity sha512-Au92NuznFklgQCUcV96iXlxUbHuB1vQMaH76DHl5M11TotjOHwqk9CwcrT78+Tnv4FN9uTBxq6p4EJoYkpyekg== optionalDependencies: fsevents "~2.3.2" @@ -2399,10 +2404,10 @@ semver-greatest-satisfied-range@^1.1.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -serialize-javascript@5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-5.0.1.tgz#7886ec848049a462467a97d3d918ebb2aaf934f4" - integrity sha512-SaaNal9imEO737H2c05Og0/8LUXG7EnsZyMa8MzkmuHoELfT6txuj0cMqRj6zfPKnmQ1yasR4PCJc8x+M4JSPA== +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== dependencies: randombytes "^2.1.0" @@ -2472,10 +2477,10 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" -source-map-support@~0.5.12: - version "0.5.19" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" - integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== +source-map-support@~0.5.20: + version "0.5.20" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.20.tgz#12166089f8f5e5e8c56926b377633392dd2cb6c9" + integrity sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw== dependencies: buffer-from "^1.0.0" source-map "^0.6.0" @@ -2490,11 +2495,16 @@ source-map@^0.5.1, source-map@^0.5.6: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= -source-map@^0.6.0, source-map@~0.6.1: +source-map@^0.6.0: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== +source-map@~0.7.2: + version "0.7.3" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" + integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== + sparkles@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.1.tgz#008db65edce6c50eec0c5e228e1945061dd0437c" @@ -2644,14 +2654,14 @@ sver-compat@^1.5.0: es6-iterator "^2.0.1" es6-symbol "^3.1.1" -terser@^4.3.9: - version "4.8.0" - resolved "https://registry.yarnpkg.com/terser/-/terser-4.8.0.tgz#63056343d7c70bb29f3af665865a46fe03a0df17" - integrity sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw== +terser@^5.7.1: + version "5.8.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.8.0.tgz#c6d352f91aed85cc6171ccb5e84655b77521d947" + integrity sha512-f0JH+6yMpneYcRJN314lZrSwu9eKkUFEHLN/kNy8ceh8gaRiLgFPJqrB9HsXjhEGdv4e/ekjTOFxIlL6xlma8A== dependencies: commander "^2.20.0" - source-map "~0.6.1" - source-map-support "~0.5.12" + source-map "~0.7.2" + source-map-support "~0.5.20" through2-filter@^3.0.0: version "3.0.0" @@ -2876,7 +2886,7 @@ vinyl-sourcemaps-apply@^0.2.1: dependencies: source-map "^0.5.1" -vinyl@^2.0.0, vinyl@^2.2.0, vinyl@^2.2.1: +vinyl@^2.0.0, vinyl@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-2.2.1.tgz#23cfb8bbab5ece3803aa2c0a1eb28af7cbba1974" integrity sha512-LII3bXRFBZLlezoG5FfZVcXflZgWP/4dCwKtxd5ky9+LOtM4CS3bIRQsmR1KMnMW07jpE8fqR2lcxPZ+8sJIcw== @@ -2914,10 +2924,10 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" -workerpool@6.1.4: - version "6.1.4" - resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.1.4.tgz#6a972b6df82e38d50248ee2820aa98e2d0ad3090" - integrity sha512-jGWPzsUqzkow8HoAvqaPWTUPCrlPJaJ5tY8Iz7n1uCz3tTp6s3CDG0FF1NsX42WNlkRSW6Mr+CDZGnNoSsKa7g== +workerpool@6.1.5: + version "6.1.5" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.1.5.tgz#0f7cf076b6215fd7e1da903ff6f22ddd1886b581" + integrity sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw== wrap-ansi@^2.0.0: version "2.1.0"