#line 1 "./tasks/../ragel/i18n/zhCN.c.rl" #include #include #if defined(_WIN32) #include #endif #ifdef HAVE_RUBY_RE_H #include #else #include #endif #ifdef HAVE_RUBY_ENCODING_H #include #define ENCODED_STR_NEW(ptr, len) \ rb_enc_str_new(ptr, len, rb_utf8_encoding()); #else #define ENCODED_STR_NEW(ptr, len) \ rb_str_new(ptr, len); #endif #ifndef RSTRING_PTR #define RSTRING_PTR(s) (RSTRING(s)->ptr) #endif #ifndef RSTRING_LEN #define RSTRING_LEN(s) (RSTRING(s)->len) #endif #define DATA_GET(FROM, TYPE, NAME) \ Data_Get_Struct(FROM, TYPE, NAME); \ if (NAME == NULL) { \ rb_raise(rb_eArgError, "NULL found for " # NAME " when it shouldn't be."); \ } typedef struct lexer_state { int content_len; int line_number; int current_line; int start_col; size_t mark; size_t keyword_start; size_t keyword_end; size_t next_keyword_start; size_t content_start; size_t content_end; size_t field_len; size_t query_start; size_t last_newline; size_t final_newline; } lexer_state; static VALUE mGherkin; static VALUE mLexer; static VALUE mCLexer; static VALUE cI18nLexer; static VALUE rb_eGherkinLexerError; #define LEN(AT, P) (P - data - lexer->AT) #define MARK(M, P) (lexer->M = (P) - data) #define PTR_TO(P) (data + lexer->P) #define STORE_KW_END_CON(EVENT) \ store_kw_con(listener, # EVENT, \ PTR_TO(keyword_start), LEN(keyword_start, PTR_TO(keyword_end - 1)), \ PTR_TO(content_start), LEN(content_start, PTR_TO(content_end)), \ lexer->current_line); \ if (lexer->content_end != 0) { \ p = PTR_TO(content_end - 1); \ } \ lexer->content_end = 0; #define STORE_ATTR(ATTR) \ store_attr(listener, # ATTR, \ PTR_TO(content_start), LEN(content_start, p), \ lexer->line_number); #line 239 "./tasks/../ragel/i18n/zhCN.c.rl" /** Data **/ #line 88 "ext/gherkin_lexer_zhCN/gherkin_lexer_zhCN.c" static const char _lexer_actions[] = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 9, 1, 10, 1, 11, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20, 1, 23, 2, 1, 16, 2, 12, 13, 2, 15, 0, 2, 15, 2, 2, 15, 14, 2, 15, 17, 2, 16, 4, 2, 16, 5, 2, 16, 6, 2, 16, 7, 2, 16, 8, 2, 16, 14, 2, 18, 19, 2, 21, 20, 2, 21, 22, 3, 3, 12, 13, 3, 9, 12, 13, 3, 10, 12, 13, 3, 11, 12, 13, 3, 12, 13, 16, 3, 15, 12, 13, 3, 21, 22, 0, 3, 21, 22, 2, 3, 21, 22, 14, 4, 1, 12, 13, 16, 4, 15, 0, 12, 13 }; static const short _lexer_key_offsets[] = { 0, 0, 14, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 35, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 59, 61, 63, 65, 67, 69, 72, 74, 76, 78, 80, 82, 84, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 123, 125, 127, 129, 131, 133, 137, 139, 141, 143, 145, 147, 149, 151, 153, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 221, 222, 223, 224, 225, 226, 227, 231, 236, 241, 246, 251, 255, 259, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 281, 288, 293, 297, 302, 303, 308, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 361, 362, 363, 364, 366, 367, 368, 369, 370, 371, 372, 373, 374, 386, 388, 390, 392, 394, 396, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 471, 472, 484, 486, 488, 490, 492, 494, 498, 500, 502, 504, 506, 508, 510, 512, 514, 517, 519, 521, 523, 525, 527, 529, 531, 533, 535, 537, 539, 541, 543, 545, 547, 549, 551, 553, 555, 557, 559, 561, 563, 565, 567, 569, 571, 573, 575, 577, 579, 581, 582 }; static const char _lexer_trans_keys[] = { -28, -27, -24, -23, 10, 32, 34, 35, 37, 42, 64, 124, 9, 13, -67, -66, -122, -26, -104, -81, 10, 10, 13, -117, -27, -83, -112, 58, 10, 10, 10, 32, 124, 9, 13, -127, -118, -100, -67, -121, -27, -90, -126, -97, -24, -125, -67, 58, 10, 10, -27, -24, 10, 32, 35, 37, 64, 9, 13, -100, 10, -70, 10, -26, 10, -103, 10, -81, 10, -27, 10, 58, -92, 10, -89, 10, -25, 10, -70, 10, -78, 10, 10, 58, -28, -27, -24, -23, 10, 32, 34, 35, 37, 42, 64, 124, 9, 13, -128, -125, -116, -28, -72, -108, -116, -26, -103, -81, 58, 10, 10, -28, -27, -24, -23, 10, 32, 35, 37, 42, 64, 9, 13, -67, 10, -122, 10, -26, 10, -104, 10, -81, 10, -127, -100, -67, 10, -121, 10, -27, 10, -90, 10, -126, 10, -70, 10, -26, 10, -103, 10, -81, 10, -27, 10, 58, -92, 10, -89, 10, -25, 10, -70, 10, -78, 10, 10, 58, -109, 10, -128, 10, -116, 10, -28, 10, -72, 10, -108, 10, -126, 10, -93, 10, -28, 10, -71, 10, -120, 10, 10, 95, 10, 70, 10, 69, 10, 65, 10, 84, 10, 85, 10, 82, 10, 69, 10, 95, 10, 69, 10, 78, 10, 68, 10, 95, 10, 37, 10, 32, -126, -93, -28, -71, -120, 34, 34, 10, 32, 9, 13, 10, 32, 34, 9, 13, 10, 32, 34, 9, 13, 10, 32, 34, 9, 13, 10, 32, 34, 9, 13, 10, 32, 9, 13, 10, 32, 9, 13, 10, 13, 95, 70, 69, 65, 84, 85, 82, 69, 95, 69, 78, 68, 95, 37, 32, 13, 32, 64, 9, 10, 9, 10, 13, 32, 64, 11, 12, 10, 32, 64, 9, 13, 32, 124, 9, 13, 10, 32, 124, 9, 13, 124, 10, 32, 124, 9, 13, -28, -27, -24, -23, 10, 32, 34, 35, 37, 42, 64, 124, 9, 13, -125, 10, -116, 10, -26, 10, -103, 10, -81, 10, 10, 95, 10, 70, 10, 69, 10, 65, 10, 84, 10, 85, 10, 82, 10, 69, 10, 95, 10, 69, 10, 78, 10, 68, 10, 95, 10, 37, -70, -26, -103, -81, -27, 58, -92, -89, -25, -70, -78, 58, 10, 10, -28, -27, -24, -23, 10, 32, 35, 37, 42, 64, 9, 13, -67, 10, -122, 10, -26, 10, -104, 10, -81, 10, -127, -100, -67, 10, -121, 10, -27, 10, -90, 10, -126, 10, -70, 10, -26, 10, -103, 10, -81, 10, 10, 58, -109, 10, -128, 10, -116, 10, -28, 10, -72, 10, -108, 10, -126, 10, -93, 10, -28, 10, -71, 10, -120, 10, 10, 95, 10, 70, 10, 69, 10, 65, 10, 84, 10, 85, 10, 82, 10, 69, 10, 95, 10, 69, 10, 78, 10, 68, 10, 95, 10, 37, 10, 32, 10, 10, -28, -27, -24, -23, 10, 32, 35, 37, 42, 64, 9, 13, -67, 10, -122, 10, -26, 10, -104, 10, -81, 10, -127, -100, -67, 10, -121, 10, -27, 10, -90, 10, -126, 10, -70, 10, -26, 10, -103, 10, -81, 10, -27, 10, 58, -92, 10, -89, 10, -25, 10, -70, 10, -78, 10, 10, 58, -109, 10, -128, 10, -116, 10, -28, 10, -72, 10, -108, 10, -126, 10, -93, 10, -28, 10, -71, 10, -120, 10, 10, 95, 10, 70, 10, 69, 10, 65, 10, 84, 10, 85, 10, 82, 10, 69, 10, 95, 10, 69, 10, 78, 10, 68, 10, 95, 10, 37, 10, 32, -109, 0 }; static const char _lexer_single_lengths[] = { 0, 12, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 7, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 12, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 5, 3, 2, 3, 1, 3, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 10, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 10, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0 }; static const char _lexer_range_lengths[] = { 0, 1, 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, 1, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 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, 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, 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, 0, 0, 0, 0 }; static const short _lexer_index_offsets[] = { 0, 0, 14, 17, 19, 21, 23, 25, 27, 30, 32, 34, 36, 38, 40, 42, 44, 49, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 85, 88, 91, 94, 97, 100, 104, 107, 110, 113, 116, 119, 122, 136, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 173, 176, 179, 182, 185, 188, 193, 196, 199, 202, 205, 208, 211, 214, 217, 221, 224, 227, 230, 233, 236, 239, 242, 245, 248, 251, 254, 257, 260, 263, 266, 269, 272, 275, 278, 281, 284, 287, 290, 293, 296, 299, 302, 305, 308, 311, 314, 317, 319, 321, 323, 325, 327, 329, 331, 335, 340, 345, 350, 355, 359, 363, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 401, 408, 413, 417, 422, 424, 429, 443, 446, 449, 452, 455, 458, 461, 464, 467, 470, 473, 476, 479, 482, 485, 488, 491, 494, 497, 500, 502, 504, 506, 508, 511, 513, 515, 517, 519, 521, 523, 525, 527, 539, 542, 545, 548, 551, 554, 559, 562, 565, 568, 571, 574, 577, 580, 583, 586, 589, 592, 595, 598, 601, 604, 607, 610, 613, 616, 619, 622, 625, 628, 631, 634, 637, 640, 643, 646, 649, 652, 655, 658, 661, 664, 666, 668, 680, 683, 686, 689, 692, 695, 700, 703, 706, 709, 712, 715, 718, 721, 724, 728, 731, 734, 737, 740, 743, 746, 749, 752, 755, 758, 761, 764, 767, 770, 773, 776, 779, 782, 785, 788, 791, 794, 797, 800, 803, 806, 809, 812, 815, 818, 821, 824, 826 }; static const short _lexer_trans_targs[] = { 2, 17, 43, 103, 1, 1, 108, 117, 118, 132, 133, 136, 1, 0, 3, 9, 0, 4, 0, 5, 0, 6, 0, 7, 0, 0, 8, 1, 8, 8, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 16, 15, 16, 15, 16, 16, 1, 16, 15, 18, 22, 160, 265, 0, 19, 0, 20, 0, 21, 0, 7, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 29, 28, 29, 28, 30, 141, 29, 29, 1, 146, 1, 29, 28, 31, 29, 28, 32, 29, 28, 33, 29, 28, 34, 29, 28, 35, 29, 28, 36, 29, 42, 28, 37, 29, 28, 38, 29, 28, 39, 29, 28, 40, 29, 28, 41, 29, 28, 29, 42, 28, 2, 17, 43, 103, 1, 1, 108, 117, 118, 132, 133, 136, 1, 0, 44, 48, 0, 45, 0, 46, 0, 47, 0, 7, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 55, 54, 55, 54, 56, 61, 78, 83, 55, 55, 1, 88, 102, 1, 55, 54, 57, 55, 54, 58, 55, 54, 59, 55, 54, 60, 55, 54, 42, 55, 54, 62, 66, 77, 55, 54, 63, 55, 54, 64, 55, 54, 65, 55, 54, 42, 55, 54, 67, 55, 54, 68, 55, 54, 69, 55, 54, 70, 55, 54, 71, 55, 42, 54, 72, 55, 54, 73, 55, 54, 74, 55, 54, 75, 55, 54, 76, 55, 54, 55, 42, 54, 42, 55, 54, 79, 55, 54, 80, 55, 54, 81, 55, 54, 82, 55, 54, 42, 55, 54, 84, 55, 54, 85, 55, 54, 86, 55, 54, 87, 55, 54, 42, 55, 54, 55, 89, 54, 55, 90, 54, 55, 91, 54, 55, 92, 54, 55, 93, 54, 55, 94, 54, 55, 95, 54, 55, 96, 54, 55, 97, 54, 55, 98, 54, 55, 99, 54, 55, 100, 54, 55, 101, 54, 55, 1, 54, 55, 42, 54, 104, 0, 105, 0, 106, 0, 107, 0, 7, 0, 109, 0, 110, 0, 111, 110, 110, 0, 112, 112, 113, 112, 112, 112, 112, 113, 112, 112, 112, 112, 114, 112, 112, 112, 112, 115, 112, 112, 1, 116, 116, 0, 1, 116, 116, 0, 1, 117, 117, 119, 0, 120, 0, 121, 0, 122, 0, 123, 0, 124, 0, 125, 0, 126, 0, 127, 0, 128, 0, 129, 0, 130, 0, 131, 0, 266, 0, 7, 0, 0, 0, 0, 0, 134, 135, 1, 135, 135, 133, 134, 134, 1, 135, 133, 135, 0, 136, 137, 136, 0, 140, 139, 137, 139, 138, 137, 138, 140, 139, 137, 139, 138, 2, 17, 43, 103, 140, 140, 108, 117, 118, 132, 133, 137, 140, 0, 142, 29, 28, 143, 29, 28, 144, 29, 28, 145, 29, 28, 41, 29, 28, 29, 147, 28, 29, 148, 28, 29, 149, 28, 29, 150, 28, 29, 151, 28, 29, 152, 28, 29, 153, 28, 29, 154, 28, 29, 155, 28, 29, 156, 28, 29, 157, 28, 29, 158, 28, 29, 159, 28, 29, 1, 28, 161, 0, 162, 0, 163, 0, 164, 0, 165, 215, 0, 166, 0, 167, 0, 168, 0, 169, 0, 170, 0, 171, 0, 173, 172, 173, 172, 174, 179, 190, 195, 173, 173, 1, 200, 214, 1, 173, 172, 175, 173, 172, 176, 173, 172, 177, 173, 172, 178, 173, 172, 42, 173, 172, 180, 184, 189, 173, 172, 181, 173, 172, 182, 173, 172, 183, 173, 172, 42, 173, 172, 185, 173, 172, 186, 173, 172, 187, 173, 172, 188, 173, 172, 173, 42, 172, 42, 173, 172, 191, 173, 172, 192, 173, 172, 193, 173, 172, 194, 173, 172, 42, 173, 172, 196, 173, 172, 197, 173, 172, 198, 173, 172, 199, 173, 172, 42, 173, 172, 173, 201, 172, 173, 202, 172, 173, 203, 172, 173, 204, 172, 173, 205, 172, 173, 206, 172, 173, 207, 172, 173, 208, 172, 173, 209, 172, 173, 210, 172, 173, 211, 172, 173, 212, 172, 173, 213, 172, 173, 1, 172, 173, 42, 172, 217, 216, 217, 216, 218, 223, 240, 245, 217, 217, 1, 250, 264, 1, 217, 216, 219, 217, 216, 220, 217, 216, 221, 217, 216, 222, 217, 216, 42, 217, 216, 224, 228, 239, 217, 216, 225, 217, 216, 226, 217, 216, 227, 217, 216, 42, 217, 216, 229, 217, 216, 230, 217, 216, 231, 217, 216, 232, 217, 216, 233, 217, 42, 216, 234, 217, 216, 235, 217, 216, 236, 217, 216, 237, 217, 216, 238, 217, 216, 217, 42, 216, 42, 217, 216, 241, 217, 216, 242, 217, 216, 243, 217, 216, 244, 217, 216, 42, 217, 216, 246, 217, 216, 247, 217, 216, 248, 217, 216, 249, 217, 216, 42, 217, 216, 217, 251, 216, 217, 252, 216, 217, 253, 216, 217, 254, 216, 217, 255, 216, 217, 256, 216, 217, 257, 216, 217, 258, 216, 217, 259, 216, 217, 260, 216, 217, 261, 216, 217, 262, 216, 217, 263, 216, 217, 1, 216, 217, 42, 216, 7, 0, 0, 0 }; static const char _lexer_trans_actions[] = { 23, 23, 23, 23, 42, 0, 5, 1, 0, 23, 0, 29, 0, 37, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 37, 45, 88, 17, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 125, 45, 42, 0, 42, 0, 69, 0, 0, 0, 0, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 125, 45, 42, 0, 72, 72, 42, 0, 57, 27, 57, 0, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 9, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 42, 9, 0, 51, 51, 51, 51, 104, 25, 48, 45, 25, 51, 25, 54, 25, 37, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 125, 45, 42, 0, 72, 72, 72, 72, 42, 0, 60, 27, 72, 60, 0, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 11, 42, 0, 0, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 11, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 11, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 42, 11, 0, 11, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 11, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 11, 42, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 11, 0, 42, 11, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 42, 0, 0, 37, 120, 39, 39, 39, 3, 100, 27, 27, 27, 0, 100, 27, 27, 27, 0, 100, 27, 0, 27, 0, 84, 7, 7, 37, 42, 0, 0, 37, 92, 19, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 37, 37, 37, 37, 1, 21, 96, 21, 21, 21, 21, 0, 42, 0, 0, 0, 37, 0, 35, 0, 37, 42, 31, 75, 31, 31, 33, 0, 42, 0, 33, 0, 0, 116, 116, 116, 116, 42, 0, 112, 108, 81, 116, 81, 78, 0, 37, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 9, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 125, 45, 42, 0, 72, 72, 72, 72, 42, 0, 66, 27, 72, 66, 0, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 15, 42, 0, 0, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 15, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 42, 15, 0, 15, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 15, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 15, 42, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 15, 0, 42, 15, 0, 125, 45, 42, 0, 72, 72, 72, 72, 42, 0, 63, 27, 72, 63, 0, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 13, 42, 0, 0, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 13, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 13, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 42, 13, 0, 13, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 13, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 13, 42, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 13, 0, 42, 13, 0, 0, 37, 0, 0 }; static const char _lexer_eof_actions[] = { 0, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37 }; static const int lexer_start = 1; static const int lexer_first_final = 266; static const int lexer_error = 0; static const int lexer_en_main = 1; #line 243 "./tasks/../ragel/i18n/zhCN.c.rl" static VALUE strip_i(VALUE str, VALUE ary) { rb_funcall(str, rb_intern("strip!"), 0); rb_ary_push(ary, str); return Qnil; } static VALUE multiline_strip(VALUE text) { VALUE map = rb_ary_new(); VALUE split = rb_str_split(text, "\n"); rb_iterate(rb_each, split, strip_i, map); return rb_ary_join(split, rb_str_new2("\n")); } static void store_kw_con(VALUE listener, const char * event_name, const char * keyword_at, size_t keyword_length, const char * at, size_t length, int current_line) { VALUE con = Qnil, kw = Qnil; kw = ENCODED_STR_NEW(keyword_at, keyword_length); con = ENCODED_STR_NEW(at, length); con = multiline_strip(con); rb_funcall(con, rb_intern("strip!"), 0); rb_funcall(kw, rb_intern("strip!"), 0); rb_funcall(listener, rb_intern(event_name), 3, kw, con, INT2FIX(current_line)); } static void store_attr(VALUE listener, const char * attr_type, const char * at, size_t length, int line) { VALUE val = ENCODED_STR_NEW(at, length); rb_funcall(listener, rb_intern(attr_type), 2, val, INT2FIX(line)); } static void store_pystring_content(VALUE listener, int start_col, const char *at, size_t length, int current_line) { VALUE con = ENCODED_STR_NEW(at, length); // Gherkin will crash gracefully if the string representation of start_col pushes the pattern past 32 characters char pat[32]; snprintf(pat, 32, "^ {0,%d}", start_col); VALUE re = rb_reg_regcomp(rb_str_new2(pat)); rb_funcall(con, rb_intern("gsub!"), 2, re, rb_str_new2("")); rb_funcall(listener, rb_intern("py_string"), 2, con, INT2FIX(current_line)); } static void raise_lexer_error(VALUE listener, const char * at, int line) { rb_raise(rb_eGherkinLexerError, "Lexing error on line %d: '%s'.", line, at); } static void lexer_init(lexer_state *lexer) { lexer->content_start = 0; lexer->content_end = 0; lexer->content_len = 0; lexer->mark = 0; lexer->field_len = 0; lexer->keyword_start = 0; lexer->keyword_end = 0; lexer->next_keyword_start = 0; lexer->line_number = 1; lexer->last_newline = 0; lexer->final_newline = 0; lexer->start_col = 0; } static VALUE CLexer_alloc(VALUE klass) { VALUE obj; lexer_state *lxr = ALLOC(lexer_state); lexer_init(lxr); obj = Data_Wrap_Struct(klass, NULL, -1, lxr); return obj; } static VALUE CLexer_init(VALUE self, VALUE listener) { rb_iv_set(self, "@listener", listener); lexer_state *lxr = NULL; DATA_GET(self, lexer_state, lxr); lexer_init(lxr); return self; } static VALUE CLexer_scan(VALUE self, VALUE input) { lexer_state *lexer = NULL; DATA_GET(self, lexer_state, lexer); VALUE input_copy = rb_str_dup(input); rb_str_append(input_copy, rb_str_new2("\n%_FEATURE_END_%")); char *data = RSTRING_PTR(input_copy); long len = RSTRING_LEN(input_copy); if (len == 0) { rb_raise(rb_eGherkinLexerError, "No content to lex."); } else { const char *p, *pe, *eof; int cs = 0; VALUE listener = rb_iv_get(self, "@listener"); VALUE rows = rb_ary_new(); VALUE current_row = rb_ary_new(); p = data; pe = data + len; eof = pe; assert(*pe == '\0' && "pointer does not end on NULL"); assert(pe - p == len && "pointers aren't same distance"); #line 723 "ext/gherkin_lexer_zhCN/gherkin_lexer_zhCN.c" { cs = lexer_start; } #line 374 "./tasks/../ragel/i18n/zhCN.c.rl" #line 730 "ext/gherkin_lexer_zhCN/gherkin_lexer_zhCN.c" { int _klen; unsigned int _trans; const char *_acts; unsigned int _nacts; const char *_keys; if ( p == pe ) goto _test_eof; if ( cs == 0 ) goto _out; _resume: _keys = _lexer_trans_keys + _lexer_key_offsets[cs]; _trans = _lexer_index_offsets[cs]; _klen = _lexer_single_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + _klen - 1; while (1) { if ( _upper < _lower ) break; _mid = _lower + ((_upper-_lower) >> 1); if ( (*p) < *_mid ) _upper = _mid - 1; else if ( (*p) > *_mid ) _lower = _mid + 1; else { _trans += (_mid - _keys); goto _match; } } _keys += _klen; _trans += _klen; } _klen = _lexer_range_lengths[cs]; if ( _klen > 0 ) { const char *_lower = _keys; const char *_mid; const char *_upper = _keys + (_klen<<1) - 2; while (1) { if ( _upper < _lower ) break; _mid = _lower + (((_upper-_lower) >> 1) & ~1); if ( (*p) < _mid[0] ) _upper = _mid - 2; else if ( (*p) > _mid[1] ) _lower = _mid + 2; else { _trans += ((_mid - _keys)>>1); goto _match; } } _trans += _klen; } _match: cs = _lexer_trans_targs[_trans]; if ( _lexer_trans_actions[_trans] == 0 ) goto _again; _acts = _lexer_actions + _lexer_trans_actions[_trans]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 0: #line 82 "./tasks/../ragel/i18n/zhCN.c.rl" { MARK(content_start, p); lexer->current_line = lexer->line_number; } break; case 1: #line 87 "./tasks/../ragel/i18n/zhCN.c.rl" { MARK(content_start, p); } break; case 2: #line 91 "./tasks/../ragel/i18n/zhCN.c.rl" { lexer->current_line = lexer->line_number; lexer->start_col = p - data - lexer->last_newline; } break; case 3: #line 96 "./tasks/../ragel/i18n/zhCN.c.rl" { int len = LEN(content_start, PTR_TO(final_newline)); if (len < 0) len = 0; store_pystring_content(listener, lexer->start_col, PTR_TO(content_start), len, lexer->current_line); } break; case 4: #line 104 "./tasks/../ragel/i18n/zhCN.c.rl" { STORE_KW_END_CON(feature) } break; case 5: #line 108 "./tasks/../ragel/i18n/zhCN.c.rl" { STORE_KW_END_CON(background) } break; case 6: #line 112 "./tasks/../ragel/i18n/zhCN.c.rl" { STORE_KW_END_CON(scenario) } break; case 7: #line 116 "./tasks/../ragel/i18n/zhCN.c.rl" { STORE_KW_END_CON(scenario_outline) } break; case 8: #line 120 "./tasks/../ragel/i18n/zhCN.c.rl" { STORE_KW_END_CON(examples) } break; case 9: #line 124 "./tasks/../ragel/i18n/zhCN.c.rl" { store_kw_con(listener, "step", PTR_TO(keyword_start), LEN(keyword_start, PTR_TO(keyword_end)), PTR_TO(content_start), LEN(content_start, p), lexer->current_line); } break; case 10: #line 131 "./tasks/../ragel/i18n/zhCN.c.rl" { STORE_ATTR(comment) lexer->mark = 0; } break; case 11: #line 136 "./tasks/../ragel/i18n/zhCN.c.rl" { STORE_ATTR(tag) lexer->mark = 0; } break; case 12: #line 141 "./tasks/../ragel/i18n/zhCN.c.rl" { lexer->line_number += 1; MARK(final_newline, p); } break; case 13: #line 146 "./tasks/../ragel/i18n/zhCN.c.rl" { MARK(last_newline, p + 1); } break; case 14: #line 150 "./tasks/../ragel/i18n/zhCN.c.rl" { if (lexer->mark == 0) { MARK(mark, p); } } break; case 15: #line 156 "./tasks/../ragel/i18n/zhCN.c.rl" { MARK(keyword_end, p); MARK(keyword_start, PTR_TO(mark)); MARK(content_start, p + 1); lexer->mark = 0; } break; case 16: #line 163 "./tasks/../ragel/i18n/zhCN.c.rl" { MARK(content_end, p); } break; case 17: #line 167 "./tasks/../ragel/i18n/zhCN.c.rl" { p = p - 1; lexer->current_line = lexer->line_number; rb_ary_clear(rows); rb_ary_clear(current_row); } break; case 18: #line 174 "./tasks/../ragel/i18n/zhCN.c.rl" { MARK(content_start, p); } break; case 19: #line 178 "./tasks/../ragel/i18n/zhCN.c.rl" { VALUE con = Qnil; con = ENCODED_STR_NEW(PTR_TO(content_start), LEN(content_start, p)); rb_funcall(con, rb_intern("strip!"), 0); rb_ary_push(current_row, con); } break; case 20: #line 186 "./tasks/../ragel/i18n/zhCN.c.rl" { current_row = rb_ary_new(); } break; case 21: #line 190 "./tasks/../ragel/i18n/zhCN.c.rl" { rb_ary_push(rows, current_row); } break; case 22: #line 194 "./tasks/../ragel/i18n/zhCN.c.rl" { rb_funcall(listener, rb_intern("table"), 2, rows, INT2FIX(lexer->current_line)); } break; case 23: #line 198 "./tasks/../ragel/i18n/zhCN.c.rl" { if (cs < lexer_first_final) { if (raise_lexer_error != NULL) { int count = 0; int newstr_count = 0; size_t len; const char *buff; if (lexer->last_newline != 0) { len = LEN(last_newline, eof); buff = PTR_TO(last_newline); } else { len = strlen(data); buff = data; } char newstr[len]; for (count = 0; count < len; count++) { if(buff[count] == 10) { newstr[newstr_count] = '\0'; // terminate new string at first newline found break; } else { if (buff[count] == '%') { newstr[newstr_count++] = buff[count]; newstr[newstr_count] = buff[count]; } else { newstr[newstr_count] = buff[count]; } } newstr_count++; } int line = lexer->line_number; lexer_init(lexer); // Re-initialize so we can scan again with the same lexer raise_lexer_error(listener, newstr, line); } } } break; #line 1006 "ext/gherkin_lexer_zhCN/gherkin_lexer_zhCN.c" } } _again: if ( cs == 0 ) goto _out; if ( ++p != pe ) goto _resume; _test_eof: {} if ( p == eof ) { const char *__acts = _lexer_actions + _lexer_eof_actions[cs]; unsigned int __nacts = (unsigned int) *__acts++; while ( __nacts-- > 0 ) { switch ( *__acts++ ) { case 23: #line 198 "./tasks/../ragel/i18n/zhCN.c.rl" { if (cs < lexer_first_final) { if (raise_lexer_error != NULL) { int count = 0; int newstr_count = 0; size_t len; const char *buff; if (lexer->last_newline != 0) { len = LEN(last_newline, eof); buff = PTR_TO(last_newline); } else { len = strlen(data); buff = data; } char newstr[len]; for (count = 0; count < len; count++) { if(buff[count] == 10) { newstr[newstr_count] = '\0'; // terminate new string at first newline found break; } else { if (buff[count] == '%') { newstr[newstr_count++] = buff[count]; newstr[newstr_count] = buff[count]; } else { newstr[newstr_count] = buff[count]; } } newstr_count++; } int line = lexer->line_number; lexer_init(lexer); // Re-initialize so we can scan again with the same lexer raise_lexer_error(listener, newstr, line); } } } break; #line 1063 "ext/gherkin_lexer_zhCN/gherkin_lexer_zhCN.c" } } } _out: {} } #line 375 "./tasks/../ragel/i18n/zhCN.c.rl" assert(p <= pe && "data overflow after parsing execute"); assert(lexer->content_start <= len && "content starts after data end"); assert(lexer->mark < len && "mark is after data end"); assert(lexer->field_len <= len && "field has length longer than the whole data"); // Reset lexer by re-initializing the whole thing lexer_init(lexer); if (cs == lexer_error) { rb_raise(rb_eGherkinLexerError, "Invalid format, lexing fails."); } else { return Qtrue; } } } void Init_gherkin_lexer_zhCN() { mGherkin = rb_define_module("Gherkin"); mLexer = rb_const_get(mGherkin, rb_intern("Lexer")); rb_eGherkinLexerError = rb_const_get(mLexer, rb_intern("LexingError")); mCLexer = rb_define_module_under(mGherkin, "CLexer"); cI18nLexer = rb_define_class_under(mCLexer, "Zhcn", rb_cObject); rb_define_alloc_func(cI18nLexer, CLexer_alloc); rb_define_method(cI18nLexer, "initialize", CLexer_init, 1); rb_define_method(cI18nLexer, "scan", CLexer_scan, 1); }