diff --git a/zcl/zclsyntax/scan_tokens.go b/zcl/zclsyntax/scan_tokens.go index 154bec8..45a1bad 100644 --- a/zcl/zclsyntax/scan_tokens.go +++ b/zcl/zclsyntax/scan_tokens.go @@ -12,9 +12,14 @@ var _zcltok_actions []byte = []byte{ 0, 1, 0, 1, 1, 1, 2, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, - 1, 14, 1, 15, 1, 16, 1, 17, - 1, 18, 1, 19, 1, 20, 1, 21, - 1, 22, 2, 2, 3, 2, 2, 4, + 1, 14, 1, 17, 1, 18, 1, 19, + 1, 20, 1, 21, 1, 22, 1, 23, + 1, 24, 1, 25, 1, 26, 1, 27, + 1, 28, 1, 29, 1, 30, 1, 31, + 1, 32, 1, 33, 1, 34, 1, 35, + 1, 36, 1, 37, 1, 38, 2, 2, + 3, 2, 2, 4, 2, 2, 15, 2, + 2, 16, } var _zcltok_key_offsets []int16 = []int16{ @@ -82,18 +87,21 @@ var _zcltok_key_offsets []int16 = []int16{ 3163, 3181, 3182, 3192, 3193, 3202, 3210, 3212, 3215, 3217, 3219, 3221, 3226, 3239, 3243, 3258, 3287, 3298, 3300, 3304, 3308, 3313, 3317, 3319, - 3326, 3330, 3338, 3342, 3411, 3412, 3413, 3414, - 3415, 3420, 3421, 3422, 3465, 3466, 3468, 3473, - 3477, 3477, 3479, 3481, 3492, 3502, 3510, 3511, - 3513, 3514, 3518, 3522, 3532, 3536, 3543, 3554, - 3561, 3565, 3571, 3582, 3614, 3663, 3678, 3693, - 3698, 3700, 3705, 3737, 3745, 3747, 3769, 3791, + 3326, 3330, 3338, 3342, 3343, 3345, 3347, 3349, + 3350, 3351, 3422, 3423, 3424, 3425, 3426, 3431, + 3432, 3433, 3476, 3477, 3478, 3480, 3485, 3489, + 3489, 3491, 3493, 3504, 3514, 3522, 3523, 3525, + 3526, 3530, 3534, 3544, 3548, 3555, 3566, 3573, + 3577, 3583, 3594, 3626, 3675, 3690, 3705, 3710, + 3712, 3717, 3749, 3757, 3759, 3781, 3803, 3805, + 3819, 3833, 3846, 3855, 3867, 3879, 3893, 3894, + 3895, 3897, 3899, } var _zcltok_trans_keys []byte = []byte{ 43, 45, 48, 57, 48, 57, 170, 181, 183, 186, 128, 150, 152, 182, 184, 255, - 192, 255, 0, 127, 173, 130, 133, 146, + 192, 255, 128, 255, 173, 130, 133, 146, 159, 165, 171, 175, 255, 181, 190, 184, 185, 192, 255, 140, 134, 138, 142, 161, 163, 255, 182, 130, 136, 137, 176, 151, @@ -366,7 +374,7 @@ var _zcltok_trans_keys []byte = []byte{ 128, 163, 164, 191, 128, 140, 141, 143, 144, 153, 154, 189, 190, 191, 128, 136, 137, 191, 173, 128, 168, 169, 177, 178, - 180, 181, 182, 183, 191, 128, 255, 192, + 180, 181, 182, 183, 191, 0, 127, 192, 255, 150, 151, 158, 159, 152, 154, 156, 158, 134, 135, 142, 143, 190, 191, 192, 255, 181, 189, 191, 128, 190, 133, 181, @@ -508,64 +516,77 @@ var _zcltok_trans_keys []byte = []byte{ 191, 181, 191, 192, 255, 158, 159, 186, 128, 185, 187, 191, 192, 255, 162, 191, 192, 255, 160, 168, 128, 159, 161, 167, - 169, 191, 158, 191, 192, 255, 9, 10, - 32, 33, 38, 44, 60, 62, 64, 92, - 95, 124, 127, 194, 195, 198, 199, 203, - 204, 205, 206, 207, 210, 212, 213, 214, - 215, 216, 217, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 233, 234, 237, - 238, 239, 240, 0, 39, 40, 47, 48, - 57, 58, 63, 65, 90, 91, 96, 97, - 122, 123, 126, 192, 193, 196, 218, 229, - 236, 241, 247, 9, 32, 61, 38, 46, - 69, 101, 48, 57, 61, 61, 95, 194, - 195, 198, 199, 203, 204, 205, 206, 207, - 210, 212, 213, 214, 215, 216, 217, 219, - 220, 221, 222, 223, 224, 225, 226, 227, - 228, 233, 234, 237, 239, 240, 243, 48, - 57, 65, 90, 97, 122, 196, 218, 229, - 236, 124, 128, 191, 170, 181, 186, 128, - 191, 151, 183, 128, 255, 192, 255, 0, - 127, 173, 130, 133, 146, 159, 165, 171, - 175, 191, 192, 255, 181, 190, 128, 175, - 176, 183, 184, 185, 186, 191, 134, 139, - 141, 162, 128, 135, 136, 255, 182, 130, - 137, 176, 151, 152, 154, 160, 136, 191, - 192, 255, 128, 143, 144, 170, 171, 175, - 176, 178, 179, 191, 128, 159, 160, 191, - 176, 128, 138, 139, 173, 174, 255, 148, - 150, 164, 167, 173, 176, 185, 189, 190, - 192, 255, 144, 128, 145, 146, 175, 176, - 191, 128, 140, 141, 255, 166, 176, 178, - 191, 192, 255, 186, 128, 137, 138, 170, - 171, 179, 180, 181, 182, 191, 160, 161, - 162, 164, 165, 166, 167, 168, 169, 170, - 171, 172, 173, 174, 175, 176, 177, 178, - 179, 180, 181, 182, 183, 184, 185, 186, - 187, 188, 189, 190, 128, 191, 128, 129, - 130, 131, 137, 138, 139, 140, 141, 142, - 143, 144, 153, 154, 155, 156, 157, 158, - 159, 160, 161, 162, 163, 164, 165, 166, + 169, 191, 158, 191, 192, 255, 123, 128, + 191, 128, 191, 128, 191, 123, 123, 9, + 10, 32, 33, 34, 38, 44, 60, 62, + 64, 92, 95, 123, 124, 125, 126, 127, + 194, 195, 198, 199, 203, 204, 205, 206, + 207, 210, 212, 213, 214, 215, 216, 217, + 219, 220, 221, 222, 223, 224, 225, 226, + 227, 228, 233, 234, 237, 238, 239, 240, + 0, 39, 40, 47, 48, 57, 58, 63, + 65, 90, 91, 96, 97, 122, 192, 193, + 196, 218, 229, 236, 241, 247, 9, 32, + 61, 38, 46, 69, 101, 48, 57, 61, + 61, 95, 194, 195, 198, 199, 203, 204, + 205, 206, 207, 210, 212, 213, 214, 215, + 216, 217, 219, 220, 221, 222, 223, 224, + 225, 226, 227, 228, 233, 234, 237, 239, + 240, 243, 48, 57, 65, 90, 97, 122, + 196, 218, 229, 236, 124, 125, 128, 191, + 170, 181, 186, 128, 191, 151, 183, 128, + 255, 192, 255, 0, 127, 173, 130, 133, + 146, 159, 165, 171, 175, 191, 192, 255, + 181, 190, 128, 175, 176, 183, 184, 185, + 186, 191, 134, 139, 141, 162, 128, 135, + 136, 255, 182, 130, 137, 176, 151, 152, + 154, 160, 136, 191, 192, 255, 128, 143, + 144, 170, 171, 175, 176, 178, 179, 191, + 128, 159, 160, 191, 176, 128, 138, 139, + 173, 174, 255, 148, 150, 164, 167, 173, + 176, 185, 189, 190, 192, 255, 144, 128, + 145, 146, 175, 176, 191, 128, 140, 141, + 255, 166, 176, 178, 191, 192, 255, 186, + 128, 137, 138, 170, 171, 179, 180, 181, + 182, 191, 160, 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, - 175, 176, 177, 178, 179, 180, 182, 183, - 184, 188, 189, 190, 191, 132, 187, 129, - 130, 132, 133, 134, 176, 177, 178, 179, - 180, 181, 182, 183, 128, 191, 128, 129, - 130, 131, 132, 133, 134, 135, 144, 136, - 143, 145, 191, 192, 255, 182, 183, 184, - 128, 191, 128, 191, 191, 128, 190, 192, - 255, 128, 146, 147, 148, 152, 153, 154, - 155, 156, 158, 159, 160, 161, 162, 163, - 164, 165, 166, 167, 168, 169, 170, 171, - 172, 173, 174, 175, 176, 129, 191, 192, - 255, 158, 159, 128, 157, 160, 191, 192, - 255, 128, 191, 164, 169, 171, 172, 173, - 174, 175, 180, 181, 182, 183, 184, 185, - 187, 188, 189, 190, 191, 128, 163, 165, - 186, 144, 145, 146, 147, 148, 150, 151, - 152, 155, 157, 158, 160, 170, 171, 172, - 175, 128, 159, 161, 169, 173, 191, 128, - 191, + 175, 176, 177, 178, 179, 180, 181, 182, + 183, 184, 185, 186, 187, 188, 189, 190, + 128, 191, 128, 129, 130, 131, 137, 138, + 139, 140, 141, 142, 143, 144, 153, 154, + 155, 156, 157, 158, 159, 160, 161, 162, + 163, 164, 165, 166, 167, 168, 169, 170, + 171, 172, 173, 174, 175, 176, 177, 178, + 179, 180, 182, 183, 184, 188, 189, 190, + 191, 132, 187, 129, 130, 132, 133, 134, + 176, 177, 178, 179, 180, 181, 182, 183, + 128, 191, 128, 129, 130, 131, 132, 133, + 134, 135, 144, 136, 143, 145, 191, 192, + 255, 182, 183, 184, 128, 191, 128, 191, + 191, 128, 190, 192, 255, 128, 146, 147, + 148, 152, 153, 154, 155, 156, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, + 168, 169, 170, 171, 172, 173, 174, 175, + 176, 129, 191, 192, 255, 158, 159, 128, + 157, 160, 191, 192, 255, 128, 191, 164, + 169, 171, 172, 173, 174, 175, 180, 181, + 182, 183, 184, 185, 187, 188, 189, 190, + 191, 128, 163, 165, 186, 144, 145, 146, + 147, 148, 150, 151, 152, 155, 157, 158, + 160, 170, 171, 172, 175, 128, 159, 161, + 169, 173, 191, 128, 191, 33, 34, 36, + 92, 128, 191, 192, 223, 224, 239, 240, + 247, 248, 255, 33, 34, 36, 92, 128, + 191, 192, 223, 224, 239, 240, 247, 248, + 255, 33, 36, 92, 128, 191, 192, 223, + 224, 239, 240, 247, 248, 255, 33, 36, + 92, 192, 223, 224, 239, 240, 247, 33, + 34, 36, 92, 192, 223, 224, 239, 240, + 247, 248, 255, 33, 34, 36, 92, 128, + 223, 224, 239, 240, 247, 248, 255, 33, + 34, 36, 92, 128, 191, 192, 223, 224, + 239, 240, 247, 248, 255, 126, 126, 128, + 191, 128, 191, 128, 191, } var _zcltok_single_lengths []byte = []byte{ @@ -633,12 +654,15 @@ var _zcltok_single_lengths []byte = []byte{ 12, 1, 4, 1, 5, 2, 0, 3, 2, 2, 2, 1, 7, 0, 7, 17, 3, 0, 2, 0, 3, 0, 0, 1, - 0, 2, 0, 45, 1, 1, 1, 1, - 3, 1, 1, 33, 1, 0, 3, 2, - 0, 0, 0, 1, 2, 4, 1, 0, - 1, 0, 0, 0, 0, 1, 1, 1, - 0, 0, 1, 30, 47, 13, 9, 3, - 0, 1, 28, 2, 0, 18, 16, 0, + 0, 2, 0, 1, 0, 0, 0, 1, + 1, 49, 1, 1, 1, 1, 3, 1, + 1, 33, 1, 1, 0, 3, 2, 0, + 0, 0, 1, 2, 4, 1, 0, 1, + 0, 0, 0, 0, 1, 1, 1, 0, + 0, 1, 30, 47, 13, 9, 3, 0, + 1, 28, 2, 0, 18, 16, 0, 4, + 4, 3, 3, 4, 4, 4, 1, 1, + 0, 0, 0, } var _zcltok_range_lengths []byte = []byte{ @@ -706,12 +730,15 @@ var _zcltok_range_lengths []byte = []byte{ 3, 0, 3, 0, 2, 3, 1, 0, 0, 0, 0, 2, 3, 2, 4, 6, 4, 1, 1, 2, 1, 2, 1, 3, - 2, 3, 2, 12, 0, 0, 0, 0, - 1, 0, 0, 5, 0, 1, 1, 1, - 0, 1, 1, 5, 4, 2, 0, 1, - 0, 2, 2, 5, 2, 3, 5, 3, - 2, 3, 5, 1, 1, 1, 3, 1, - 1, 2, 2, 3, 1, 2, 3, 1, + 2, 3, 2, 0, 1, 1, 1, 0, + 0, 11, 0, 0, 0, 0, 1, 0, + 0, 5, 0, 0, 1, 1, 1, 0, + 1, 1, 5, 4, 2, 0, 1, 0, + 2, 2, 5, 2, 3, 5, 3, 2, + 3, 5, 1, 1, 1, 3, 1, 1, + 2, 2, 3, 1, 2, 3, 1, 5, + 5, 5, 3, 4, 4, 5, 0, 0, + 1, 1, 1, } var _zcltok_index_offsets []int16 = []int16{ @@ -779,18 +806,21 @@ var _zcltok_index_offsets []int16 = []int16{ 2421, 2437, 2439, 2447, 2449, 2457, 2463, 2465, 2469, 2472, 2475, 2478, 2482, 2493, 2496, 2508, 2532, 2540, 2542, 2546, 2549, 2554, 2557, 2559, - 2564, 2567, 2573, 2576, 2634, 2636, 2638, 2640, - 2642, 2647, 2649, 2651, 2690, 2692, 2694, 2699, - 2703, 2704, 2706, 2708, 2715, 2722, 2729, 2731, - 2733, 2735, 2738, 2741, 2747, 2750, 2755, 2762, - 2767, 2770, 2774, 2781, 2813, 2862, 2877, 2890, - 2895, 2897, 2901, 2932, 2938, 2940, 2961, 2981, + 2564, 2567, 2573, 2576, 2578, 2580, 2582, 2584, + 2586, 2588, 2649, 2651, 2653, 2655, 2657, 2662, + 2664, 2666, 2705, 2707, 2709, 2711, 2716, 2720, + 2721, 2723, 2725, 2732, 2739, 2746, 2748, 2750, + 2752, 2755, 2758, 2764, 2767, 2772, 2779, 2784, + 2787, 2791, 2798, 2830, 2879, 2894, 2907, 2912, + 2914, 2918, 2949, 2955, 2957, 2978, 2998, 3000, + 3010, 3020, 3029, 3036, 3045, 3054, 3064, 3066, + 3068, 3070, 3072, } var _zcltok_indicies []int16 = []int16{ 1, 1, 2, 0, 2, 0, 4, 4, 4, 4, 3, 4, 4, 4, 3, 4, - 3, 4, 3, 4, 3, 3, 3, 3, + 3, 4, 4, 3, 3, 3, 3, 3, 3, 4, 3, 3, 3, 3, 4, 4, 4, 4, 4, 3, 3, 4, 3, 3, 4, 3, 4, 3, 3, 4, 3, 3, @@ -1001,7 +1031,7 @@ var _zcltok_indicies []int16 = []int16{ 254, 255, 4, 255, 4, 255, 4, 254, 255, 254, 4, 4, 255, 254, 255, 4, 255, 4, 255, 254, 4, 255, 254, 255, - 255, 4, 255, 4, 255, 254, 4, 254, + 255, 4, 255, 4, 255, 254, 254, 4, 254, 4, 255, 255, 4, 255, 255, 255, 255, 255, 255, 255, 254, 4, 255, 255, 255, 4, 254, 255, 255, 255, 4, 255, @@ -1110,61 +1140,73 @@ var _zcltok_indicies []int16 = []int16{ 268, 10, 255, 254, 4, 255, 4, 349, 268, 256, 254, 10, 255, 254, 4, 259, 350, 256, 268, 256, 254, 255, 254, 4, - 351, 352, 353, 354, 355, 255, 356, 357, - 255, 255, 255, 358, 255, 361, 362, 364, - 365, 366, 360, 367, 368, 369, 370, 371, - 372, 373, 374, 375, 376, 377, 378, 379, - 380, 381, 382, 383, 384, 385, 386, 388, - 389, 390, 391, 392, 393, 255, 352, 2, - 352, 4, 352, 4, 352, 360, 363, 387, - 394, 359, 351, 395, 353, 396, 398, 397, - 399, 397, 2, 401, 401, 2, 400, 402, - 397, 403, 397, 4, 405, 406, 74, 55, - 407, 55, 408, 409, 410, 411, 412, 413, - 414, 415, 416, 417, 418, 129, 419, 105, - 420, 421, 422, 423, 424, 425, 426, 427, - 428, 429, 430, 431, 4, 4, 4, 10, - 150, 404, 432, 397, 255, 433, 4, 4, - 4, 255, 433, 255, 255, 4, 433, 4, - 433, 4, 433, 4, 255, 255, 255, 255, - 255, 433, 4, 255, 255, 255, 4, 255, - 4, 433, 4, 255, 255, 255, 255, 4, - 433, 255, 4, 255, 4, 255, 4, 255, - 255, 4, 255, 433, 4, 255, 4, 255, - 4, 255, 433, 255, 4, 433, 255, 4, - 255, 4, 433, 255, 255, 255, 255, 255, - 433, 4, 4, 255, 4, 255, 433, 255, - 4, 433, 255, 255, 433, 4, 4, 255, - 4, 255, 4, 255, 433, 434, 435, 436, - 437, 438, 439, 440, 441, 442, 443, 444, - 300, 445, 446, 447, 448, 449, 450, 451, - 452, 453, 454, 455, 456, 455, 457, 458, - 459, 460, 461, 256, 433, 462, 463, 464, - 465, 466, 467, 468, 469, 470, 471, 472, - 473, 474, 475, 476, 477, 478, 479, 480, - 310, 481, 482, 483, 277, 484, 485, 486, - 487, 488, 489, 256, 490, 491, 492, 493, - 494, 495, 496, 497, 259, 498, 256, 259, - 499, 500, 501, 502, 268, 433, 503, 504, - 505, 506, 288, 507, 508, 268, 509, 510, - 511, 512, 513, 256, 433, 514, 473, 515, - 516, 517, 268, 518, 519, 259, 256, 268, - 10, 433, 483, 256, 259, 268, 10, 268, - 10, 520, 268, 433, 10, 259, 521, 522, - 259, 523, 524, 266, 525, 526, 527, 528, - 529, 479, 530, 531, 532, 533, 534, 535, - 536, 537, 538, 539, 540, 541, 498, 542, - 259, 268, 10, 433, 543, 544, 268, 256, - 433, 10, 256, 433, 259, 545, 316, 546, - 547, 548, 549, 550, 551, 552, 553, 256, - 554, 555, 556, 557, 558, 559, 256, 268, - 433, 561, 562, 563, 564, 565, 566, 567, - 568, 569, 570, 571, 567, 573, 574, 575, - 576, 560, 572, 560, 433, 560, 433, + 351, 352, 352, 353, 354, 353, 355, 351, + 356, 352, 357, 352, 358, 359, 360, 361, + 362, 363, 255, 364, 365, 255, 255, 255, + 366, 367, 368, 369, 255, 372, 373, 375, + 376, 377, 371, 378, 379, 380, 381, 382, + 383, 384, 385, 386, 387, 388, 389, 390, + 391, 392, 393, 394, 395, 396, 397, 399, + 400, 401, 402, 403, 404, 255, 359, 2, + 359, 4, 359, 4, 371, 374, 398, 405, + 370, 358, 406, 360, 407, 409, 408, 410, + 408, 2, 412, 412, 2, 411, 413, 408, + 414, 408, 4, 416, 417, 74, 55, 418, + 55, 419, 420, 421, 422, 423, 424, 425, + 426, 427, 428, 429, 129, 430, 105, 431, + 432, 433, 434, 435, 436, 437, 438, 439, + 440, 441, 442, 4, 4, 4, 10, 150, + 415, 443, 408, 444, 408, 255, 445, 4, + 4, 4, 255, 445, 255, 255, 4, 445, + 4, 445, 4, 445, 4, 255, 255, 255, + 255, 255, 445, 4, 255, 255, 255, 4, + 255, 4, 445, 4, 255, 255, 255, 255, + 4, 445, 255, 4, 255, 4, 255, 4, + 255, 255, 4, 255, 445, 4, 255, 4, + 255, 4, 255, 445, 255, 4, 445, 255, + 4, 255, 4, 445, 255, 255, 255, 255, + 255, 445, 4, 4, 255, 4, 255, 445, + 255, 4, 445, 255, 255, 445, 4, 4, + 255, 4, 255, 4, 255, 445, 446, 447, + 448, 449, 450, 451, 452, 453, 454, 455, + 456, 300, 457, 458, 459, 460, 461, 462, + 463, 464, 465, 466, 467, 468, 467, 469, + 470, 471, 472, 473, 256, 445, 474, 475, + 476, 477, 478, 479, 480, 481, 482, 483, + 484, 485, 486, 487, 488, 489, 490, 491, + 492, 310, 493, 494, 495, 277, 496, 497, + 498, 499, 500, 501, 256, 502, 503, 504, + 505, 506, 507, 508, 509, 259, 510, 256, + 259, 511, 512, 513, 514, 268, 445, 515, + 516, 517, 518, 288, 519, 520, 268, 521, + 522, 523, 524, 525, 256, 445, 526, 485, + 527, 528, 529, 268, 530, 531, 259, 256, + 268, 10, 445, 495, 256, 259, 268, 10, + 268, 10, 532, 268, 445, 10, 259, 533, + 534, 259, 535, 536, 266, 537, 538, 539, + 540, 541, 491, 542, 543, 544, 545, 546, + 547, 548, 549, 550, 551, 552, 553, 510, + 554, 259, 268, 10, 445, 555, 556, 268, + 256, 445, 10, 256, 445, 259, 557, 316, + 558, 559, 560, 561, 562, 563, 564, 565, + 256, 566, 567, 568, 569, 570, 571, 256, + 268, 445, 573, 574, 575, 576, 577, 578, + 579, 580, 581, 582, 583, 579, 585, 586, + 587, 588, 572, 584, 572, 445, 572, 445, + 589, 590, 591, 592, 593, 594, 595, 596, + 593, 352, 598, 597, 598, 592, 597, 354, + 355, 599, 597, 352, 600, 600, 592, 597, + 354, 355, 599, 597, 352, 600, 600, 592, + 601, 602, 603, 352, 598, 597, 598, 592, + 354, 355, 599, 597, 352, 598, 597, 598, + 592, 354, 355, 599, 597, 352, 598, 597, + 598, 592, 355, 354, 355, 599, 597, 352, + 605, 604, 607, 606, 352, 608, 354, 608, + 355, 608, } var _zcltok_trans_targs []int16 = []int16{ - 515, 1, 520, 515, 523, 515, 24, 25, + 521, 1, 526, 521, 529, 521, 24, 25, 26, 27, 4, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, @@ -1195,7 +1237,7 @@ var _zcltok_trans_targs []int16 = []int16{ 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 260, 261, 262, 263, 264, 265, - 267, 269, 271, 273, 275, 276, 515, 515, + 267, 269, 271, 273, 275, 276, 521, 521, 277, 414, 415, 346, 416, 417, 418, 419, 420, 421, 375, 422, 311, 423, 424, 425, 426, 427, 428, 429, 430, 331, 431, 432, @@ -1207,40 +1249,44 @@ var _zcltok_trans_targs []int16 = []int16{ 474, 475, 476, 477, 478, 479, 482, 483, 485, 486, 487, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 501, 502, - 503, 504, 507, 509, 510, 512, 514, 516, - 515, 517, 518, 519, 521, 522, 524, 515, - 525, 526, 527, 528, 529, 530, 531, 532, - 533, 534, 535, 536, 537, 538, 539, 540, - 541, 542, 543, 544, 545, 546, 547, 548, - 549, 550, 551, 552, 553, 554, 555, 556, - 557, 558, 559, 515, 515, 515, 515, 515, - 515, 0, 515, 515, 515, 2, 3, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 20, 22, 23, 55, 96, - 111, 118, 120, 122, 142, 145, 161, 274, - 515, 515, 278, 279, 280, 281, 282, 283, - 284, 285, 286, 287, 288, 290, 291, 292, - 293, 294, 295, 296, 297, 298, 299, 300, - 301, 302, 303, 304, 305, 306, 307, 308, - 309, 310, 312, 313, 314, 315, 316, 317, - 318, 319, 320, 321, 322, 323, 324, 325, - 326, 328, 329, 330, 332, 333, 334, 335, - 336, 337, 338, 339, 340, 341, 342, 343, - 344, 345, 347, 348, 349, 350, 351, 352, - 353, 354, 355, 357, 358, 359, 360, 361, - 362, 363, 364, 365, 366, 367, 368, 369, - 370, 371, 372, 373, 374, 376, 377, 378, - 379, 380, 381, 382, 383, 384, 385, 386, - 387, 388, 389, 390, 391, 392, 393, 394, - 395, 396, 398, 399, 400, 401, 402, 403, - 404, 405, 406, 407, 408, 409, 410, 411, - 412, 413, 442, 467, 470, 471, 473, 480, - 481, 484, 488, 500, 505, 506, 508, 511, - 513, + 503, 504, 507, 509, 510, 512, 514, 567, + 568, 567, 516, 517, 574, 575, 522, 521, + 523, 524, 521, 525, 527, 528, 521, 530, + 521, 531, 521, 532, 533, 534, 535, 536, + 537, 538, 539, 540, 541, 542, 543, 544, + 545, 546, 547, 548, 549, 550, 551, 552, + 553, 554, 555, 556, 557, 558, 559, 560, + 561, 562, 563, 564, 565, 566, 521, 521, + 521, 521, 521, 521, 0, 521, 521, 521, + 2, 3, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 20, 22, + 23, 55, 96, 111, 118, 120, 122, 142, + 145, 161, 274, 521, 521, 521, 278, 279, + 280, 281, 282, 283, 284, 285, 286, 287, + 288, 290, 291, 292, 293, 294, 295, 296, + 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 312, 313, + 314, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 324, 325, 326, 328, 329, 330, + 332, 333, 334, 335, 336, 337, 338, 339, + 340, 341, 342, 343, 344, 345, 347, 348, + 349, 350, 351, 352, 353, 354, 355, 357, + 358, 359, 360, 361, 362, 363, 364, 365, + 366, 367, 368, 369, 370, 371, 372, 373, + 374, 376, 377, 378, 379, 380, 381, 382, + 383, 384, 385, 386, 387, 388, 389, 390, + 391, 392, 393, 394, 395, 396, 398, 399, + 400, 401, 402, 403, 404, 405, 406, 407, + 408, 409, 410, 411, 412, 413, 442, 467, + 470, 471, 473, 480, 481, 484, 488, 500, + 505, 506, 508, 511, 513, 519, 567, 520, + 569, 567, 576, 577, 578, 567, 515, 518, + 570, 571, 572, 573, 567, 567, 567, 567, + 567, } var _zcltok_trans_actions []byte = []byte{ - 35, 0, 5, 37, 43, 41, 0, 0, + 63, 0, 5, 65, 77, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1271,7 +1317,7 @@ var _zcltok_trans_actions []byte = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 39, 19, + 0, 0, 0, 0, 0, 0, 67, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1283,18 +1329,19 @@ var _zcltok_trans_actions []byte = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 0, 0, 0, 21, + 0, 0, 0, 0, 0, 0, 0, 23, + 71, 25, 0, 0, 0, 0, 0, 37, + 0, 0, 45, 0, 0, 0, 39, 0, + 41, 0, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 5, 5, - 5, 46, 46, 46, 46, 46, 46, 5, - 5, 46, 5, 31, 23, 29, 7, 13, - 25, 0, 11, 9, 27, 0, 0, 0, + 0, 5, 5, 5, 80, 80, 80, 80, + 80, 80, 5, 5, 80, 5, 59, 51, + 57, 27, 33, 53, 0, 31, 29, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 15, 33, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 35, 43, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1312,7 +1359,10 @@ var _zcltok_trans_actions []byte = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, + 0, 0, 0, 0, 0, 0, 11, 0, + 71, 13, 0, 74, 74, 19, 0, 0, + 0, 71, 71, 71, 17, 9, 15, 7, + 21, } var _zcltok_to_state_actions []byte = []byte{ @@ -1380,12 +1430,15 @@ var _zcltok_to_state_actions []byte = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, } var _zcltok_from_state_actions []byte = []byte{ @@ -1453,12 +1506,15 @@ var _zcltok_from_state_actions []byte = []byte{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, } var _zcltok_eof_trans []int16 = []int16{ @@ -1526,19 +1582,23 @@ var _zcltok_eof_trans []int16 = []int16{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 0, 396, 397, 398, 398, - 401, 398, 398, 405, 398, 434, 434, 434, - 434, 434, 434, 434, 434, 434, 434, 434, - 434, 434, 434, 434, 434, 434, 434, 434, - 434, 434, 434, 434, 434, 434, 434, 434, - 434, 434, 434, 434, 434, 434, 434, 434, + 255, 255, 255, 352, 354, 354, 352, 0, + 0, 0, 407, 408, 409, 409, 412, 409, + 409, 416, 409, 409, 446, 446, 446, 446, + 446, 446, 446, 446, 446, 446, 446, 446, + 446, 446, 446, 446, 446, 446, 446, 446, + 446, 446, 446, 446, 446, 446, 446, 446, + 446, 446, 446, 446, 446, 446, 446, 0, + 598, 598, 598, 598, 598, 598, 605, 607, + 609, 609, 609, } -const zcltok_start int = 515 -const zcltok_first_final int = 515 +const zcltok_start int = 521 +const zcltok_first_final int = 521 const zcltok_error int = -1 -const zcltok_en_main int = 515 +const zcltok_en_stringTemplate int = 567 +const zcltok_en_main int = 521 // line 13 "scan_tokens.rl" @@ -1549,7 +1609,7 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { Pos: start, } - // line 70 "scan_tokens.rl" + // line 154 "scan_tokens.rl" // Ragel state cs := 0 // Current State @@ -1559,6 +1619,13 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { te := 0 act := 0 eof := pe + var stack []int + var top int + + braces := 0 + var retBraces []int // stack of brace levels that cause us to use fret + + // line 177 "scan_tokens.rl" // Make Go compiler happy _ = ts @@ -1578,15 +1645,16 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { f.emitToken(TokenType(b[0]), ts, te) } - // line 1588 "scan_tokens.go" + // line 1657 "scan_tokens.go" { cs = zcltok_start + top = 0 ts = 0 te = 0 act = 0 } - // line 1596 "scan_tokens.go" + // line 1666 "scan_tokens.go" { var _klen int var _trans int @@ -1608,7 +1676,7 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { ts = p - // line 1617 "scan_tokens.go" + // line 1687 "scan_tokens.go" } } @@ -1685,153 +1753,353 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { te = p + 1 case 3: - // line 56 "scan_tokens.rl" + // line 126 "scan_tokens.rl" - act = 3 + act = 4 case 4: + // line 127 "scan_tokens.rl" + + act = 5 + case 5: // line 67 "scan_tokens.rl" - act = 12 - case 5: - // line 58 "scan_tokens.rl" - te = p + 1 { - token(TokenNotEqual) + token(TokenTemplateInterp) + braces++ + retBraces = append(retBraces, braces) + { + stack = append(stack, 0) + stack[top] = cs + top++ + cs = 521 + goto _again + } } case 6: - // line 59 "scan_tokens.rl" + // line 74 "scan_tokens.rl" te = p + 1 { - token(TokenGreaterThanEq) + token(TokenTemplateControl) + braces++ + retBraces = append(retBraces, braces) + { + stack = append(stack, 0) + stack[top] = cs + top++ + cs = 521 + goto _again + } } case 7: - // line 60 "scan_tokens.rl" - - te = p + 1 - { - token(TokenLessThanEq) - } - case 8: - // line 61 "scan_tokens.rl" - - te = p + 1 - { - token(TokenAnd) - } - case 9: // line 62 "scan_tokens.rl" te = p + 1 { - token(TokenOr) + token(TokenCQuote) + top-- + cs = stack[top] + { + stack = stack[:len(stack)-1] + } + goto _again + } - case 10: - // line 63 "scan_tokens.rl" + case 8: + // line 127 "scan_tokens.rl" te = p + 1 { - selfToken() + token(TokenBadUTF8) } - case 11: - // line 66 "scan_tokens.rl" - - te = p + 1 - { - token(TokenInvalid) - } - case 12: + case 9: // line 67 "scan_tokens.rl" - te = p + 1 + te = p + p-- + { + token(TokenTemplateInterp) + braces++ + retBraces = append(retBraces, braces) + { + stack = append(stack, 0) + stack[top] = cs + top++ + cs = 521 + goto _again + } + } + case 10: + // line 74 "scan_tokens.rl" + + te = p + p-- + { + token(TokenTemplateControl) + braces++ + retBraces = append(retBraces, braces) + { + stack = append(stack, 0) + stack[top] = cs + top++ + cs = 521 + goto _again + } + } + case 11: + // line 126 "scan_tokens.rl" + + te = p + p-- + { + token(TokenStringLit) + } + case 12: + // line 127 "scan_tokens.rl" + + te = p + p-- { token(TokenBadUTF8) } case 13: - // line 54 "scan_tokens.rl" - - te = p - p-- + // line 126 "scan_tokens.rl" + p = (te) - 1 + { + token(TokenStringLit) + } case 14: - // line 55 "scan_tokens.rl" - - te = p - p-- - { - token(TokenNumberLit) - } - case 15: - // line 56 "scan_tokens.rl" - - te = p - p-- - { - token(TokenIdent) - } - case 16: - // line 63 "scan_tokens.rl" - - te = p - p-- - { - selfToken() - } - case 17: - // line 65 "scan_tokens.rl" - - te = p - p-- - { - token(TokenTabs) - } - case 18: - // line 67 "scan_tokens.rl" - - te = p - p-- - { - token(TokenBadUTF8) - } - case 19: - // line 55 "scan_tokens.rl" - - p = (te) - 1 - { - token(TokenNumberLit) - } - case 20: - // line 56 "scan_tokens.rl" - - p = (te) - 1 - { - token(TokenIdent) - } - case 21: - // line 67 "scan_tokens.rl" - - p = (te) - 1 - { - token(TokenBadUTF8) - } - case 22: // line 1 "NONE" switch act { - case 3: + case 4: { p = (te) - 1 - token(TokenIdent) + token(TokenStringLit) } - case 12: + case 5: { p = (te) - 1 token(TokenBadUTF8) } } - // line 1803 "scan_tokens.go" + case 15: + // line 133 "scan_tokens.rl" + + act = 8 + case 16: + // line 151 "scan_tokens.rl" + + act = 21 + case 17: + // line 135 "scan_tokens.rl" + + te = p + 1 + { + token(TokenNotEqual) + } + case 18: + // line 136 "scan_tokens.rl" + + te = p + 1 + { + token(TokenGreaterThanEq) + } + case 19: + // line 137 "scan_tokens.rl" + + te = p + 1 + { + token(TokenLessThanEq) + } + case 20: + // line 138 "scan_tokens.rl" + + te = p + 1 + { + token(TokenAnd) + } + case 21: + // line 139 "scan_tokens.rl" + + te = p + 1 + { + token(TokenOr) + } + case 22: + // line 140 "scan_tokens.rl" + + te = p + 1 + { + selfToken() + } + case 23: + // line 81 "scan_tokens.rl" + + te = p + 1 + { + token(TokenOBrace) + braces++ + } + case 24: + // line 86 "scan_tokens.rl" + + te = p + 1 + { + if len(retBraces) > 0 && retBraces[len(retBraces)-1] == braces { + token(TokenTemplateSeqEnd) + braces-- + retBraces = retBraces[0 : len(retBraces)-1] + top-- + cs = stack[top] + { + stack = stack[:len(stack)-1] + } + goto _again + + } else { + token(TokenCBrace) + braces-- + } + } + case 25: + // line 98 "scan_tokens.rl" + + te = p + 1 + { + token(TokenTemplateSeqEnd) + braces-- + + // Only consume from the retBraces stack and return if we are at + // a suitable brace nesting level, otherwise things will get + // confused. (Not entering this branch indicates a syntax error, + // which we will catch in the parser.) + if len(retBraces) > 0 && retBraces[len(retBraces)-1] == braces { + retBraces = retBraces[0 : len(retBraces)-1] + top-- + cs = stack[top] + { + stack = stack[:len(stack)-1] + } + goto _again + + } + } + case 26: + // line 57 "scan_tokens.rl" + + te = p + 1 + { + token(TokenOQuote) + { + stack = append(stack, 0) + stack[top] = cs + top++ + cs = 567 + goto _again + } + } + case 27: + // line 150 "scan_tokens.rl" + + te = p + 1 + { + token(TokenInvalid) + } + case 28: + // line 151 "scan_tokens.rl" + + te = p + 1 + { + token(TokenBadUTF8) + } + case 29: + // line 131 "scan_tokens.rl" + + te = p + p-- + + case 30: + // line 132 "scan_tokens.rl" + + te = p + p-- + { + token(TokenNumberLit) + } + case 31: + // line 133 "scan_tokens.rl" + + te = p + p-- + { + token(TokenIdent) + } + case 32: + // line 140 "scan_tokens.rl" + + te = p + p-- + { + selfToken() + } + case 33: + // line 149 "scan_tokens.rl" + + te = p + p-- + { + token(TokenTabs) + } + case 34: + // line 151 "scan_tokens.rl" + + te = p + p-- + { + token(TokenBadUTF8) + } + case 35: + // line 132 "scan_tokens.rl" + + p = (te) - 1 + { + token(TokenNumberLit) + } + case 36: + // line 133 "scan_tokens.rl" + + p = (te) - 1 + { + token(TokenIdent) + } + case 37: + // line 151 "scan_tokens.rl" + + p = (te) - 1 + { + token(TokenBadUTF8) + } + case 38: + // line 1 "NONE" + + switch act { + case 8: + { + p = (te) - 1 + token(TokenIdent) + } + case 21: + { + p = (te) - 1 + token(TokenBadUTF8) + } + } + + // line 2043 "scan_tokens.go" } } @@ -1847,7 +2115,7 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { ts = 0 - // line 1818 "scan_tokens.go" + // line 2058 "scan_tokens.go" } } @@ -1867,7 +2135,7 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { } - // line 102 "scan_tokens.rl" + // line 200 "scan_tokens.rl" // If we fall out here without being in a final state then we've // encountered something that the scanner can't match, which we'll diff --git a/zcl/zclsyntax/scan_tokens.rl b/zcl/zclsyntax/scan_tokens.rl index 74a40dc..2f06239 100644 --- a/zcl/zclsyntax/scan_tokens.rl +++ b/zcl/zclsyntax/scan_tokens.rl @@ -35,7 +35,7 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { Ident = ID_Start ID_Continue*; # Symbols that just represent themselves are handled as a single rule. - SelfToken = "{" | "}" | "[" | "]" | "(" | ")" | "." | "*" | "/" | "+" | "-" | "=" | "<" | ">" | "!" | "?" | ":" | "\n" | "&" | "|" | "~" | "^" | ";" | "`"; + SelfToken = "[" | "]" | "(" | ")" | "." | "*" | "/" | "+" | "-" | "=" | "<" | ">" | "!" | "?" | ":" | "\n" | "&" | "|" | "~" | "^" | ";" | "`"; NotEqual = "!="; GreaterThanEqual = ">="; @@ -43,6 +43,10 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { LogicalAnd = "&&"; LogicalOr = "||"; + Newline = '\r' ? '\n'; + + BeginStringTmpl = '"'; + # Tabs are not valid, but we accept them in the scanner and mark them # as tokens so that we can produce diagnostics advising the user to # use spaces instead. @@ -50,6 +54,79 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { Spaces = ' '+; + action beginStringTemplate { + token(TokenOQuote); + fcall stringTemplate; + } + + action endStringTemplate { + token(TokenCQuote); + fret; + } + + action beginTemplateInterp { + token(TokenTemplateInterp); + braces++; + retBraces = append(retBraces, braces); + fcall main; + } + + action beginTemplateControl { + token(TokenTemplateControl); + braces++; + retBraces = append(retBraces, braces); + fcall main; + } + + action openBrace { + token(TokenOBrace); + braces++; + } + + action closeBrace { + if len(retBraces) > 0 && retBraces[len(retBraces)-1] == braces { + token(TokenTemplateSeqEnd); + braces--; + retBraces = retBraces[0:len(retBraces)-1] + fret; + } else { + token(TokenCBrace); + braces--; + } + } + + action closeTemplateSeqEatWhitespace { + token(TokenTemplateSeqEnd); + braces--; + + // Only consume from the retBraces stack and return if we are at + // a suitable brace nesting level, otherwise things will get + // confused. (Not entering this branch indicates a syntax error, + // which we will catch in the parser.) + if len(retBraces) > 0 && retBraces[len(retBraces)-1] == braces { + retBraces = retBraces[0:len(retBraces)-1] + fret; + } + } + + TemplateInterp = "${" ("~")?; + TemplateControl = "!{" ("~")?; + EndStringTmpl = '"'; + TemplateStringLiteral = ( + ('$' ^'{') | + ('!' ^'{') | + ('\\' AnyUTF8) | + (AnyUTF8 - ("$" | "!" | '"')) + )+; + + stringTemplate := |* + TemplateInterp => beginTemplateInterp; + TemplateControl => beginTemplateControl; + EndStringTmpl => endStringTemplate; + TemplateStringLiteral => { token(TokenStringLit); }; + BrokenUTF8 => { token(TokenBadUTF8); }; + *|; + main := |* Spaces => {}; NumberLit => { token(TokenNumberLit) }; @@ -62,6 +139,13 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { LogicalOr => { token(TokenOr); }; SelfToken => { selfToken() }; + "{" => openBrace; + "}" => closeBrace; + + "~}" => closeTemplateSeqEatWhitespace; + + BeginStringTmpl => beginStringTemplate; + Tabs => { token(TokenTabs) }; AnyUTF8 => { token(TokenInvalid) }; BrokenUTF8 => { token(TokenBadUTF8) }; @@ -77,6 +161,20 @@ func scanTokens(data []byte, filename string, start zcl.Pos) []Token { te := 0 act := 0 eof := pe + var stack []int + var top int + + braces := 0 + var retBraces []int // stack of brace levels that cause us to use fret + + %%{ + prepush { + stack = append(stack, 0); + } + postpop { + stack = stack[:len(stack)-1]; + } + }%% // Make Go compiler happy _ = ts diff --git a/zcl/zclsyntax/scan_tokens_test.go b/zcl/zclsyntax/scan_tokens_test.go index 05726cf..bc72656 100644 --- a/zcl/zclsyntax/scan_tokens_test.go +++ b/zcl/zclsyntax/scan_tokens_test.go @@ -213,6 +213,482 @@ func TestScanTokens(t *testing.T) { }, }, + // Literal-only Templates (string literals, effectively) + { + `""`, + []Token{ + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 0, Line: 1, Column: 1}, + End: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + End: zcl.Pos{Byte: 2, Line: 1, Column: 3}, + }, + }, + { + Type: TokenEOF, + Bytes: []byte{}, + Range: zcl.Range{ + Start: zcl.Pos{Byte: 2, Line: 1, Column: 3}, + End: zcl.Pos{Byte: 2, Line: 1, Column: 3}, + }, + }, + }, + }, + { + `"hello"`, + []Token{ + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 0, Line: 1, Column: 1}, + End: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + }, + }, + { + Type: TokenStringLit, + Bytes: []byte(`hello`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + End: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + }, + }, + { + Type: TokenEOF, + Bytes: []byte{}, + Range: zcl.Range{ + Start: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + End: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + }, + }, + }, + }, + + // Templates with interpolations and control sequences + { + `"${1}"`, + []Token{ + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 0, Line: 1, Column: 1}, + End: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + }, + }, + { + Type: TokenTemplateInterp, + Bytes: []byte(`${`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + End: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + }, + }, + { + Type: TokenNumberLit, + Bytes: []byte(`1`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + End: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + }, + }, + { + Type: TokenTemplateSeqEnd, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + End: zcl.Pos{Byte: 5, Line: 1, Column: 6}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 5, Line: 1, Column: 6}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + { + Type: TokenEOF, + Bytes: []byte{}, + Range: zcl.Range{ + Start: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + }, + }, + { + `"!{a}"`, + []Token{ + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 0, Line: 1, Column: 1}, + End: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + }, + }, + { + Type: TokenTemplateControl, + Bytes: []byte(`!{`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + End: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + }, + }, + { + Type: TokenIdent, + Bytes: []byte(`a`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + End: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + }, + }, + { + Type: TokenTemplateSeqEnd, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + End: zcl.Pos{Byte: 5, Line: 1, Column: 6}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 5, Line: 1, Column: 6}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + { + Type: TokenEOF, + Bytes: []byte{}, + Range: zcl.Range{ + Start: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + }, + }, + { + `"${{}}"`, + []Token{ + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 0, Line: 1, Column: 1}, + End: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + }, + }, + { + Type: TokenTemplateInterp, + Bytes: []byte(`${`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + End: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + }, + }, + { + Type: TokenOBrace, + Bytes: []byte(`{`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + End: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + }, + }, + { + Type: TokenCBrace, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + End: zcl.Pos{Byte: 5, Line: 1, Column: 6}, + }, + }, + { + Type: TokenTemplateSeqEnd, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 5, Line: 1, Column: 6}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + End: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + }, + }, + { + Type: TokenEOF, + Bytes: []byte{}, + Range: zcl.Range{ + Start: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + End: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + }, + }, + }, + }, + { + `"${""}"`, + []Token{ + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 0, Line: 1, Column: 1}, + End: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + }, + }, + { + Type: TokenTemplateInterp, + Bytes: []byte(`${`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + End: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + }, + }, + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + End: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + End: zcl.Pos{Byte: 5, Line: 1, Column: 6}, + }, + }, + { + Type: TokenTemplateSeqEnd, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 5, Line: 1, Column: 6}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + End: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + }, + }, + { + Type: TokenEOF, + Bytes: []byte{}, + Range: zcl.Range{ + Start: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + End: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + }, + }, + }, + }, + { + `"${"${a}"}"`, + []Token{ + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 0, Line: 1, Column: 1}, + End: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + }, + }, + { + Type: TokenTemplateInterp, + Bytes: []byte(`${`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + End: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + }, + }, + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + End: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + }, + }, + { + Type: TokenTemplateInterp, + Bytes: []byte(`${`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + { + Type: TokenIdent, + Bytes: []byte(`a`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + End: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + }, + }, + { + Type: TokenTemplateSeqEnd, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + End: zcl.Pos{Byte: 8, Line: 1, Column: 9}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 8, Line: 1, Column: 9}, + End: zcl.Pos{Byte: 9, Line: 1, Column: 10}, + }, + }, + { + Type: TokenTemplateSeqEnd, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 9, Line: 1, Column: 10}, + End: zcl.Pos{Byte: 10, Line: 1, Column: 11}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 10, Line: 1, Column: 11}, + End: zcl.Pos{Byte: 11, Line: 1, Column: 12}, + }, + }, + { + Type: TokenEOF, + Bytes: []byte{}, + Range: zcl.Range{ + Start: zcl.Pos{Byte: 11, Line: 1, Column: 12}, + End: zcl.Pos{Byte: 11, Line: 1, Column: 12}, + }, + }, + }, + }, + { + `"${"${a} foo"}"`, + []Token{ + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 0, Line: 1, Column: 1}, + End: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + }, + }, + { + Type: TokenTemplateInterp, + Bytes: []byte(`${`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 1, Line: 1, Column: 2}, + End: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + }, + }, + { + Type: TokenOQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 3, Line: 1, Column: 4}, + End: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + }, + }, + { + Type: TokenTemplateInterp, + Bytes: []byte(`${`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 4, Line: 1, Column: 5}, + End: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + }, + }, + { + Type: TokenIdent, + Bytes: []byte(`a`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 6, Line: 1, Column: 7}, + End: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + }, + }, + { + Type: TokenTemplateSeqEnd, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 7, Line: 1, Column: 8}, + End: zcl.Pos{Byte: 8, Line: 1, Column: 9}, + }, + }, + { + Type: TokenStringLit, + Bytes: []byte(` foo`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 8, Line: 1, Column: 9}, + End: zcl.Pos{Byte: 12, Line: 1, Column: 13}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 12, Line: 1, Column: 13}, + End: zcl.Pos{Byte: 13, Line: 1, Column: 14}, + }, + }, + { + Type: TokenTemplateSeqEnd, + Bytes: []byte(`}`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 13, Line: 1, Column: 14}, + End: zcl.Pos{Byte: 14, Line: 1, Column: 15}, + }, + }, + { + Type: TokenCQuote, + Bytes: []byte(`"`), + Range: zcl.Range{ + Start: zcl.Pos{Byte: 14, Line: 1, Column: 15}, + End: zcl.Pos{Byte: 15, Line: 1, Column: 16}, + }, + }, + { + Type: TokenEOF, + Bytes: []byte{}, + Range: zcl.Range{ + Start: zcl.Pos{Byte: 15, Line: 1, Column: 16}, + End: zcl.Pos{Byte: 15, Line: 1, Column: 16}, + }, + }, + }, + }, + // Combinations { ` (1 + 2) * 3 `,