#line 1 "./tasks/../ragel/i18n/enlol.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/enlol.c.rl" /** Data **/ #line 88 "ext/gherkin_lexer_enlol/gherkin_lexer_enlol.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, 18, 19, 20, 24, 29, 34, 39, 44, 48, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 72, 77, 84, 89, 90, 92, 93, 94, 95, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 187, 188, 189, 190, 191, 192, 193, 194, 195, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 276, 277, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 333, 335, 337, 339, 341, 343, 345, 347, 349, 351, 353, 355, 358, 360, 362, 364, 366, 368, 370, 371, 372, 373, 374, 375, 376, 377, 378, 387, 389, 391, 393, 395, 397, 399, 401, 403, 405, 407, 409, 411, 413, 415, 417, 419, 421, 423, 425, 427, 429, 432, 434, 436, 438, 440, 442, 446, 451, 452, 457, 475, 477, 479, 481, 483, 485, 487, 489, 491, 493, 495, 497, 499, 501, 503, 505, 507, 509, 512, 514, 516, 518, 520, 522, 524, 525 }; static const char _lexer_trans_keys[] = { 10, 32, 34, 35, 37, 42, 64, 65, 66, 68, 69, 73, 77, 79, 87, 124, 9, 13, 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, 10, 10, 13, 13, 32, 64, 9, 10, 9, 10, 13, 32, 64, 11, 12, 10, 32, 64, 9, 13, 78, 52, 85, 58, 10, 10, 10, 32, 35, 37, 42, 64, 65, 66, 68, 73, 77, 87, 9, 13, 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, 32, 34, 35, 37, 42, 64, 65, 66, 68, 69, 73, 77, 79, 87, 124, 9, 13, 69, 88, 65, 77, 80, 76, 90, 58, 10, 10, 10, 32, 124, 9, 13, 32, 67, 65, 78, 32, 72, 65, 90, 73, 83, 72, 85, 78, 32, 58, 83, 82, 83, 76, 89, 58, 10, 10, 10, 32, 35, 37, 42, 64, 65, 66, 68, 73, 77, 87, 9, 13, 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, 78, 10, 85, 10, 84, 10, 69, 10, 32, 10, 67, 10, 65, 10, 78, 10, 32, 10, 72, 10, 65, 10, 90, 10, 73, 10, 83, 10, 72, 10, 85, 10, 78, 10, 58, 10, 10, 10, 32, 35, 37, 42, 64, 65, 66, 68, 73, 77, 87, 9, 13, 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, 78, 10, 85, 10, 84, 10, 69, 10, 32, 10, 67, 10, 65, 10, 78, 10, 32, 10, 72, 10, 65, 10, 90, 10, 73, 10, 83, 10, 72, 10, 85, 10, 78, 10, 32, 58, 10, 83, 10, 82, 10, 83, 10, 76, 10, 89, 10, 58, 72, 32, 72, 65, 73, 58, 10, 10, 10, 32, 35, 37, 64, 66, 77, 9, 13, 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, 52, 10, 58, 10, 73, 10, 83, 10, 72, 10, 85, 10, 78, 10, 32, 58, 10, 83, 10, 82, 10, 83, 10, 76, 10, 89, 32, 124, 9, 13, 10, 32, 124, 9, 13, 124, 10, 32, 124, 9, 13, 10, 32, 34, 35, 37, 42, 64, 65, 66, 68, 69, 73, 77, 79, 87, 124, 9, 13, 10, 78, 10, 85, 10, 84, 10, 69, 10, 32, 10, 67, 10, 65, 10, 78, 10, 32, 10, 72, 10, 65, 10, 90, 10, 73, 10, 83, 10, 72, 10, 85, 10, 78, 10, 32, 58, 10, 83, 10, 82, 10, 83, 10, 76, 10, 89, 10, 58, 84, 0 }; static const char _lexer_single_lengths[] = { 0, 16, 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, 1, 2, 3, 5, 3, 1, 2, 1, 1, 1, 12, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 12, 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, 12, 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, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 3, 1, 3, 16, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 1, 0 }; static const char _lexer_range_lengths[] = { 0, 1, 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, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 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, 1, 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, 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, 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, 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 }; static const short _lexer_index_offsets[] = { 0, 0, 18, 20, 22, 26, 31, 36, 41, 46, 50, 54, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 92, 97, 104, 109, 111, 114, 116, 118, 120, 134, 137, 140, 143, 146, 149, 152, 155, 158, 161, 164, 167, 170, 173, 176, 179, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 251, 253, 255, 257, 259, 261, 263, 265, 267, 281, 284, 287, 290, 293, 296, 299, 302, 305, 308, 311, 314, 317, 320, 323, 326, 329, 332, 335, 338, 341, 344, 347, 350, 353, 356, 359, 362, 365, 368, 371, 374, 377, 380, 382, 384, 398, 401, 404, 407, 410, 413, 416, 419, 422, 425, 428, 431, 434, 437, 440, 443, 446, 449, 452, 455, 458, 461, 464, 467, 470, 473, 476, 479, 482, 485, 488, 491, 494, 498, 501, 504, 507, 510, 513, 516, 518, 520, 522, 524, 526, 528, 530, 532, 541, 544, 547, 550, 553, 556, 559, 562, 565, 568, 571, 574, 577, 580, 583, 586, 589, 592, 595, 598, 601, 604, 608, 611, 614, 617, 620, 623, 627, 632, 634, 639, 657, 660, 663, 666, 669, 672, 675, 678, 681, 684, 687, 690, 693, 696, 699, 702, 705, 708, 712, 715, 718, 721, 724, 727, 730, 732 }; static const unsigned char _lexer_trans_targs[] = { 1, 1, 2, 11, 12, 26, 29, 32, 33, 54, 55, 65, 73, 163, 54, 199, 1, 0, 3, 0, 4, 0, 5, 4, 4, 0, 6, 6, 7, 6, 6, 6, 6, 7, 6, 6, 6, 6, 8, 6, 6, 6, 6, 9, 6, 6, 1, 10, 10, 0, 1, 10, 10, 0, 1, 11, 11, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 229, 0, 27, 0, 0, 28, 1, 28, 28, 0, 0, 0, 0, 30, 31, 1, 31, 31, 29, 30, 30, 1, 31, 29, 31, 0, 26, 0, 34, 228, 0, 35, 0, 37, 36, 37, 36, 37, 37, 1, 38, 52, 1, 204, 205, 207, 208, 216, 207, 37, 36, 37, 39, 36, 37, 40, 36, 37, 41, 36, 37, 42, 36, 37, 43, 36, 37, 44, 36, 37, 45, 36, 37, 46, 36, 37, 47, 36, 37, 48, 36, 37, 49, 36, 37, 50, 36, 37, 51, 36, 37, 1, 36, 37, 53, 36, 1, 1, 2, 11, 12, 26, 29, 32, 33, 54, 55, 65, 73, 163, 54, 199, 1, 0, 32, 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 64, 63, 64, 63, 64, 64, 1, 64, 63, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 26, 0, 74, 0, 75, 0, 76, 0, 77, 0, 78, 0, 79, 121, 0, 80, 0, 81, 0, 82, 0, 83, 0, 84, 0, 85, 0, 87, 86, 87, 86, 87, 87, 1, 88, 102, 1, 103, 104, 106, 107, 115, 106, 87, 86, 87, 89, 86, 87, 90, 86, 87, 91, 86, 87, 92, 86, 87, 93, 86, 87, 94, 86, 87, 95, 86, 87, 96, 86, 87, 97, 86, 87, 98, 86, 87, 99, 86, 87, 100, 86, 87, 101, 86, 87, 1, 86, 87, 53, 86, 87, 102, 86, 87, 105, 86, 87, 102, 86, 87, 103, 86, 87, 108, 86, 87, 109, 86, 87, 110, 86, 87, 111, 86, 87, 112, 86, 87, 113, 86, 87, 114, 86, 87, 102, 86, 87, 116, 86, 87, 117, 86, 87, 118, 86, 87, 119, 86, 87, 120, 86, 87, 53, 86, 123, 122, 123, 122, 123, 123, 1, 124, 138, 1, 139, 140, 142, 143, 151, 142, 123, 122, 123, 125, 122, 123, 126, 122, 123, 127, 122, 123, 128, 122, 123, 129, 122, 123, 130, 122, 123, 131, 122, 123, 132, 122, 123, 133, 122, 123, 134, 122, 123, 135, 122, 123, 136, 122, 123, 137, 122, 123, 1, 122, 123, 53, 122, 123, 138, 122, 123, 141, 122, 123, 138, 122, 123, 139, 122, 123, 144, 122, 123, 145, 122, 123, 146, 122, 123, 147, 122, 123, 148, 122, 123, 149, 122, 123, 150, 122, 123, 138, 122, 123, 152, 122, 123, 153, 122, 123, 154, 122, 123, 155, 122, 123, 156, 122, 123, 157, 53, 122, 123, 158, 122, 123, 159, 122, 123, 160, 122, 123, 161, 122, 123, 162, 122, 123, 53, 122, 164, 0, 165, 0, 166, 0, 167, 0, 168, 0, 169, 0, 171, 170, 171, 170, 171, 171, 1, 172, 1, 186, 188, 171, 170, 171, 173, 170, 171, 174, 170, 171, 175, 170, 171, 176, 170, 171, 177, 170, 171, 178, 170, 171, 179, 170, 171, 180, 170, 171, 181, 170, 171, 182, 170, 171, 183, 170, 171, 184, 170, 171, 185, 170, 171, 1, 170, 171, 187, 170, 171, 53, 170, 171, 189, 170, 171, 190, 170, 171, 191, 170, 171, 192, 170, 171, 193, 170, 171, 194, 53, 170, 171, 195, 170, 171, 196, 170, 171, 197, 170, 171, 198, 170, 171, 187, 170, 199, 200, 199, 0, 203, 202, 200, 202, 201, 200, 201, 203, 202, 200, 202, 201, 203, 203, 2, 11, 12, 26, 29, 32, 33, 54, 55, 65, 73, 163, 54, 200, 203, 0, 37, 52, 36, 37, 206, 36, 37, 52, 36, 37, 204, 36, 37, 209, 36, 37, 210, 36, 37, 211, 36, 37, 212, 36, 37, 213, 36, 37, 214, 36, 37, 215, 36, 37, 52, 36, 37, 217, 36, 37, 218, 36, 37, 219, 36, 37, 220, 36, 37, 221, 36, 37, 222, 53, 36, 37, 223, 36, 37, 224, 36, 37, 225, 36, 37, 226, 36, 37, 227, 36, 37, 53, 36, 26, 0, 0, 0 }; static const char _lexer_trans_actions[] = { 42, 0, 5, 1, 0, 23, 0, 23, 23, 23, 23, 23, 23, 23, 23, 29, 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, 45, 88, 17, 0, 37, 37, 37, 37, 1, 21, 96, 21, 21, 21, 21, 0, 42, 0, 0, 0, 37, 0, 37, 0, 0, 37, 0, 37, 125, 45, 42, 0, 42, 0, 60, 27, 72, 60, 72, 72, 72, 72, 72, 72, 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, 0, 0, 42, 11, 0, 42, 11, 0, 104, 25, 48, 45, 25, 51, 25, 51, 51, 51, 51, 51, 51, 51, 51, 54, 25, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 125, 45, 42, 0, 42, 0, 69, 0, 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, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 125, 45, 42, 0, 42, 0, 66, 27, 72, 66, 72, 72, 72, 72, 72, 72, 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, 0, 0, 42, 15, 0, 42, 15, 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, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 15, 0, 125, 45, 42, 0, 42, 0, 63, 27, 72, 63, 72, 72, 72, 72, 72, 72, 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, 0, 0, 42, 13, 0, 42, 13, 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, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 13, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 13, 0, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 0, 37, 125, 45, 42, 0, 42, 0, 57, 27, 57, 72, 72, 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, 0, 0, 42, 9, 0, 42, 0, 0, 42, 9, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 9, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 0, 35, 0, 37, 42, 31, 75, 31, 31, 33, 0, 42, 0, 33, 0, 0, 42, 0, 112, 108, 81, 116, 81, 116, 116, 116, 116, 116, 116, 116, 116, 78, 0, 37, 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, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 11, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 0, 0, 42, 11, 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 }; static const int lexer_start = 1; static const int lexer_first_final = 229; static const int lexer_error = 0; static const int lexer_en_main = 1; #line 243 "./tasks/../ragel/i18n/enlol.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 667 "ext/gherkin_lexer_enlol/gherkin_lexer_enlol.c" { cs = lexer_start; } #line 374 "./tasks/../ragel/i18n/enlol.c.rl" #line 674 "ext/gherkin_lexer_enlol/gherkin_lexer_enlol.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/enlol.c.rl" { MARK(content_start, p); lexer->current_line = lexer->line_number; } break; case 1: #line 87 "./tasks/../ragel/i18n/enlol.c.rl" { MARK(content_start, p); } break; case 2: #line 91 "./tasks/../ragel/i18n/enlol.c.rl" { lexer->current_line = lexer->line_number; lexer->start_col = p - data - lexer->last_newline; } break; case 3: #line 96 "./tasks/../ragel/i18n/enlol.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/enlol.c.rl" { STORE_KW_END_CON(feature) } break; case 5: #line 108 "./tasks/../ragel/i18n/enlol.c.rl" { STORE_KW_END_CON(background) } break; case 6: #line 112 "./tasks/../ragel/i18n/enlol.c.rl" { STORE_KW_END_CON(scenario) } break; case 7: #line 116 "./tasks/../ragel/i18n/enlol.c.rl" { STORE_KW_END_CON(scenario_outline) } break; case 8: #line 120 "./tasks/../ragel/i18n/enlol.c.rl" { STORE_KW_END_CON(examples) } break; case 9: #line 124 "./tasks/../ragel/i18n/enlol.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/enlol.c.rl" { STORE_ATTR(comment) lexer->mark = 0; } break; case 11: #line 136 "./tasks/../ragel/i18n/enlol.c.rl" { STORE_ATTR(tag) lexer->mark = 0; } break; case 12: #line 141 "./tasks/../ragel/i18n/enlol.c.rl" { lexer->line_number += 1; MARK(final_newline, p); } break; case 13: #line 146 "./tasks/../ragel/i18n/enlol.c.rl" { MARK(last_newline, p + 1); } break; case 14: #line 150 "./tasks/../ragel/i18n/enlol.c.rl" { if (lexer->mark == 0) { MARK(mark, p); } } break; case 15: #line 156 "./tasks/../ragel/i18n/enlol.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/enlol.c.rl" { MARK(content_end, p); } break; case 17: #line 167 "./tasks/../ragel/i18n/enlol.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/enlol.c.rl" { MARK(content_start, p); } break; case 19: #line 178 "./tasks/../ragel/i18n/enlol.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/enlol.c.rl" { current_row = rb_ary_new(); } break; case 21: #line 190 "./tasks/../ragel/i18n/enlol.c.rl" { rb_ary_push(rows, current_row); } break; case 22: #line 194 "./tasks/../ragel/i18n/enlol.c.rl" { rb_funcall(listener, rb_intern("table"), 2, rows, INT2FIX(lexer->current_line)); } break; case 23: #line 198 "./tasks/../ragel/i18n/enlol.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 950 "ext/gherkin_lexer_enlol/gherkin_lexer_enlol.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/enlol.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 1007 "ext/gherkin_lexer_enlol/gherkin_lexer_enlol.c" } } } _out: {} } #line 375 "./tasks/../ragel/i18n/enlol.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_enlol() { 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, "Enlol", 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); }