diff --git a/antlr/ContactQL.g4 b/antlr/ContactQL.g4 index d0e2384d8..56272b381 100644 --- a/antlr/ContactQL.g4 +++ b/antlr/ContactQL.g4 @@ -5,6 +5,8 @@ import LexUnicode; // Lexer rules fragment HAS: [Hh][Aa][Ss]; fragment IS: [Ii][Ss]; +fragment PROPTYPE: (UnicodeLetter)+; +fragment PROPKEY: (UnicodeLetter | UnicodeDigit | '_')+; LPAREN: '('; RPAREN: ')'; @@ -22,7 +24,7 @@ COMPARATOR: ( | IS ); STRING: '"' (~["] | '\\"')* '"'; -NAME: (UnicodeLetter | UnicodeDigit | '_' | ':')+; +PROPERTY: (PROPTYPE '.')? PROPKEY; TEXT: ( UnicodeLetter | UnicodeDigit @@ -44,14 +46,14 @@ ERROR: .; parse: expression EOF; expression: - expression AND expression # combinationAnd - | expression expression # combinationImpicitAnd - | expression OR expression # combinationOr - | LPAREN expression RPAREN # expressionGrouping - | NAME COMPARATOR literal # condition - | literal # implicitCondition; - -literal: - NAME # textLiteral - | TEXT # textLiteral - | STRING # stringLiteral; \ No newline at end of file + expression AND expression # combinationAnd + | expression expression # combinationImpicitAnd + | expression OR expression # combinationOr + | LPAREN expression RPAREN # expressionGrouping + | PROPERTY COMPARATOR literal # condition + | literal # implicitCondition; + +literal: + PROPERTY # textLiteral // it's not really a property, just indistinguishable by lexer + | TEXT # textLiteral + | STRING # stringLiteral; \ No newline at end of file diff --git a/antlr/gen/contactql/ContactQL.interp b/antlr/gen/contactql/ContactQL.interp index d2a753ade..07aaa9843 100644 --- a/antlr/gen/contactql/ContactQL.interp +++ b/antlr/gen/contactql/ContactQL.interp @@ -19,7 +19,7 @@ AND OR COMPARATOR STRING -NAME +PROPERTY TEXT WS ERROR diff --git a/antlr/gen/contactql/ContactQL.tokens b/antlr/gen/contactql/ContactQL.tokens index 6fb2749ba..026008112 100644 --- a/antlr/gen/contactql/ContactQL.tokens +++ b/antlr/gen/contactql/ContactQL.tokens @@ -4,7 +4,7 @@ AND=3 OR=4 COMPARATOR=5 STRING=6 -NAME=7 +PROPERTY=7 TEXT=8 WS=9 ERROR=10 diff --git a/antlr/gen/contactql/ContactQLLexer.interp b/antlr/gen/contactql/ContactQLLexer.interp index 026c6f32a..bd11d1d84 100644 --- a/antlr/gen/contactql/ContactQLLexer.interp +++ b/antlr/gen/contactql/ContactQLLexer.interp @@ -19,7 +19,7 @@ AND OR COMPARATOR STRING -NAME +PROPERTY TEXT WS ERROR @@ -27,13 +27,15 @@ ERROR rule names: HAS IS +PROPTYPE +PROPKEY LPAREN RPAREN AND OR COMPARATOR STRING -NAME +PROPERTY TEXT WS ERROR @@ -53,4 +55,4 @@ mode names: DEFAULT_MODE atn: -[4, 0, 10, 123, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 69, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 5, 7, 75, 8, 7, 10, 7, 12, 7, 78, 9, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 4, 8, 85, 8, 8, 11, 8, 12, 8, 86, 1, 9, 1, 9, 1, 9, 4, 9, 92, 8, 9, 11, 9, 12, 9, 93, 1, 10, 4, 10, 97, 8, 10, 11, 10, 12, 10, 98, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 3, 12, 110, 8, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 0, 0, 19, 1, 0, 3, 0, 5, 1, 7, 2, 9, 3, 11, 4, 13, 5, 15, 6, 17, 7, 19, 8, 21, 9, 23, 10, 25, 0, 27, 0, 29, 0, 31, 0, 33, 0, 35, 0, 37, 0, 1, 0, 19, 2, 0, 72, 72, 104, 104, 2, 0, 65, 65, 97, 97, 2, 0, 83, 83, 115, 115, 2, 0, 73, 73, 105, 105, 2, 0, 78, 78, 110, 110, 2, 0, 68, 68, 100, 100, 2, 0, 79, 79, 111, 111, 2, 0, 82, 82, 114, 114, 2, 0, 60, 60, 62, 62, 1, 0, 34, 34, 2, 0, 58, 58, 95, 95, 6, 0, 39, 39, 43, 43, 45, 47, 58, 58, 64, 64, 95, 95, 3, 0, 9, 10, 13, 13, 32, 32, 82, 0, 65, 90, 192, 214, 216, 222, 256, 310, 313, 327, 330, 381, 385, 386, 388, 395, 398, 401, 403, 404, 406, 408, 412, 413, 415, 416, 418, 425, 428, 435, 437, 444, 452, 461, 463, 475, 478, 494, 497, 500, 502, 504, 506, 562, 570, 571, 573, 574, 577, 582, 584, 590, 880, 882, 886, 895, 902, 906, 908, 929, 931, 939, 975, 980, 984, 1006, 1012, 1015, 1017, 1018, 1021, 1071, 1120, 1152, 1162, 1229, 1232, 1326, 1329, 1366, 4256, 4293, 4295, 4301, 7680, 7828, 7838, 7934, 7944, 7951, 7960, 7965, 7976, 7983, 7992, 7999, 8008, 8013, 8025, 8031, 8040, 8047, 8120, 8123, 8136, 8139, 8152, 8155, 8168, 8172, 8184, 8187, 8450, 8455, 8459, 8461, 8464, 8466, 8469, 8477, 8484, 8493, 8496, 8499, 8510, 8511, 8517, 8579, 11264, 11310, 11360, 11364, 11367, 11376, 11378, 11381, 11390, 11392, 11394, 11490, 11499, 11501, 11506, 42560, 42562, 42604, 42624, 42650, 42786, 42798, 42802, 42862, 42873, 42886, 42891, 42893, 42896, 42898, 42902, 42925, 42928, 42929, 65313, 65338, 81, 0, 97, 122, 181, 246, 248, 255, 257, 375, 378, 384, 387, 389, 392, 402, 405, 411, 414, 417, 419, 421, 424, 429, 432, 436, 438, 447, 454, 460, 462, 499, 501, 505, 507, 569, 572, 578, 583, 659, 661, 687, 881, 883, 887, 893, 912, 974, 976, 977, 981, 983, 985, 1011, 1013, 1119, 1121, 1153, 1163, 1215, 1218, 1327, 1377, 1415, 7424, 7467, 7531, 7543, 7545, 7578, 7681, 7837, 7839, 7943, 7952, 7957, 7968, 7975, 7984, 7991, 8000, 8005, 8016, 8023, 8032, 8039, 8048, 8061, 8064, 8071, 8080, 8087, 8096, 8103, 8112, 8116, 8118, 8119, 8126, 8132, 8134, 8135, 8144, 8147, 8150, 8151, 8160, 8167, 8178, 8180, 8182, 8183, 8458, 8467, 8495, 8505, 8508, 8509, 8518, 8521, 8526, 8580, 11312, 11358, 11361, 11372, 11377, 11387, 11393, 11500, 11502, 11507, 11520, 11557, 11559, 11565, 42561, 42605, 42625, 42651, 42787, 42801, 42803, 42872, 42874, 42876, 42879, 42887, 42892, 42894, 42897, 42901, 42903, 42921, 43002, 43866, 43876, 43877, 64256, 64262, 64275, 64279, 65345, 65370, 6, 0, 453, 459, 498, 8079, 8088, 8095, 8104, 8111, 8124, 8140, 8188, 8188, 33, 0, 688, 705, 710, 721, 736, 740, 748, 750, 884, 890, 1369, 1600, 1765, 1766, 2036, 2037, 2042, 2074, 2084, 2088, 2417, 3654, 3782, 4348, 6103, 6211, 6823, 7293, 7468, 7530, 7544, 7615, 8305, 8319, 8336, 8348, 11388, 11389, 11631, 11823, 12293, 12341, 12347, 12542, 40981, 42237, 42508, 42623, 42652, 42653, 42775, 42783, 42864, 42888, 43000, 43001, 43471, 43494, 43632, 43741, 43763, 43764, 43868, 43871, 65392, 65439, 234, 0, 170, 186, 443, 451, 660, 1514, 1520, 1522, 1568, 1599, 1601, 1610, 1646, 1647, 1649, 1747, 1749, 1788, 1791, 1808, 1810, 1839, 1869, 1957, 1969, 2026, 2048, 2069, 2112, 2136, 2208, 2226, 2308, 2361, 2365, 2384, 2392, 2401, 2418, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2489, 2493, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2913, 2929, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2986, 2990, 3001, 3024, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3526, 3585, 3632, 3634, 3635, 3648, 3653, 3713, 3714, 3716, 3722, 3725, 3735, 3737, 3743, 3745, 3747, 3749, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3780, 3804, 3807, 3840, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4181, 4186, 4189, 4193, 4208, 4213, 4225, 4238, 4346, 4349, 4680, 4682, 4685, 4688, 4694, 4696, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5873, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6108, 6210, 6212, 6263, 6272, 6312, 6314, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7287, 7401, 7404, 7406, 7409, 7413, 7414, 8501, 8504, 11568, 11623, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12294, 12348, 12353, 12438, 12447, 12538, 12543, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 40980, 40982, 42124, 42192, 42231, 42240, 42507, 42512, 42527, 42538, 42539, 42606, 42725, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43488, 43492, 43495, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43631, 43633, 43638, 43642, 43695, 43697, 43709, 43712, 43714, 43739, 43740, 43744, 43754, 43762, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65382, 65391, 65393, 65437, 65440, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 37, 0, 48, 57, 1632, 1641, 1776, 1785, 1984, 1993, 2406, 2415, 2534, 2543, 2662, 2671, 2790, 2799, 2918, 2927, 3046, 3055, 3174, 3183, 3302, 3311, 3430, 3439, 3558, 3567, 3664, 3673, 3792, 3801, 3872, 3881, 4160, 4169, 4240, 4249, 6112, 6121, 6160, 6169, 6470, 6479, 6608, 6617, 6784, 6793, 6800, 6809, 6992, 7001, 7088, 7097, 7232, 7241, 7248, 7257, 42528, 42537, 43216, 43225, 43264, 43273, 43472, 43481, 43504, 43513, 43600, 43609, 44016, 44025, 65296, 65305, 133, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 1, 39, 1, 0, 0, 0, 3, 43, 1, 0, 0, 0, 5, 46, 1, 0, 0, 0, 7, 48, 1, 0, 0, 0, 9, 50, 1, 0, 0, 0, 11, 54, 1, 0, 0, 0, 13, 68, 1, 0, 0, 0, 15, 70, 1, 0, 0, 0, 17, 84, 1, 0, 0, 0, 19, 91, 1, 0, 0, 0, 21, 96, 1, 0, 0, 0, 23, 102, 1, 0, 0, 0, 25, 109, 1, 0, 0, 0, 27, 111, 1, 0, 0, 0, 29, 113, 1, 0, 0, 0, 31, 115, 1, 0, 0, 0, 33, 117, 1, 0, 0, 0, 35, 119, 1, 0, 0, 0, 37, 121, 1, 0, 0, 0, 39, 40, 7, 0, 0, 0, 40, 41, 7, 1, 0, 0, 41, 42, 7, 2, 0, 0, 42, 2, 1, 0, 0, 0, 43, 44, 7, 3, 0, 0, 44, 45, 7, 2, 0, 0, 45, 4, 1, 0, 0, 0, 46, 47, 5, 40, 0, 0, 47, 6, 1, 0, 0, 0, 48, 49, 5, 41, 0, 0, 49, 8, 1, 0, 0, 0, 50, 51, 7, 1, 0, 0, 51, 52, 7, 4, 0, 0, 52, 53, 7, 5, 0, 0, 53, 10, 1, 0, 0, 0, 54, 55, 7, 6, 0, 0, 55, 56, 7, 7, 0, 0, 56, 12, 1, 0, 0, 0, 57, 69, 5, 61, 0, 0, 58, 59, 5, 33, 0, 0, 59, 69, 5, 61, 0, 0, 60, 69, 5, 126, 0, 0, 61, 62, 5, 62, 0, 0, 62, 69, 5, 61, 0, 0, 63, 64, 5, 60, 0, 0, 64, 69, 5, 61, 0, 0, 65, 69, 7, 8, 0, 0, 66, 69, 3, 1, 0, 0, 67, 69, 3, 3, 1, 0, 68, 57, 1, 0, 0, 0, 68, 58, 1, 0, 0, 0, 68, 60, 1, 0, 0, 0, 68, 61, 1, 0, 0, 0, 68, 63, 1, 0, 0, 0, 68, 65, 1, 0, 0, 0, 68, 66, 1, 0, 0, 0, 68, 67, 1, 0, 0, 0, 69, 14, 1, 0, 0, 0, 70, 76, 5, 34, 0, 0, 71, 75, 8, 9, 0, 0, 72, 73, 5, 92, 0, 0, 73, 75, 5, 34, 0, 0, 74, 71, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 75, 78, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 79, 1, 0, 0, 0, 78, 76, 1, 0, 0, 0, 79, 80, 5, 34, 0, 0, 80, 16, 1, 0, 0, 0, 81, 85, 3, 25, 12, 0, 82, 85, 3, 37, 18, 0, 83, 85, 7, 10, 0, 0, 84, 81, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 83, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 86, 87, 1, 0, 0, 0, 87, 18, 1, 0, 0, 0, 88, 92, 3, 25, 12, 0, 89, 92, 3, 37, 18, 0, 90, 92, 7, 11, 0, 0, 91, 88, 1, 0, 0, 0, 91, 89, 1, 0, 0, 0, 91, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 93, 94, 1, 0, 0, 0, 94, 20, 1, 0, 0, 0, 95, 97, 7, 12, 0, 0, 96, 95, 1, 0, 0, 0, 97, 98, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 98, 99, 1, 0, 0, 0, 99, 100, 1, 0, 0, 0, 100, 101, 6, 10, 0, 0, 101, 22, 1, 0, 0, 0, 102, 103, 9, 0, 0, 0, 103, 24, 1, 0, 0, 0, 104, 110, 3, 27, 13, 0, 105, 110, 3, 29, 14, 0, 106, 110, 3, 31, 15, 0, 107, 110, 3, 33, 16, 0, 108, 110, 3, 35, 17, 0, 109, 104, 1, 0, 0, 0, 109, 105, 1, 0, 0, 0, 109, 106, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 109, 108, 1, 0, 0, 0, 110, 26, 1, 0, 0, 0, 111, 112, 7, 13, 0, 0, 112, 28, 1, 0, 0, 0, 113, 114, 7, 14, 0, 0, 114, 30, 1, 0, 0, 0, 115, 116, 7, 15, 0, 0, 116, 32, 1, 0, 0, 0, 117, 118, 7, 16, 0, 0, 118, 34, 1, 0, 0, 0, 119, 120, 7, 17, 0, 0, 120, 36, 1, 0, 0, 0, 121, 122, 7, 18, 0, 0, 122, 38, 1, 0, 0, 0, 10, 0, 68, 74, 76, 84, 86, 91, 93, 98, 109, 1, 6, 0, 0] \ No newline at end of file +[4, 0, 10, 139, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 52, 8, 2, 11, 2, 12, 2, 53, 1, 3, 1, 3, 1, 3, 4, 3, 59, 8, 3, 11, 3, 12, 3, 60, 1, 4, 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 85, 8, 8, 1, 9, 1, 9, 1, 9, 1, 9, 5, 9, 91, 8, 9, 10, 9, 12, 9, 94, 9, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 3, 10, 101, 8, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 4, 11, 108, 8, 11, 11, 11, 12, 11, 109, 1, 12, 4, 12, 113, 8, 12, 11, 12, 12, 12, 114, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 126, 8, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 0, 0, 21, 1, 0, 3, 0, 5, 0, 7, 0, 9, 1, 11, 2, 13, 3, 15, 4, 17, 5, 19, 6, 21, 7, 23, 8, 25, 9, 27, 10, 29, 0, 31, 0, 33, 0, 35, 0, 37, 0, 39, 0, 41, 0, 1, 0, 18, 2, 0, 72, 72, 104, 104, 2, 0, 65, 65, 97, 97, 2, 0, 83, 83, 115, 115, 2, 0, 73, 73, 105, 105, 2, 0, 78, 78, 110, 110, 2, 0, 68, 68, 100, 100, 2, 0, 79, 79, 111, 111, 2, 0, 82, 82, 114, 114, 2, 0, 60, 60, 62, 62, 1, 0, 34, 34, 6, 0, 39, 39, 43, 43, 45, 47, 58, 58, 64, 64, 95, 95, 3, 0, 9, 10, 13, 13, 32, 32, 82, 0, 65, 90, 192, 214, 216, 222, 256, 310, 313, 327, 330, 381, 385, 386, 388, 395, 398, 401, 403, 404, 406, 408, 412, 413, 415, 416, 418, 425, 428, 435, 437, 444, 452, 461, 463, 475, 478, 494, 497, 500, 502, 504, 506, 562, 570, 571, 573, 574, 577, 582, 584, 590, 880, 882, 886, 895, 902, 906, 908, 929, 931, 939, 975, 980, 984, 1006, 1012, 1015, 1017, 1018, 1021, 1071, 1120, 1152, 1162, 1229, 1232, 1326, 1329, 1366, 4256, 4293, 4295, 4301, 7680, 7828, 7838, 7934, 7944, 7951, 7960, 7965, 7976, 7983, 7992, 7999, 8008, 8013, 8025, 8031, 8040, 8047, 8120, 8123, 8136, 8139, 8152, 8155, 8168, 8172, 8184, 8187, 8450, 8455, 8459, 8461, 8464, 8466, 8469, 8477, 8484, 8493, 8496, 8499, 8510, 8511, 8517, 8579, 11264, 11310, 11360, 11364, 11367, 11376, 11378, 11381, 11390, 11392, 11394, 11490, 11499, 11501, 11506, 42560, 42562, 42604, 42624, 42650, 42786, 42798, 42802, 42862, 42873, 42886, 42891, 42893, 42896, 42898, 42902, 42925, 42928, 42929, 65313, 65338, 81, 0, 97, 122, 181, 246, 248, 255, 257, 375, 378, 384, 387, 389, 392, 402, 405, 411, 414, 417, 419, 421, 424, 429, 432, 436, 438, 447, 454, 460, 462, 499, 501, 505, 507, 569, 572, 578, 583, 659, 661, 687, 881, 883, 887, 893, 912, 974, 976, 977, 981, 983, 985, 1011, 1013, 1119, 1121, 1153, 1163, 1215, 1218, 1327, 1377, 1415, 7424, 7467, 7531, 7543, 7545, 7578, 7681, 7837, 7839, 7943, 7952, 7957, 7968, 7975, 7984, 7991, 8000, 8005, 8016, 8023, 8032, 8039, 8048, 8061, 8064, 8071, 8080, 8087, 8096, 8103, 8112, 8116, 8118, 8119, 8126, 8132, 8134, 8135, 8144, 8147, 8150, 8151, 8160, 8167, 8178, 8180, 8182, 8183, 8458, 8467, 8495, 8505, 8508, 8509, 8518, 8521, 8526, 8580, 11312, 11358, 11361, 11372, 11377, 11387, 11393, 11500, 11502, 11507, 11520, 11557, 11559, 11565, 42561, 42605, 42625, 42651, 42787, 42801, 42803, 42872, 42874, 42876, 42879, 42887, 42892, 42894, 42897, 42901, 42903, 42921, 43002, 43866, 43876, 43877, 64256, 64262, 64275, 64279, 65345, 65370, 6, 0, 453, 459, 498, 8079, 8088, 8095, 8104, 8111, 8124, 8140, 8188, 8188, 33, 0, 688, 705, 710, 721, 736, 740, 748, 750, 884, 890, 1369, 1600, 1765, 1766, 2036, 2037, 2042, 2074, 2084, 2088, 2417, 3654, 3782, 4348, 6103, 6211, 6823, 7293, 7468, 7530, 7544, 7615, 8305, 8319, 8336, 8348, 11388, 11389, 11631, 11823, 12293, 12341, 12347, 12542, 40981, 42237, 42508, 42623, 42652, 42653, 42775, 42783, 42864, 42888, 43000, 43001, 43471, 43494, 43632, 43741, 43763, 43764, 43868, 43871, 65392, 65439, 234, 0, 170, 186, 443, 451, 660, 1514, 1520, 1522, 1568, 1599, 1601, 1610, 1646, 1647, 1649, 1747, 1749, 1788, 1791, 1808, 1810, 1839, 1869, 1957, 1969, 2026, 2048, 2069, 2112, 2136, 2208, 2226, 2308, 2361, 2365, 2384, 2392, 2401, 2418, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2489, 2493, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2913, 2929, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2986, 2990, 3001, 3024, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3526, 3585, 3632, 3634, 3635, 3648, 3653, 3713, 3714, 3716, 3722, 3725, 3735, 3737, 3743, 3745, 3747, 3749, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3780, 3804, 3807, 3840, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4181, 4186, 4189, 4193, 4208, 4213, 4225, 4238, 4346, 4349, 4680, 4682, 4685, 4688, 4694, 4696, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5873, 5880, 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6108, 6210, 6212, 6263, 6272, 6312, 6314, 6389, 6400, 6430, 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, 7287, 7401, 7404, 7406, 7409, 7413, 7414, 8501, 8504, 11568, 11623, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12294, 12348, 12353, 12438, 12447, 12538, 12543, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, 19968, 40908, 40960, 40980, 40982, 42124, 42192, 42231, 42240, 42507, 42512, 42527, 42538, 42539, 42606, 42725, 42999, 43009, 43011, 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43488, 43492, 43495, 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43631, 43633, 43638, 43642, 43695, 43697, 43709, 43712, 43714, 43739, 43740, 43744, 43754, 43762, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65382, 65391, 65393, 65437, 65440, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 37, 0, 48, 57, 1632, 1641, 1776, 1785, 1984, 1993, 2406, 2415, 2534, 2543, 2662, 2671, 2790, 2799, 2918, 2927, 3046, 3055, 3174, 3183, 3302, 3311, 3430, 3439, 3558, 3567, 3664, 3673, 3792, 3801, 3872, 3881, 4160, 4169, 4240, 4249, 6112, 6121, 6160, 6169, 6470, 6479, 6608, 6617, 6784, 6793, 6800, 6809, 6992, 7001, 7088, 7097, 7232, 7241, 7248, 7257, 42528, 42537, 43216, 43225, 43264, 43273, 43472, 43481, 43504, 43513, 43600, 43609, 44016, 44025, 65296, 65305, 149, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 1, 43, 1, 0, 0, 0, 3, 47, 1, 0, 0, 0, 5, 51, 1, 0, 0, 0, 7, 58, 1, 0, 0, 0, 9, 62, 1, 0, 0, 0, 11, 64, 1, 0, 0, 0, 13, 66, 1, 0, 0, 0, 15, 70, 1, 0, 0, 0, 17, 84, 1, 0, 0, 0, 19, 86, 1, 0, 0, 0, 21, 100, 1, 0, 0, 0, 23, 107, 1, 0, 0, 0, 25, 112, 1, 0, 0, 0, 27, 118, 1, 0, 0, 0, 29, 125, 1, 0, 0, 0, 31, 127, 1, 0, 0, 0, 33, 129, 1, 0, 0, 0, 35, 131, 1, 0, 0, 0, 37, 133, 1, 0, 0, 0, 39, 135, 1, 0, 0, 0, 41, 137, 1, 0, 0, 0, 43, 44, 7, 0, 0, 0, 44, 45, 7, 1, 0, 0, 45, 46, 7, 2, 0, 0, 46, 2, 1, 0, 0, 0, 47, 48, 7, 3, 0, 0, 48, 49, 7, 2, 0, 0, 49, 4, 1, 0, 0, 0, 50, 52, 3, 29, 14, 0, 51, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 53, 54, 1, 0, 0, 0, 54, 6, 1, 0, 0, 0, 55, 59, 3, 29, 14, 0, 56, 59, 3, 41, 20, 0, 57, 59, 5, 95, 0, 0, 58, 55, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 57, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 58, 1, 0, 0, 0, 60, 61, 1, 0, 0, 0, 61, 8, 1, 0, 0, 0, 62, 63, 5, 40, 0, 0, 63, 10, 1, 0, 0, 0, 64, 65, 5, 41, 0, 0, 65, 12, 1, 0, 0, 0, 66, 67, 7, 1, 0, 0, 67, 68, 7, 4, 0, 0, 68, 69, 7, 5, 0, 0, 69, 14, 1, 0, 0, 0, 70, 71, 7, 6, 0, 0, 71, 72, 7, 7, 0, 0, 72, 16, 1, 0, 0, 0, 73, 85, 5, 61, 0, 0, 74, 75, 5, 33, 0, 0, 75, 85, 5, 61, 0, 0, 76, 85, 5, 126, 0, 0, 77, 78, 5, 62, 0, 0, 78, 85, 5, 61, 0, 0, 79, 80, 5, 60, 0, 0, 80, 85, 5, 61, 0, 0, 81, 85, 7, 8, 0, 0, 82, 85, 3, 1, 0, 0, 83, 85, 3, 3, 1, 0, 84, 73, 1, 0, 0, 0, 84, 74, 1, 0, 0, 0, 84, 76, 1, 0, 0, 0, 84, 77, 1, 0, 0, 0, 84, 79, 1, 0, 0, 0, 84, 81, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 83, 1, 0, 0, 0, 85, 18, 1, 0, 0, 0, 86, 92, 5, 34, 0, 0, 87, 91, 8, 9, 0, 0, 88, 89, 5, 92, 0, 0, 89, 91, 5, 34, 0, 0, 90, 87, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 91, 94, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 95, 1, 0, 0, 0, 94, 92, 1, 0, 0, 0, 95, 96, 5, 34, 0, 0, 96, 20, 1, 0, 0, 0, 97, 98, 3, 5, 2, 0, 98, 99, 5, 46, 0, 0, 99, 101, 1, 0, 0, 0, 100, 97, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 103, 3, 7, 3, 0, 103, 22, 1, 0, 0, 0, 104, 108, 3, 29, 14, 0, 105, 108, 3, 41, 20, 0, 106, 108, 7, 10, 0, 0, 107, 104, 1, 0, 0, 0, 107, 105, 1, 0, 0, 0, 107, 106, 1, 0, 0, 0, 108, 109, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 109, 110, 1, 0, 0, 0, 110, 24, 1, 0, 0, 0, 111, 113, 7, 11, 0, 0, 112, 111, 1, 0, 0, 0, 113, 114, 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 117, 6, 12, 0, 0, 117, 26, 1, 0, 0, 0, 118, 119, 9, 0, 0, 0, 119, 28, 1, 0, 0, 0, 120, 126, 3, 31, 15, 0, 121, 126, 3, 33, 16, 0, 122, 126, 3, 35, 17, 0, 123, 126, 3, 37, 18, 0, 124, 126, 3, 39, 19, 0, 125, 120, 1, 0, 0, 0, 125, 121, 1, 0, 0, 0, 125, 122, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 125, 124, 1, 0, 0, 0, 126, 30, 1, 0, 0, 0, 127, 128, 7, 12, 0, 0, 128, 32, 1, 0, 0, 0, 129, 130, 7, 13, 0, 0, 130, 34, 1, 0, 0, 0, 131, 132, 7, 14, 0, 0, 132, 36, 1, 0, 0, 0, 133, 134, 7, 15, 0, 0, 134, 38, 1, 0, 0, 0, 135, 136, 7, 16, 0, 0, 136, 40, 1, 0, 0, 0, 137, 138, 7, 17, 0, 0, 138, 42, 1, 0, 0, 0, 12, 0, 53, 58, 60, 84, 90, 92, 100, 107, 109, 114, 125, 1, 6, 0, 0] \ No newline at end of file diff --git a/antlr/gen/contactql/ContactQLLexer.tokens b/antlr/gen/contactql/ContactQLLexer.tokens index 6fb2749ba..026008112 100644 --- a/antlr/gen/contactql/ContactQLLexer.tokens +++ b/antlr/gen/contactql/ContactQLLexer.tokens @@ -4,7 +4,7 @@ AND=3 OR=4 COMPARATOR=5 STRING=6 -NAME=7 +PROPERTY=7 TEXT=8 WS=9 ERROR=10 diff --git a/antlr/gen/contactql/contactql_lexer.go b/antlr/gen/contactql/contactql_lexer.go index 82373f7b3..c3f67ae6f 100644 --- a/antlr/gen/contactql/contactql_lexer.go +++ b/antlr/gen/contactql/contactql_lexer.go @@ -46,153 +46,161 @@ func contactqllexerLexerInit() { "", "'('", "')'", } staticData.SymbolicNames = []string{ - "", "LPAREN", "RPAREN", "AND", "OR", "COMPARATOR", "STRING", "NAME", + "", "LPAREN", "RPAREN", "AND", "OR", "COMPARATOR", "STRING", "PROPERTY", "TEXT", "WS", "ERROR", } staticData.RuleNames = []string{ - "HAS", "IS", "LPAREN", "RPAREN", "AND", "OR", "COMPARATOR", "STRING", - "NAME", "TEXT", "WS", "ERROR", "UnicodeLetter", "UnicodeClass_LU", "UnicodeClass_LL", - "UnicodeClass_LT", "UnicodeClass_LM", "UnicodeClass_LO", "UnicodeDigit", + "HAS", "IS", "PROPTYPE", "PROPKEY", "LPAREN", "RPAREN", "AND", "OR", + "COMPARATOR", "STRING", "PROPERTY", "TEXT", "WS", "ERROR", "UnicodeLetter", + "UnicodeClass_LU", "UnicodeClass_LL", "UnicodeClass_LT", "UnicodeClass_LM", + "UnicodeClass_LO", "UnicodeDigit", } staticData.PredictionContextCache = antlr.NewPredictionContextCache() staticData.serializedATN = []int32{ - 4, 0, 10, 123, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, + 4, 0, 10, 139, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, - 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 1, 0, 1, 0, 1, 0, 1, 0, - 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, - 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, - 1, 6, 3, 6, 69, 8, 6, 1, 7, 1, 7, 1, 7, 1, 7, 5, 7, 75, 8, 7, 10, 7, 12, - 7, 78, 9, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 4, 8, 85, 8, 8, 11, 8, 12, 8, - 86, 1, 9, 1, 9, 1, 9, 4, 9, 92, 8, 9, 11, 9, 12, 9, 93, 1, 10, 4, 10, 97, - 8, 10, 11, 10, 12, 10, 98, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, - 12, 1, 12, 1, 12, 3, 12, 110, 8, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 15, - 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, 18, 1, 18, 0, 0, 19, 1, 0, 3, 0, - 5, 1, 7, 2, 9, 3, 11, 4, 13, 5, 15, 6, 17, 7, 19, 8, 21, 9, 23, 10, 25, - 0, 27, 0, 29, 0, 31, 0, 33, 0, 35, 0, 37, 0, 1, 0, 19, 2, 0, 72, 72, 104, + 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, + 20, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 4, 2, 52, 8, 2, 11, + 2, 12, 2, 53, 1, 3, 1, 3, 1, 3, 4, 3, 59, 8, 3, 11, 3, 12, 3, 60, 1, 4, + 1, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, + 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 85, 8, 8, 1, + 9, 1, 9, 1, 9, 1, 9, 5, 9, 91, 8, 9, 10, 9, 12, 9, 94, 9, 9, 1, 9, 1, 9, + 1, 10, 1, 10, 1, 10, 3, 10, 101, 8, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, + 11, 4, 11, 108, 8, 11, 11, 11, 12, 11, 109, 1, 12, 4, 12, 113, 8, 12, 11, + 12, 12, 12, 114, 1, 12, 1, 12, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, + 1, 14, 3, 14, 126, 8, 14, 1, 15, 1, 15, 1, 16, 1, 16, 1, 17, 1, 17, 1, + 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 0, 0, 21, 1, 0, 3, 0, 5, 0, 7, 0, + 9, 1, 11, 2, 13, 3, 15, 4, 17, 5, 19, 6, 21, 7, 23, 8, 25, 9, 27, 10, 29, + 0, 31, 0, 33, 0, 35, 0, 37, 0, 39, 0, 41, 0, 1, 0, 18, 2, 0, 72, 72, 104, 104, 2, 0, 65, 65, 97, 97, 2, 0, 83, 83, 115, 115, 2, 0, 73, 73, 105, 105, 2, 0, 78, 78, 110, 110, 2, 0, 68, 68, 100, 100, 2, 0, 79, 79, 111, 111, - 2, 0, 82, 82, 114, 114, 2, 0, 60, 60, 62, 62, 1, 0, 34, 34, 2, 0, 58, 58, - 95, 95, 6, 0, 39, 39, 43, 43, 45, 47, 58, 58, 64, 64, 95, 95, 3, 0, 9, - 10, 13, 13, 32, 32, 82, 0, 65, 90, 192, 214, 216, 222, 256, 310, 313, 327, - 330, 381, 385, 386, 388, 395, 398, 401, 403, 404, 406, 408, 412, 413, 415, - 416, 418, 425, 428, 435, 437, 444, 452, 461, 463, 475, 478, 494, 497, 500, - 502, 504, 506, 562, 570, 571, 573, 574, 577, 582, 584, 590, 880, 882, 886, - 895, 902, 906, 908, 929, 931, 939, 975, 980, 984, 1006, 1012, 1015, 1017, - 1018, 1021, 1071, 1120, 1152, 1162, 1229, 1232, 1326, 1329, 1366, 4256, - 4293, 4295, 4301, 7680, 7828, 7838, 7934, 7944, 7951, 7960, 7965, 7976, - 7983, 7992, 7999, 8008, 8013, 8025, 8031, 8040, 8047, 8120, 8123, 8136, - 8139, 8152, 8155, 8168, 8172, 8184, 8187, 8450, 8455, 8459, 8461, 8464, - 8466, 8469, 8477, 8484, 8493, 8496, 8499, 8510, 8511, 8517, 8579, 11264, - 11310, 11360, 11364, 11367, 11376, 11378, 11381, 11390, 11392, 11394, 11490, - 11499, 11501, 11506, 42560, 42562, 42604, 42624, 42650, 42786, 42798, 42802, - 42862, 42873, 42886, 42891, 42893, 42896, 42898, 42902, 42925, 42928, 42929, - 65313, 65338, 81, 0, 97, 122, 181, 246, 248, 255, 257, 375, 378, 384, 387, - 389, 392, 402, 405, 411, 414, 417, 419, 421, 424, 429, 432, 436, 438, 447, - 454, 460, 462, 499, 501, 505, 507, 569, 572, 578, 583, 659, 661, 687, 881, - 883, 887, 893, 912, 974, 976, 977, 981, 983, 985, 1011, 1013, 1119, 1121, - 1153, 1163, 1215, 1218, 1327, 1377, 1415, 7424, 7467, 7531, 7543, 7545, - 7578, 7681, 7837, 7839, 7943, 7952, 7957, 7968, 7975, 7984, 7991, 8000, - 8005, 8016, 8023, 8032, 8039, 8048, 8061, 8064, 8071, 8080, 8087, 8096, - 8103, 8112, 8116, 8118, 8119, 8126, 8132, 8134, 8135, 8144, 8147, 8150, - 8151, 8160, 8167, 8178, 8180, 8182, 8183, 8458, 8467, 8495, 8505, 8508, - 8509, 8518, 8521, 8526, 8580, 11312, 11358, 11361, 11372, 11377, 11387, - 11393, 11500, 11502, 11507, 11520, 11557, 11559, 11565, 42561, 42605, 42625, - 42651, 42787, 42801, 42803, 42872, 42874, 42876, 42879, 42887, 42892, 42894, - 42897, 42901, 42903, 42921, 43002, 43866, 43876, 43877, 64256, 64262, 64275, - 64279, 65345, 65370, 6, 0, 453, 459, 498, 8079, 8088, 8095, 8104, 8111, - 8124, 8140, 8188, 8188, 33, 0, 688, 705, 710, 721, 736, 740, 748, 750, - 884, 890, 1369, 1600, 1765, 1766, 2036, 2037, 2042, 2074, 2084, 2088, 2417, - 3654, 3782, 4348, 6103, 6211, 6823, 7293, 7468, 7530, 7544, 7615, 8305, - 8319, 8336, 8348, 11388, 11389, 11631, 11823, 12293, 12341, 12347, 12542, - 40981, 42237, 42508, 42623, 42652, 42653, 42775, 42783, 42864, 42888, 43000, - 43001, 43471, 43494, 43632, 43741, 43763, 43764, 43868, 43871, 65392, 65439, - 234, 0, 170, 186, 443, 451, 660, 1514, 1520, 1522, 1568, 1599, 1601, 1610, - 1646, 1647, 1649, 1747, 1749, 1788, 1791, 1808, 1810, 1839, 1869, 1957, - 1969, 2026, 2048, 2069, 2112, 2136, 2208, 2226, 2308, 2361, 2365, 2384, - 2392, 2401, 2418, 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, - 2482, 2489, 2493, 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, - 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, - 2649, 2652, 2654, 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, - 2738, 2739, 2741, 2745, 2749, 2768, 2784, 2785, 2821, 2828, 2831, 2832, - 2835, 2856, 2858, 2864, 2866, 2867, 2869, 2873, 2877, 2913, 2929, 2947, - 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2986, 2990, 3001, - 3024, 3084, 3086, 3088, 3090, 3112, 3114, 3129, 3133, 3212, 3214, 3216, - 3218, 3240, 3242, 3251, 3253, 3257, 3261, 3294, 3296, 3297, 3313, 3314, - 3333, 3340, 3342, 3344, 3346, 3386, 3389, 3406, 3424, 3425, 3450, 3455, - 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3526, 3585, 3632, 3634, 3635, - 3648, 3653, 3713, 3714, 3716, 3722, 3725, 3735, 3737, 3743, 3745, 3747, - 3749, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3780, 3804, 3807, - 3840, 3911, 3913, 3948, 3976, 3980, 4096, 4138, 4159, 4181, 4186, 4189, - 4193, 4208, 4213, 4225, 4238, 4346, 4349, 4680, 4682, 4685, 4688, 4694, - 4696, 4701, 4704, 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, - 4800, 4805, 4808, 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, - 5024, 5108, 5121, 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5873, 5880, - 5888, 5900, 5902, 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, - 6016, 6067, 6108, 6210, 6212, 6263, 6272, 6312, 6314, 6389, 6400, 6430, - 6480, 6509, 6512, 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, - 6917, 6963, 6981, 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, - 7245, 7247, 7258, 7287, 7401, 7404, 7406, 7409, 7413, 7414, 8501, 8504, - 11568, 11623, 11648, 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, - 11710, 11712, 11718, 11720, 11726, 11728, 11734, 11736, 11742, 12294, 12348, - 12353, 12438, 12447, 12538, 12543, 12589, 12593, 12686, 12704, 12730, 12784, - 12799, 13312, 19893, 19968, 40908, 40960, 40980, 40982, 42124, 42192, 42231, - 42240, 42507, 42512, 42527, 42538, 42539, 42606, 42725, 42999, 43009, 43011, - 43013, 43015, 43018, 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, - 43259, 43301, 43312, 43334, 43360, 43388, 43396, 43442, 43488, 43492, 43495, - 43503, 43514, 43518, 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43631, - 43633, 43638, 43642, 43695, 43697, 43709, 43712, 43714, 43739, 43740, 43744, - 43754, 43762, 43782, 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, - 43968, 44002, 44032, 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, - 64217, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64433, 64467, 64829, - 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65382, - 65391, 65393, 65437, 65440, 65470, 65474, 65479, 65482, 65487, 65490, 65495, - 65498, 65500, 37, 0, 48, 57, 1632, 1641, 1776, 1785, 1984, 1993, 2406, - 2415, 2534, 2543, 2662, 2671, 2790, 2799, 2918, 2927, 3046, 3055, 3174, - 3183, 3302, 3311, 3430, 3439, 3558, 3567, 3664, 3673, 3792, 3801, 3872, - 3881, 4160, 4169, 4240, 4249, 6112, 6121, 6160, 6169, 6470, 6479, 6608, - 6617, 6784, 6793, 6800, 6809, 6992, 7001, 7088, 7097, 7232, 7241, 7248, - 7257, 42528, 42537, 43216, 43225, 43264, 43273, 43472, 43481, 43504, 43513, - 43600, 43609, 44016, 44025, 65296, 65305, 133, 0, 5, 1, 0, 0, 0, 0, 7, - 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, - 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, - 0, 23, 1, 0, 0, 0, 1, 39, 1, 0, 0, 0, 3, 43, 1, 0, 0, 0, 5, 46, 1, 0, 0, - 0, 7, 48, 1, 0, 0, 0, 9, 50, 1, 0, 0, 0, 11, 54, 1, 0, 0, 0, 13, 68, 1, - 0, 0, 0, 15, 70, 1, 0, 0, 0, 17, 84, 1, 0, 0, 0, 19, 91, 1, 0, 0, 0, 21, - 96, 1, 0, 0, 0, 23, 102, 1, 0, 0, 0, 25, 109, 1, 0, 0, 0, 27, 111, 1, 0, - 0, 0, 29, 113, 1, 0, 0, 0, 31, 115, 1, 0, 0, 0, 33, 117, 1, 0, 0, 0, 35, - 119, 1, 0, 0, 0, 37, 121, 1, 0, 0, 0, 39, 40, 7, 0, 0, 0, 40, 41, 7, 1, - 0, 0, 41, 42, 7, 2, 0, 0, 42, 2, 1, 0, 0, 0, 43, 44, 7, 3, 0, 0, 44, 45, - 7, 2, 0, 0, 45, 4, 1, 0, 0, 0, 46, 47, 5, 40, 0, 0, 47, 6, 1, 0, 0, 0, - 48, 49, 5, 41, 0, 0, 49, 8, 1, 0, 0, 0, 50, 51, 7, 1, 0, 0, 51, 52, 7, - 4, 0, 0, 52, 53, 7, 5, 0, 0, 53, 10, 1, 0, 0, 0, 54, 55, 7, 6, 0, 0, 55, - 56, 7, 7, 0, 0, 56, 12, 1, 0, 0, 0, 57, 69, 5, 61, 0, 0, 58, 59, 5, 33, - 0, 0, 59, 69, 5, 61, 0, 0, 60, 69, 5, 126, 0, 0, 61, 62, 5, 62, 0, 0, 62, - 69, 5, 61, 0, 0, 63, 64, 5, 60, 0, 0, 64, 69, 5, 61, 0, 0, 65, 69, 7, 8, - 0, 0, 66, 69, 3, 1, 0, 0, 67, 69, 3, 3, 1, 0, 68, 57, 1, 0, 0, 0, 68, 58, - 1, 0, 0, 0, 68, 60, 1, 0, 0, 0, 68, 61, 1, 0, 0, 0, 68, 63, 1, 0, 0, 0, - 68, 65, 1, 0, 0, 0, 68, 66, 1, 0, 0, 0, 68, 67, 1, 0, 0, 0, 69, 14, 1, - 0, 0, 0, 70, 76, 5, 34, 0, 0, 71, 75, 8, 9, 0, 0, 72, 73, 5, 92, 0, 0, - 73, 75, 5, 34, 0, 0, 74, 71, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 75, 78, 1, - 0, 0, 0, 76, 74, 1, 0, 0, 0, 76, 77, 1, 0, 0, 0, 77, 79, 1, 0, 0, 0, 78, - 76, 1, 0, 0, 0, 79, 80, 5, 34, 0, 0, 80, 16, 1, 0, 0, 0, 81, 85, 3, 25, - 12, 0, 82, 85, 3, 37, 18, 0, 83, 85, 7, 10, 0, 0, 84, 81, 1, 0, 0, 0, 84, - 82, 1, 0, 0, 0, 84, 83, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 84, 1, 0, 0, - 0, 86, 87, 1, 0, 0, 0, 87, 18, 1, 0, 0, 0, 88, 92, 3, 25, 12, 0, 89, 92, - 3, 37, 18, 0, 90, 92, 7, 11, 0, 0, 91, 88, 1, 0, 0, 0, 91, 89, 1, 0, 0, - 0, 91, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 91, 1, 0, 0, 0, 93, 94, - 1, 0, 0, 0, 94, 20, 1, 0, 0, 0, 95, 97, 7, 12, 0, 0, 96, 95, 1, 0, 0, 0, - 97, 98, 1, 0, 0, 0, 98, 96, 1, 0, 0, 0, 98, 99, 1, 0, 0, 0, 99, 100, 1, - 0, 0, 0, 100, 101, 6, 10, 0, 0, 101, 22, 1, 0, 0, 0, 102, 103, 9, 0, 0, - 0, 103, 24, 1, 0, 0, 0, 104, 110, 3, 27, 13, 0, 105, 110, 3, 29, 14, 0, - 106, 110, 3, 31, 15, 0, 107, 110, 3, 33, 16, 0, 108, 110, 3, 35, 17, 0, - 109, 104, 1, 0, 0, 0, 109, 105, 1, 0, 0, 0, 109, 106, 1, 0, 0, 0, 109, - 107, 1, 0, 0, 0, 109, 108, 1, 0, 0, 0, 110, 26, 1, 0, 0, 0, 111, 112, 7, - 13, 0, 0, 112, 28, 1, 0, 0, 0, 113, 114, 7, 14, 0, 0, 114, 30, 1, 0, 0, - 0, 115, 116, 7, 15, 0, 0, 116, 32, 1, 0, 0, 0, 117, 118, 7, 16, 0, 0, 118, - 34, 1, 0, 0, 0, 119, 120, 7, 17, 0, 0, 120, 36, 1, 0, 0, 0, 121, 122, 7, - 18, 0, 0, 122, 38, 1, 0, 0, 0, 10, 0, 68, 74, 76, 84, 86, 91, 93, 98, 109, - 1, 6, 0, 0, + 2, 0, 82, 82, 114, 114, 2, 0, 60, 60, 62, 62, 1, 0, 34, 34, 6, 0, 39, 39, + 43, 43, 45, 47, 58, 58, 64, 64, 95, 95, 3, 0, 9, 10, 13, 13, 32, 32, 82, + 0, 65, 90, 192, 214, 216, 222, 256, 310, 313, 327, 330, 381, 385, 386, + 388, 395, 398, 401, 403, 404, 406, 408, 412, 413, 415, 416, 418, 425, 428, + 435, 437, 444, 452, 461, 463, 475, 478, 494, 497, 500, 502, 504, 506, 562, + 570, 571, 573, 574, 577, 582, 584, 590, 880, 882, 886, 895, 902, 906, 908, + 929, 931, 939, 975, 980, 984, 1006, 1012, 1015, 1017, 1018, 1021, 1071, + 1120, 1152, 1162, 1229, 1232, 1326, 1329, 1366, 4256, 4293, 4295, 4301, + 7680, 7828, 7838, 7934, 7944, 7951, 7960, 7965, 7976, 7983, 7992, 7999, + 8008, 8013, 8025, 8031, 8040, 8047, 8120, 8123, 8136, 8139, 8152, 8155, + 8168, 8172, 8184, 8187, 8450, 8455, 8459, 8461, 8464, 8466, 8469, 8477, + 8484, 8493, 8496, 8499, 8510, 8511, 8517, 8579, 11264, 11310, 11360, 11364, + 11367, 11376, 11378, 11381, 11390, 11392, 11394, 11490, 11499, 11501, 11506, + 42560, 42562, 42604, 42624, 42650, 42786, 42798, 42802, 42862, 42873, 42886, + 42891, 42893, 42896, 42898, 42902, 42925, 42928, 42929, 65313, 65338, 81, + 0, 97, 122, 181, 246, 248, 255, 257, 375, 378, 384, 387, 389, 392, 402, + 405, 411, 414, 417, 419, 421, 424, 429, 432, 436, 438, 447, 454, 460, 462, + 499, 501, 505, 507, 569, 572, 578, 583, 659, 661, 687, 881, 883, 887, 893, + 912, 974, 976, 977, 981, 983, 985, 1011, 1013, 1119, 1121, 1153, 1163, + 1215, 1218, 1327, 1377, 1415, 7424, 7467, 7531, 7543, 7545, 7578, 7681, + 7837, 7839, 7943, 7952, 7957, 7968, 7975, 7984, 7991, 8000, 8005, 8016, + 8023, 8032, 8039, 8048, 8061, 8064, 8071, 8080, 8087, 8096, 8103, 8112, + 8116, 8118, 8119, 8126, 8132, 8134, 8135, 8144, 8147, 8150, 8151, 8160, + 8167, 8178, 8180, 8182, 8183, 8458, 8467, 8495, 8505, 8508, 8509, 8518, + 8521, 8526, 8580, 11312, 11358, 11361, 11372, 11377, 11387, 11393, 11500, + 11502, 11507, 11520, 11557, 11559, 11565, 42561, 42605, 42625, 42651, 42787, + 42801, 42803, 42872, 42874, 42876, 42879, 42887, 42892, 42894, 42897, 42901, + 42903, 42921, 43002, 43866, 43876, 43877, 64256, 64262, 64275, 64279, 65345, + 65370, 6, 0, 453, 459, 498, 8079, 8088, 8095, 8104, 8111, 8124, 8140, 8188, + 8188, 33, 0, 688, 705, 710, 721, 736, 740, 748, 750, 884, 890, 1369, 1600, + 1765, 1766, 2036, 2037, 2042, 2074, 2084, 2088, 2417, 3654, 3782, 4348, + 6103, 6211, 6823, 7293, 7468, 7530, 7544, 7615, 8305, 8319, 8336, 8348, + 11388, 11389, 11631, 11823, 12293, 12341, 12347, 12542, 40981, 42237, 42508, + 42623, 42652, 42653, 42775, 42783, 42864, 42888, 43000, 43001, 43471, 43494, + 43632, 43741, 43763, 43764, 43868, 43871, 65392, 65439, 234, 0, 170, 186, + 443, 451, 660, 1514, 1520, 1522, 1568, 1599, 1601, 1610, 1646, 1647, 1649, + 1747, 1749, 1788, 1791, 1808, 1810, 1839, 1869, 1957, 1969, 2026, 2048, + 2069, 2112, 2136, 2208, 2226, 2308, 2361, 2365, 2384, 2392, 2401, 2418, + 2432, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2489, 2493, + 2510, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, + 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, + 2676, 2693, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, + 2745, 2749, 2768, 2784, 2785, 2821, 2828, 2831, 2832, 2835, 2856, 2858, + 2864, 2866, 2867, 2869, 2873, 2877, 2913, 2929, 2947, 2949, 2954, 2958, + 2960, 2962, 2965, 2969, 2970, 2972, 2986, 2990, 3001, 3024, 3084, 3086, + 3088, 3090, 3112, 3114, 3129, 3133, 3212, 3214, 3216, 3218, 3240, 3242, + 3251, 3253, 3257, 3261, 3294, 3296, 3297, 3313, 3314, 3333, 3340, 3342, + 3344, 3346, 3386, 3389, 3406, 3424, 3425, 3450, 3455, 3461, 3478, 3482, + 3505, 3507, 3515, 3517, 3526, 3585, 3632, 3634, 3635, 3648, 3653, 3713, + 3714, 3716, 3722, 3725, 3735, 3737, 3743, 3745, 3747, 3749, 3751, 3754, + 3755, 3757, 3760, 3762, 3763, 3773, 3780, 3804, 3807, 3840, 3911, 3913, + 3948, 3976, 3980, 4096, 4138, 4159, 4181, 4186, 4189, 4193, 4208, 4213, + 4225, 4238, 4346, 4349, 4680, 4682, 4685, 4688, 4694, 4696, 4701, 4704, + 4744, 4746, 4749, 4752, 4784, 4786, 4789, 4792, 4798, 4800, 4805, 4808, + 4822, 4824, 4880, 4882, 4885, 4888, 4954, 4992, 5007, 5024, 5108, 5121, + 5740, 5743, 5759, 5761, 5786, 5792, 5866, 5873, 5880, 5888, 5900, 5902, + 5905, 5920, 5937, 5952, 5969, 5984, 5996, 5998, 6000, 6016, 6067, 6108, + 6210, 6212, 6263, 6272, 6312, 6314, 6389, 6400, 6430, 6480, 6509, 6512, + 6516, 6528, 6571, 6593, 6599, 6656, 6678, 6688, 6740, 6917, 6963, 6981, + 6987, 7043, 7072, 7086, 7087, 7098, 7141, 7168, 7203, 7245, 7247, 7258, + 7287, 7401, 7404, 7406, 7409, 7413, 7414, 8501, 8504, 11568, 11623, 11648, + 11670, 11680, 11686, 11688, 11694, 11696, 11702, 11704, 11710, 11712, 11718, + 11720, 11726, 11728, 11734, 11736, 11742, 12294, 12348, 12353, 12438, 12447, + 12538, 12543, 12589, 12593, 12686, 12704, 12730, 12784, 12799, 13312, 19893, + 19968, 40908, 40960, 40980, 40982, 42124, 42192, 42231, 42240, 42507, 42512, + 42527, 42538, 42539, 42606, 42725, 42999, 43009, 43011, 43013, 43015, 43018, + 43020, 43042, 43072, 43123, 43138, 43187, 43250, 43255, 43259, 43301, 43312, + 43334, 43360, 43388, 43396, 43442, 43488, 43492, 43495, 43503, 43514, 43518, + 43520, 43560, 43584, 43586, 43588, 43595, 43616, 43631, 43633, 43638, 43642, + 43695, 43697, 43709, 43712, 43714, 43739, 43740, 43744, 43754, 43762, 43782, + 43785, 43790, 43793, 43798, 43808, 43814, 43816, 43822, 43968, 44002, 44032, + 55203, 55216, 55238, 55243, 55291, 63744, 64109, 64112, 64217, 64285, 64296, + 64298, 64310, 64312, 64316, 64318, 64433, 64467, 64829, 64848, 64911, 64914, + 64967, 65008, 65019, 65136, 65140, 65142, 65276, 65382, 65391, 65393, 65437, + 65440, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500, 37, + 0, 48, 57, 1632, 1641, 1776, 1785, 1984, 1993, 2406, 2415, 2534, 2543, + 2662, 2671, 2790, 2799, 2918, 2927, 3046, 3055, 3174, 3183, 3302, 3311, + 3430, 3439, 3558, 3567, 3664, 3673, 3792, 3801, 3872, 3881, 4160, 4169, + 4240, 4249, 6112, 6121, 6160, 6169, 6470, 6479, 6608, 6617, 6784, 6793, + 6800, 6809, 6992, 7001, 7088, 7097, 7232, 7241, 7248, 7257, 42528, 42537, + 43216, 43225, 43264, 43273, 43472, 43481, 43504, 43513, 43600, 43609, 44016, + 44025, 65296, 65305, 149, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, + 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, + 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 1, + 43, 1, 0, 0, 0, 3, 47, 1, 0, 0, 0, 5, 51, 1, 0, 0, 0, 7, 58, 1, 0, 0, 0, + 9, 62, 1, 0, 0, 0, 11, 64, 1, 0, 0, 0, 13, 66, 1, 0, 0, 0, 15, 70, 1, 0, + 0, 0, 17, 84, 1, 0, 0, 0, 19, 86, 1, 0, 0, 0, 21, 100, 1, 0, 0, 0, 23, + 107, 1, 0, 0, 0, 25, 112, 1, 0, 0, 0, 27, 118, 1, 0, 0, 0, 29, 125, 1, + 0, 0, 0, 31, 127, 1, 0, 0, 0, 33, 129, 1, 0, 0, 0, 35, 131, 1, 0, 0, 0, + 37, 133, 1, 0, 0, 0, 39, 135, 1, 0, 0, 0, 41, 137, 1, 0, 0, 0, 43, 44, + 7, 0, 0, 0, 44, 45, 7, 1, 0, 0, 45, 46, 7, 2, 0, 0, 46, 2, 1, 0, 0, 0, + 47, 48, 7, 3, 0, 0, 48, 49, 7, 2, 0, 0, 49, 4, 1, 0, 0, 0, 50, 52, 3, 29, + 14, 0, 51, 50, 1, 0, 0, 0, 52, 53, 1, 0, 0, 0, 53, 51, 1, 0, 0, 0, 53, + 54, 1, 0, 0, 0, 54, 6, 1, 0, 0, 0, 55, 59, 3, 29, 14, 0, 56, 59, 3, 41, + 20, 0, 57, 59, 5, 95, 0, 0, 58, 55, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, + 57, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 58, 1, 0, 0, 0, 60, 61, 1, 0, 0, + 0, 61, 8, 1, 0, 0, 0, 62, 63, 5, 40, 0, 0, 63, 10, 1, 0, 0, 0, 64, 65, + 5, 41, 0, 0, 65, 12, 1, 0, 0, 0, 66, 67, 7, 1, 0, 0, 67, 68, 7, 4, 0, 0, + 68, 69, 7, 5, 0, 0, 69, 14, 1, 0, 0, 0, 70, 71, 7, 6, 0, 0, 71, 72, 7, + 7, 0, 0, 72, 16, 1, 0, 0, 0, 73, 85, 5, 61, 0, 0, 74, 75, 5, 33, 0, 0, + 75, 85, 5, 61, 0, 0, 76, 85, 5, 126, 0, 0, 77, 78, 5, 62, 0, 0, 78, 85, + 5, 61, 0, 0, 79, 80, 5, 60, 0, 0, 80, 85, 5, 61, 0, 0, 81, 85, 7, 8, 0, + 0, 82, 85, 3, 1, 0, 0, 83, 85, 3, 3, 1, 0, 84, 73, 1, 0, 0, 0, 84, 74, + 1, 0, 0, 0, 84, 76, 1, 0, 0, 0, 84, 77, 1, 0, 0, 0, 84, 79, 1, 0, 0, 0, + 84, 81, 1, 0, 0, 0, 84, 82, 1, 0, 0, 0, 84, 83, 1, 0, 0, 0, 85, 18, 1, + 0, 0, 0, 86, 92, 5, 34, 0, 0, 87, 91, 8, 9, 0, 0, 88, 89, 5, 92, 0, 0, + 89, 91, 5, 34, 0, 0, 90, 87, 1, 0, 0, 0, 90, 88, 1, 0, 0, 0, 91, 94, 1, + 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 93, 1, 0, 0, 0, 93, 95, 1, 0, 0, 0, 94, + 92, 1, 0, 0, 0, 95, 96, 5, 34, 0, 0, 96, 20, 1, 0, 0, 0, 97, 98, 3, 5, + 2, 0, 98, 99, 5, 46, 0, 0, 99, 101, 1, 0, 0, 0, 100, 97, 1, 0, 0, 0, 100, + 101, 1, 0, 0, 0, 101, 102, 1, 0, 0, 0, 102, 103, 3, 7, 3, 0, 103, 22, 1, + 0, 0, 0, 104, 108, 3, 29, 14, 0, 105, 108, 3, 41, 20, 0, 106, 108, 7, 10, + 0, 0, 107, 104, 1, 0, 0, 0, 107, 105, 1, 0, 0, 0, 107, 106, 1, 0, 0, 0, + 108, 109, 1, 0, 0, 0, 109, 107, 1, 0, 0, 0, 109, 110, 1, 0, 0, 0, 110, + 24, 1, 0, 0, 0, 111, 113, 7, 11, 0, 0, 112, 111, 1, 0, 0, 0, 113, 114, + 1, 0, 0, 0, 114, 112, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 116, 1, 0, + 0, 0, 116, 117, 6, 12, 0, 0, 117, 26, 1, 0, 0, 0, 118, 119, 9, 0, 0, 0, + 119, 28, 1, 0, 0, 0, 120, 126, 3, 31, 15, 0, 121, 126, 3, 33, 16, 0, 122, + 126, 3, 35, 17, 0, 123, 126, 3, 37, 18, 0, 124, 126, 3, 39, 19, 0, 125, + 120, 1, 0, 0, 0, 125, 121, 1, 0, 0, 0, 125, 122, 1, 0, 0, 0, 125, 123, + 1, 0, 0, 0, 125, 124, 1, 0, 0, 0, 126, 30, 1, 0, 0, 0, 127, 128, 7, 12, + 0, 0, 128, 32, 1, 0, 0, 0, 129, 130, 7, 13, 0, 0, 130, 34, 1, 0, 0, 0, + 131, 132, 7, 14, 0, 0, 132, 36, 1, 0, 0, 0, 133, 134, 7, 15, 0, 0, 134, + 38, 1, 0, 0, 0, 135, 136, 7, 16, 0, 0, 136, 40, 1, 0, 0, 0, 137, 138, 7, + 17, 0, 0, 138, 42, 1, 0, 0, 0, 12, 0, 53, 58, 60, 84, 90, 92, 100, 107, + 109, 114, 125, 1, 6, 0, 0, } deserializer := antlr.NewATNDeserializer(nil) staticData.atn = deserializer.Deserialize(staticData.serializedATN) @@ -239,7 +247,7 @@ const ( ContactQLLexerOR = 4 ContactQLLexerCOMPARATOR = 5 ContactQLLexerSTRING = 6 - ContactQLLexerNAME = 7 + ContactQLLexerPROPERTY = 7 ContactQLLexerTEXT = 8 ContactQLLexerWS = 9 ContactQLLexerERROR = 10 diff --git a/antlr/gen/contactql/contactql_parser.go b/antlr/gen/contactql/contactql_parser.go index 45de3fae8..20dffb20c 100644 --- a/antlr/gen/contactql/contactql_parser.go +++ b/antlr/gen/contactql/contactql_parser.go @@ -35,7 +35,7 @@ func contactqlParserInit() { "", "'('", "')'", } staticData.SymbolicNames = []string{ - "", "LPAREN", "RPAREN", "AND", "OR", "COMPARATOR", "STRING", "NAME", + "", "LPAREN", "RPAREN", "AND", "OR", "COMPARATOR", "STRING", "PROPERTY", "TEXT", "WS", "ERROR", } staticData.RuleNames = []string{ @@ -103,7 +103,7 @@ const ( ContactQLParserOR = 4 ContactQLParserCOMPARATOR = 5 ContactQLParserSTRING = 6 - ContactQLParserNAME = 7 + ContactQLParserPROPERTY = 7 ContactQLParserTEXT = 8 ContactQLParserWS = 9 ContactQLParserERROR = 10 @@ -371,8 +371,8 @@ func (s *ConditionContext) GetRuleContext() antlr.RuleContext { return s } -func (s *ConditionContext) NAME() antlr.TerminalNode { - return s.GetToken(ContactQLParserNAME, 0) +func (s *ConditionContext) PROPERTY() antlr.TerminalNode { + return s.GetToken(ContactQLParserPROPERTY, 0) } func (s *ConditionContext) COMPARATOR() antlr.TerminalNode { @@ -787,7 +787,7 @@ func (p *ContactQLParser) expression(_p int) (localctx IExpressionContext) { _prevctx = localctx { p.SetState(14) - p.Match(ContactQLParserNAME) + p.Match(ContactQLParserPROPERTY) if p.HasError() { // Recognition error - abort rule goto errorExit @@ -1044,8 +1044,8 @@ func (s *TextLiteralContext) GetRuleContext() antlr.RuleContext { return s } -func (s *TextLiteralContext) NAME() antlr.TerminalNode { - return s.GetToken(ContactQLParserNAME, 0) +func (s *TextLiteralContext) PROPERTY() antlr.TerminalNode { + return s.GetToken(ContactQLParserPROPERTY, 0) } func (s *TextLiteralContext) TEXT() antlr.TerminalNode { @@ -1084,12 +1084,12 @@ func (p *ContactQLParser) Literal() (localctx ILiteralContext) { } switch p.GetTokenStream().LA(1) { - case ContactQLParserNAME: + case ContactQLParserPROPERTY: localctx = NewTextLiteralContext(p, localctx) p.EnterOuterAlt(localctx, 1) { p.SetState(33) - p.Match(ContactQLParserNAME) + p.Match(ContactQLParserPROPERTY) if p.HasError() { // Recognition error - abort rule goto errorExit diff --git a/contactql/error.go b/contactql/error.go index 395955b6c..abf40571a 100644 --- a/contactql/error.go +++ b/contactql/error.go @@ -21,6 +21,7 @@ const ( ErrUnsupportedContains = "unsupported_contains" // `property` the property key ErrUnsupportedComparison = "unsupported_comparison" // `property` the property key, `operator` one of =>, <, >=, <= ErrUnsupportedSetCheck = "unsupported_setcheck" // `property` the property key, `operator` one of =, != + ErrUnknownPropertyType = "unknown_property_type" // `type` the property type ErrUnknownProperty = "unknown_property" // `property` the property key ErrRedactedURNs = "redacted_urns" ) diff --git a/contactql/es/query.go b/contactql/es/query.go index c27550845..bc0097e69 100644 --- a/contactql/es/query.go +++ b/contactql/es/query.go @@ -65,7 +65,7 @@ func conditionToElastic(env envs.Environment, resolver contactql.Resolver, mappe return fieldConditionToElastic(env, resolver, c) case contactql.PropertyTypeAttribute: return attributeConditionToElastic(env, resolver, mapper, c) - case contactql.PropertyTypeScheme: + case contactql.PropertyTypeURN: return schemeConditionToElastic(env, c) default: panic(fmt.Sprintf("unsupported property type: %s", c.PropertyType())) diff --git a/contactql/inspect.go b/contactql/inspect.go index 554246297..d558112fa 100644 --- a/contactql/inspect.go +++ b/contactql/inspect.go @@ -41,7 +41,7 @@ func Inspect(query *ContactQuery) *Inspection { addRef(assets.NewVariableGroupReference(c.value)) } } - case PropertyTypeScheme: + case PropertyTypeURN: schemes[c.propKey] = true case PropertyTypeField: if query.resolver != nil { diff --git a/contactql/parser.go b/contactql/parser.go index 208e4573e..5f1e62aa0 100644 --- a/contactql/parser.go +++ b/contactql/parser.go @@ -46,10 +46,10 @@ type PropertyType string const ( // PropertyTypeAttribute is builtin property - PropertyTypeAttribute PropertyType = "attribute" + PropertyTypeAttribute PropertyType = "attr" - // PropertyTypeScheme is a URN scheme - PropertyTypeScheme PropertyType = "scheme" + // PropertyTypeURN is a URN scheme + PropertyTypeURN PropertyType = "urn" // PropertyTypeField is a custom contact field PropertyTypeField PropertyType = "field" @@ -72,27 +72,27 @@ type QueryNode interface { // Condition represents a comparison between a keywed value on the contact and a provided value type Condition struct { - propKey string propType PropertyType + propKey string operator Operator value string } -func NewCondition(propKey string, propType PropertyType, operator Operator, value string) *Condition { +func NewCondition(propType PropertyType, propKey string, operator Operator, value string) *Condition { return &Condition{ - propKey: propKey, propType: propType, + propKey: propKey, operator: operator, value: value, } } -// PropertyKey returns the key for the property being queried -func (c *Condition) PropertyKey() string { return c.propKey } - // PropertyType returns the type (attribute, scheme, field) func (c *Condition) PropertyType() PropertyType { return c.propType } +// PropertyKey returns the key for the property being queried +func (c *Condition) PropertyKey() string { return c.propKey } + // Operator returns the type of comparison being made func (c *Condition) Operator() Operator { return c.operator } @@ -123,7 +123,7 @@ func (c *Condition) resolveValueType(resolver Resolver) assets.FieldType { switch c.propType { case PropertyTypeAttribute: return attributes[c.propKey] - case PropertyTypeScheme: + case PropertyTypeURN: return assets.FieldTypeText case PropertyTypeField: field := resolver.ResolveField(c.propKey) @@ -152,7 +152,7 @@ func (c *Condition) validate(env envs.Environment, resolver Resolver) error { if len(tokenizeNameValue(c.value)) == 0 { return NewQueryError(ErrInvalidPartialName, "contains operator on name requires token of minimum length %d", minNameTokenContainsLength).withExtra("min_token_length", strconv.Itoa(minNameTokenContainsLength)) } - } else if c.propKey == AttributeURN || c.propType == PropertyTypeScheme { + } else if c.propKey == AttributeURN || c.propType == PropertyTypeURN { if len(c.value) < minURNContainsLength { return NewQueryError(ErrInvalidPartialURN, "contains operator on URN requires value of minimum length %d", minURNContainsLength).withExtra("min_value_length", strconv.Itoa(minURNContainsLength)) } @@ -174,7 +174,7 @@ func (c *Condition) validate(env envs.Environment, resolver Resolver) error { return NewQueryError(ErrUnsupportedSetCheck, "can't check whether '%s' is set or not set", c.propKey).withExtra("property", c.propKey).withExtra("operator", string(c.operator)) } } else { - // check values are valid for the property type + // check values are valid for the value type if valueType == assets.FieldTypeNumber { _, err := c.ValueAsNumber() if err != nil { @@ -185,27 +185,31 @@ func (c *Condition) validate(env envs.Environment, resolver Resolver) error { if err != nil { return NewQueryError(ErrInvalidDate, "can't convert '%s' to a date", c.value).withExtra("value", c.value) } + } - } else if c.propKey == AttributeGroup && resolver != nil { - group := c.ValueAsGroup(resolver) - if group == nil { - return NewQueryError(ErrInvalidGroup, "'%s' is not a valid group name", c.value).withExtra("value", c.value) - } - } else if (c.propKey == AttributeFlow || c.propKey == AttributeHistory) && resolver != nil { - flow := c.ValueAsFlow(resolver) - if flow == nil { - return NewQueryError(ErrInvalidFlow, "'%s' is not a valid flow name", c.value).withExtra("value", c.value) - } - } else if c.propKey == AttributeStatus { - val := strings.ToLower(c.value) - if val != "active" && val != "blocked" && val != "stopped" && val != "archived" { - return NewQueryError(ErrInvalidStatus, "'%s' is not a valid contact status", c.value).withExtra("value", c.value) - } - } else if c.propKey == AttributeLanguage { - if c.value != "" { - _, err := i18n.ParseLanguage(c.value) - if err != nil { - return NewQueryError(ErrInvalidLanguage, "'%s' is not a valid language code", c.value).withExtra("value", c.value) + // for some text attributes, do some additional validation + if c.propType == PropertyTypeAttribute { + if c.propKey == AttributeGroup && resolver != nil { + group := c.ValueAsGroup(resolver) + if group == nil { + return NewQueryError(ErrInvalidGroup, "'%s' is not a valid group name", c.value).withExtra("value", c.value) + } + } else if (c.propKey == AttributeFlow || c.propKey == AttributeHistory) && resolver != nil { + flow := c.ValueAsFlow(resolver) + if flow == nil { + return NewQueryError(ErrInvalidFlow, "'%s' is not a valid flow name", c.value).withExtra("value", c.value) + } + } else if c.propKey == AttributeStatus { + val := strings.ToLower(c.value) + if val != "active" && val != "blocked" && val != "stopped" && val != "archived" { + return NewQueryError(ErrInvalidStatus, "'%s' is not a valid contact status", c.value).withExtra("value", c.value) + } + } else if c.propKey == AttributeLanguage { + if c.value != "" { + _, err := i18n.ParseLanguage(c.value) + if err != nil { + return NewQueryError(ErrInvalidLanguage, "'%s' is not a valid language code", c.value).withExtra("value", c.value) + } } } } diff --git a/contactql/parser_test.go b/contactql/parser_test.go index 22a4c8801..e9edb7405 100644 --- a/contactql/parser_test.go +++ b/contactql/parser_test.go @@ -17,6 +17,7 @@ func TestParseQuery(t *testing.T) { static.NewField("d66a7823-eada-40e5-9a3a-57239d4690bf", "gender", "Gender", assets.FieldTypeText), static.NewField("165def68-3216-4ebf-96bc-f6f1ee5bd966", "state", "State", assets.FieldTypeState), static.NewField("85baf5e1-b57a-46dc-a726-a84e8c4229c7", "dob", "DOB", assets.FieldTypeDatetime), + static.NewField("85baf5e1-b57a-46dc-a726-a84e8c4229c7", "language", "Language", assets.FieldTypeText), // conflicts with language attribute }, []assets.Flow{ static.NewFlow("f87fd7cd-e501-4394-9cff-62309af85138", "Registration", []byte(`{}`)), @@ -71,8 +72,9 @@ func TestParseQuery(t *testing.T) { {text: `language = spa`, parsed: `language = "spa"`, resolver: resolver}, {text: `Group IS U-Reporters`, parsed: `group = "U-Reporters"`, resolver: resolver}, {text: `CREATED_ON>27-01-2020`, parsed: `created_on > "27-01-2020"`, resolver: resolver}, + {text: `URN=ewok`, parsed: `urn = "ewok"`, resolver: resolver}, - // explicit conditions on URN + // explicit conditions on URN schemes {text: `tel=""`, parsed: `tel = ""`, resolver: resolver}, {text: `tel!=""`, parsed: `tel != ""`, resolver: resolver}, {text: `tel IS 233`, parsed: `tel = 233`, resolver: resolver}, @@ -80,26 +82,32 @@ func TestParseQuery(t *testing.T) { {text: `tel ~ 23`, err: "contains operator on URN requires value of minimum length 3", resolver: resolver}, {text: `mailto = user@example.com`, parsed: `mailto = "user@example.com"`, resolver: resolver}, {text: `MAILTO ~ user@example.com`, parsed: `mailto ~ "user@example.com"`, resolver: resolver}, - {text: `URN=ewok`, parsed: `urn = "ewok"`, resolver: resolver}, + {text: `urns.tel = 234`, parsed: `tel = 234`, resolver: resolver}, + {text: `URNS.MAILTO = user@example.com`, parsed: `mailto = "user@example.com"`, resolver: resolver}, + + // explicit conditions on URN attribute with URN redaction + {text: `URN=""`, parsed: `urn = ""`, redactURNs: true, resolver: resolver}, + {text: `URN!=""`, parsed: `urn != ""`, redactURNs: true, resolver: resolver}, + {text: `URN=ewok`, err: "cannot query on redacted URNs", redactURNs: true, resolver: resolver}, + {text: `URN!=ewok`, err: "cannot query on redacted URNs", redactURNs: true, resolver: resolver}, - // explicit conditions on URN with URN redaction + // explicit conditions on URN schemes with URN redaction {text: `tel=""`, parsed: `tel = ""`, redactURNs: true, resolver: resolver}, {text: `tel!=""`, parsed: `tel != ""`, redactURNs: true, resolver: resolver}, {text: `mailto=""`, parsed: `mailto = ""`, redactURNs: true, resolver: resolver}, {text: `mailto!=""`, parsed: `mailto != ""`, redactURNs: true, resolver: resolver}, - {text: `urn=""`, parsed: `urn = ""`, redactURNs: true, resolver: resolver}, - {text: `urn!=""`, parsed: `urn != ""`, redactURNs: true, resolver: resolver}, {text: `tel = 233`, err: "cannot query on redacted URNs", redactURNs: true, resolver: resolver}, {text: `tel ~ 233`, err: "cannot query on redacted URNs", redactURNs: true, resolver: resolver}, {text: `mailto = user@example.com`, err: "cannot query on redacted URNs", redactURNs: true, resolver: resolver}, {text: `MAILTO ~ user@example.com`, err: "cannot query on redacted URNs", redactURNs: true, resolver: resolver}, - {text: `URN=ewok`, err: "cannot query on redacted URNs", redactURNs: true, resolver: resolver}, // field conditions {text: `Age IS 18`, parsed: `age = 18`, resolver: resolver}, {text: `AGE != ""`, parsed: `age != ""`, resolver: resolver}, {text: `age ~ 34`, err: "contains conditions can only be used with name or URN values", resolver: resolver}, + {text: `FIELDS.AGE != "45"`, parsed: `age != 45`, resolver: resolver}, {text: `gender ~ M`, err: "contains conditions can only be used with name or URN values", resolver: resolver}, + {text: `fields.language = "EN"`, parsed: `language = "EN"`, resolver: resolver}, // lt/lte/gt/gte comparisons {text: `Age > "18"`, parsed: `age > 18`, resolver: resolver}, @@ -274,28 +282,40 @@ func TestParsingErrors(t *testing.T) { }{ { query: `$`, - errMsg: "mismatched input '$' expecting {'(', STRING, NAME, TEXT}", + errMsg: "mismatched input '$' expecting {'(', STRING, PROPERTY, TEXT}", errCode: "unexpected_token", errExtra: map[string]string{"token": "$"}, }, { query: `name = `, - errMsg: "mismatched input '' expecting {STRING, NAME, TEXT}", + errMsg: "mismatched input '' expecting {STRING, PROPERTY, TEXT}", errCode: "unexpected_token", errExtra: map[string]string{"token": ""}, }, { query: `name = "x`, - errMsg: "extraneous input '\"' expecting {STRING, NAME, TEXT}", + errMsg: "extraneous input '\"' expecting {STRING, PROPERTY, TEXT}", errCode: "", errExtra: nil, }, { query: `nam/e = "x"`, + errMsg: "mismatched input '=' expecting ", // because .name isn't valid NAME + errCode: "unexpected_token", + errExtra: map[string]string{"token": "="}, + }, + { + query: `name. = "x"`, errMsg: "mismatched input '=' expecting ", errCode: "unexpected_token", errExtra: map[string]string{"token": "="}, }, + { + query: `.name != "x"`, + errMsg: "mismatched input '!=' expecting ", + errCode: "unexpected_token", + errExtra: map[string]string{"token": "!="}, + }, { query: `age = XZ`, errMsg: "can't convert 'XZ' to a number", @@ -368,6 +388,12 @@ func TestParsingErrors(t *testing.T) { errCode: "unknown_property", errExtra: map[string]string{"property": "beers"}, }, + { + query: `xxx.age = 12`, + errMsg: "unknown property type 'xxx'", + errCode: "unknown_property_type", + errExtra: map[string]string{"type": "xxx"}, + }, } env := envs.NewBuilder().WithDefaultCountry("US").Build() @@ -445,29 +471,29 @@ func TestQueryBuilding(t *testing.T) { query string }{ { - node: contactql.NewCondition("age", contactql.PropertyTypeField, ">", "10"), + node: contactql.NewCondition(contactql.PropertyTypeField, "age", ">", "10"), query: "age > 10", }, { node: contactql.NewBoolCombination(contactql.BoolOperatorAnd, - contactql.NewCondition("age", contactql.PropertyTypeField, ">", "10"), - contactql.NewCondition("age", contactql.PropertyTypeField, "<", "20"), + contactql.NewCondition(contactql.PropertyTypeField, "age", ">", "10"), + contactql.NewCondition(contactql.PropertyTypeField, "age", "<", "20"), ), query: "age > 10 AND age < 20", }, { node: contactql.NewBoolCombination(contactql.BoolOperatorOr, - contactql.NewCondition("name", contactql.PropertyTypeField, "=", "bob"), + contactql.NewCondition(contactql.PropertyTypeField, "name", "=", "bob"), contactql.NewBoolCombination(contactql.BoolOperatorAnd, - contactql.NewCondition("age", contactql.PropertyTypeField, ">", "10"), - contactql.NewCondition("age", contactql.PropertyTypeField, "<", "20"), + contactql.NewCondition(contactql.PropertyTypeField, "age", ">", "10"), + contactql.NewCondition(contactql.PropertyTypeField, "age", "<", "20"), ), ), query: `name = "bob" OR (age > 10 AND age < 20)`, }, { node: contactql.NewBoolCombination(contactql.BoolOperatorAnd, - contactql.NewCondition("age", contactql.PropertyTypeField, ">", "10"), + contactql.NewCondition(contactql.PropertyTypeField, "age", ">", "10"), ), query: "age > 10", }, @@ -477,7 +503,7 @@ func TestQueryBuilding(t *testing.T) { }, { node: contactql.NewBoolCombination(contactql.BoolOperatorAnd, - contactql.NewCondition("name", contactql.PropertyTypeField, "=", "bob"), + contactql.NewCondition(contactql.PropertyTypeField, "name", "=", "bob"), contactql.NewBoolCombination(contactql.BoolOperatorAnd, contactql.NewBoolCombination(contactql.BoolOperatorAnd), ), diff --git a/contactql/visitor.go b/contactql/visitor.go index 08deb986a..c6da1f0fb 100644 --- a/contactql/visitor.go +++ b/contactql/visitor.go @@ -92,17 +92,17 @@ func (v *visitor) VisitImplicitCondition(ctx *gen.ImplicitConditionContext) any if v.env.RedactionPolicy() == envs.RedactionPolicyURNs { num, err := strconv.Atoi(value) if err == nil { - return NewCondition(AttributeID, PropertyTypeAttribute, OpEqual, strconv.Itoa(num)) + return NewCondition(PropertyTypeAttribute, AttributeID, OpEqual, strconv.Itoa(num)) } } else if asURN != urns.NilURN { scheme, path, _, _ := asURN.ToParts() - return NewCondition(scheme, PropertyTypeScheme, OpEqual, path) + return NewCondition(PropertyTypeURN, scheme, OpEqual, path) } else if implicitIsPhoneNumberRegex.MatchString(value) { value = cleanPhoneNumberRegex.ReplaceAllLiteralString(value, "") - return NewCondition(urns.Phone.Prefix, PropertyTypeScheme, OpContains, value) + return NewCondition(PropertyTypeURN, urns.Phone.Prefix, OpContains, value) } // convert to contains condition only if we have the right tokens, otherwise make equals check @@ -111,12 +111,12 @@ func (v *visitor) VisitImplicitCondition(ctx *gen.ImplicitConditionContext) any operator = OpEqual } - return NewCondition(AttributeName, PropertyTypeAttribute, operator, value) + return NewCondition(PropertyTypeAttribute, AttributeName, operator, value) } -// expression : NAME COMPARATOR literal +// expression : PROPERTY COMPARATOR literal func (v *visitor) VisitCondition(ctx *gen.ConditionContext) any { - propKey := strings.ToLower(ctx.NAME().GetText()) + propText := strings.ToLower(ctx.PROPERTY().GetText()) operatorText := strings.ToLower(ctx.COMPARATOR().GetText()) value := v.Visit(ctx.Literal()).(string) @@ -126,28 +126,46 @@ func (v *visitor) VisitCondition(ctx *gen.ConditionContext) any { } var propType PropertyType - - // first try to match a fixed attribute - _, isAttribute := attributes[propKey] - if isAttribute { - propType = PropertyTypeAttribute - - if propKey == AttributeURN && v.env.RedactionPolicy() == envs.RedactionPolicyURNs && value != "" { - v.addError(NewQueryError(ErrRedactedURNs, "cannot query on redacted URNs")) - } - - } else if urns.IsValidScheme(propKey) { - // second try to match a URN scheme - propType = PropertyTypeScheme - - if v.env.RedactionPolicy() == envs.RedactionPolicyURNs && value != "" { - v.addError(NewQueryError(ErrRedactedURNs, "cannot query on redacted URNs")) + var propKey string + + // check if property type is specified as prefix + if strings.Contains(propText, ".") { + parts := strings.SplitN(propText, ".", 2) + + if parts[0] == "fields" { + propType = PropertyTypeField + propKey = parts[1] + } else if parts[0] == "urns" { + propType = PropertyTypeURN + propKey = parts[1] + } else { + v.addError(NewQueryError(ErrUnknownPropertyType, "unknown property type '%s'", parts[0]).withExtra("type", parts[0])) } } else { - propType = PropertyTypeField + propKey = propText + + // first try to match a fixed attribute + _, isAttribute := attributes[propKey] + if isAttribute { + propType = PropertyTypeAttribute + + if propKey == AttributeURN && v.env.RedactionPolicy() == envs.RedactionPolicyURNs && value != "" { + v.addError(NewQueryError(ErrRedactedURNs, "cannot query on redacted URNs")) + } + + } else if urns.IsValidScheme(propKey) { + // second try to match a URN scheme + propType = PropertyTypeURN + + if v.env.RedactionPolicy() == envs.RedactionPolicyURNs && value != "" { + v.addError(NewQueryError(ErrRedactedURNs, "cannot query on redacted URNs")) + } + } else { + propType = PropertyTypeField + } } - return NewCondition(propKey, propType, operator, value) + return NewCondition(propType, propKey, operator, value) } // expression : expression AND expression diff --git a/excellent/functions/builtin.go b/excellent/functions/builtin.go index 9db17eb0d..3e7e37b2e 100644 --- a/excellent/functions/builtin.go +++ b/excellent/functions/builtin.go @@ -2082,7 +2082,7 @@ func IsError(env envs.Environment, value types.XValue) types.XValue { // // It will return an error if it is passed an item which isn't countable. // -// @(count(contact.fields)) -> 6 +// @(count(contact.fields)) -> 7 // @(count(array())) -> 0 // @(count(array("a", "b", "c"))) -> 3 // @(count(1234)) -> ERROR diff --git a/flows/contact.go b/flows/contact.go index 48885f951..4a68ebeb7 100644 --- a/flows/contact.go +++ b/flows/contact.go @@ -523,7 +523,7 @@ func (c *Contact) QueryProperty(env envs.Environment, key string, propType conta default: return nil } - } else if propType == contactql.PropertyTypeScheme { + } else if propType == contactql.PropertyTypeURN { urnsWithScheme := c.urns.WithScheme(key) vals := make([]any, len(urnsWithScheme)) for i := range urnsWithScheme { diff --git a/flows/contact_test.go b/flows/contact_test.go index 6f230ec06..0d8bfd768 100644 --- a/flows/contact_test.go +++ b/flows/contact_test.go @@ -394,7 +394,8 @@ func TestContactQuery(t *testing.T) { "name": "Ben Haggerty", "fields": { "gender": {"text": "Male"}, - "age": {"text": "39!", "number": 39} + "age": {"text": "39!", "number": 39}, + "language": {"text": "en"} }, "groups": [ {"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Testers"}, @@ -507,6 +508,10 @@ func TestContactQuery(t *testing.T) { {`age = 60`, envs.RedactionPolicyNone, false, ""}, {`age != 60`, envs.RedactionPolicyNone, true, ""}, + // field with key that conflicts with attribute has to be prefixed + {`fields.language = EN`, envs.RedactionPolicyNone, true, ""}, + {`fields.language = FR`, envs.RedactionPolicyNone, false, ""}, + // check querying on a field that isn't set for this contact {`activation_token = ""`, envs.RedactionPolicyNone, true, ""}, {`activation_token != ""`, envs.RedactionPolicyNone, false, ""}, diff --git a/flows/engine/testdata/templates.json b/flows/engine/testdata/templates.json index 6b5c20e7e..597a5c91f 100644 --- a/flows/engine/testdata/templates.json +++ b/flows/engine/testdata/templates.json @@ -170,7 +170,7 @@ }, { "template": "@(count(contact.fields))", - "output": "6" + "output": "7" }, { "template": "@fields", @@ -202,7 +202,7 @@ }, { "template": "@(count(fields))", - "output": "6" + "output": "7" }, { "template": "@input", @@ -387,6 +387,7 @@ "age": 23, "gender": "Male", "join_date": "2017-12-02T00:00:00.000000-02:00", + "language": null, "not_set": null, "state": null } @@ -421,6 +422,7 @@ "age": 23, "gender": "Male", "join_date": "2017-12-02T00:00:00.000000-02:00", + "language": null, "not_set": null, "state": null }, @@ -500,6 +502,7 @@ "age": 23, "gender": "Male", "join_date": "2017-12-02T00:00:00.000000-02:00", + "language": null, "not_set": null, "state": null }, @@ -720,6 +723,7 @@ "age": 23, "gender": "Male", "join_date": "2017-12-02T00:00:00.000000-02:00", + "language": null, "not_set": null, "state": null }, @@ -768,6 +772,7 @@ "age": 23, "gender": "Male", "join_date": "2017-12-02T00:00:00.000000-02:00", + "language": null, "not_set": null, "state": null }, @@ -841,6 +846,7 @@ "age": 33, "gender": "Female", "join_date": null, + "language": null, "not_set": null, "state": null }, @@ -864,6 +870,7 @@ "age": 33, "gender": "Female", "join_date": null, + "language": null, "not_set": null, "state": null }, diff --git a/flows/field_test.go b/flows/field_test.go index d577c544d..f39efc06d 100644 --- a/flows/field_test.go +++ b/flows/field_test.go @@ -48,6 +48,7 @@ func TestFieldValues(t *testing.T) { "join_date": nil, "state": nil, "not_set": nil, + "language": nil, }), flows.Context(env, fieldVals)) } diff --git a/flows/runs/run_test.go b/flows/runs/run_test.go index e9acfe314..da403de85 100644 --- a/flows/runs/run_test.go +++ b/flows/runs/run_test.go @@ -187,11 +187,11 @@ func TestRunContext(t *testing.T) { {`@resume.type`, "msg"}, { `@(json(contact.fields))`, - `{"activation_token":"AACC55","age":23,"gender":"Male","join_date":"2017-12-02T00:00:00.000000-02:00","not_set":null,"state":null}`, + `{"activation_token":"AACC55","age":23,"gender":"Male","join_date":"2017-12-02T00:00:00.000000-02:00","language":null,"not_set":null,"state":null}`, }, { `@(json(fields))`, - `{"activation_token":"AACC55","age":23,"gender":"Male","join_date":"2017-12-02T00:00:00.000000-02:00","not_set":null,"state":null}`, + `{"activation_token":"AACC55","age":23,"gender":"Male","join_date":"2017-12-02T00:00:00.000000-02:00","language":null,"not_set":null,"state":null}`, }, { `@(json(contact.urns))`, @@ -219,7 +219,7 @@ func TestRunContext(t *testing.T) { }, { `@(json(parent.fields))`, - `{"activation_token":null,"age":33,"gender":"Female","join_date":null,"not_set":null,"state":null}`, + `{"activation_token":null,"age":33,"gender":"Female","join_date":null,"language":null,"not_set":null,"state":null}`, }, } diff --git a/test/session.go b/test/session.go index 3dc458e49..e0a566a81 100644 --- a/test/session.go +++ b/test/session.go @@ -239,7 +239,8 @@ var sessionAssets = `{ {"uuid": "6c86d5ab-3fd9-4a5c-a5b6-48168b016747", "key": "join_date", "name": "Join Date", "type": "datetime"}, {"uuid": "c88d2640-d124-438a-b666-5ec53a353dcd", "key": "activation_token", "name": "Activation Token", "type": "text"}, {"uuid": "ab9c0631-d8cd-4e77-a5a2-66a8b077e385", "key": "state", "name": "State", "type": "state"}, - {"uuid": "3bfc3908-a402-48ea-841c-b73b5ef3a254", "key": "not_set", "name": "Not set", "type": "text"} + {"uuid": "3bfc3908-a402-48ea-841c-b73b5ef3a254", "key": "not_set", "name": "Not set", "type": "text"}, + {"uuid": "3bfc3908-a402-48ea-841c-b73b5ef3a254", "key": "language", "name": "Language (Conflicts)", "type": "text"} ], "groups": [ {"uuid": "b7cf0d83-f1c9-411c-96fd-c511a4cfa86d", "name": "Testers"},