#line 1 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.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 #define LF_FLAG 0 #define CRLF_FLAG 1 #define LF "\n" #define CRLF "\r\n" #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; int eol; 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 query_start; size_t last_newline; size_t final_newline; } lexer_state; static VALUE mGherkin; static VALUE mGherkinLexer; static VALUE mCLexer; static VALUE cI18nLexer; static VALUE rb_eGherkinLexingError; #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_multiline_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, lexer->eol); \ 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 244 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" /** Data **/ #line 93 "ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.c" static const char _lexer_actions[] = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20, 1, 21, 2, 1, 16, 2, 11, 0, 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, 20, 0, 2, 20, 2, 2, 20, 14, 2, 20, 17, 3, 3, 12, 13, 3, 9, 12, 13, 3, 10, 12, 13, 3, 11, 12, 13, 3, 12, 13, 16, 3, 15, 12, 13, 4, 1, 12, 13, 16, 4, 15, 0, 12, 13 }; static const short _lexer_key_offsets[] = { 0, 0, 19, 20, 21, 39, 40, 41, 45, 50, 55, 60, 65, 69, 73, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 94, 99, 106, 111, 112, 114, 115, 116, 117, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 197, 199, 201, 203, 205, 207, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 224, 225, 226, 227, 228, 229, 230, 231, 232, 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 324, 325, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 375, 377, 379, 381, 383, 385, 387, 389, 391, 393, 395, 397, 399, 401, 403, 405, 407, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 431, 432, 433, 434, 435, 436, 437, 438, 449, 451, 453, 455, 457, 459, 461, 463, 465, 467, 469, 471, 473, 475, 477, 479, 481, 483, 485, 487, 489, 491, 493, 495, 497, 499, 501, 503, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 530, 536, 539, 541, 547, 565, 567, 569, 571, 573, 575, 577, 579, 581, 583, 585, 587, 589, 591, 593, 595, 597, 599, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 625 }; static const char _lexer_trans_keys[] = { -17, 10, 32, 34, 35, 37, 42, 64, 65, 66, 68, 69, 73, 77, 79, 87, 124, 9, 13, -69, -65, 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, 10, 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, 79, 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, 35, 79, 124, 9, 13, 10, 72, 10, 32, 10, 72, 10, 65, 10, 73, 10, 58, 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, 79, 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, 72, 10, 32, 10, 72, 10, 65, 10, 73, 10, 10, 10, 32, 35, 37, 42, 64, 65, 66, 68, 73, 77, 79, 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, 52, 85, 10, 58, 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, 72, 10, 32, 10, 72, 10, 65, 10, 73, 72, 32, 72, 65, 73, 58, 10, 10, 10, 32, 35, 37, 64, 66, 69, 77, 79, 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, 88, 10, 65, 10, 77, 10, 80, 10, 76, 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, 72, 10, 32, 10, 72, 10, 65, 10, 73, 32, 124, 9, 13, 10, 32, 92, 124, 9, 13, 10, 92, 124, 10, 92, 10, 32, 92, 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, 10, 72, 10, 32, 10, 72, 10, 65, 10, 73, 84, 0 }; static const char _lexer_single_lengths[] = { 0, 17, 1, 1, 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, 1, 2, 3, 5, 3, 1, 2, 1, 1, 1, 13, 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, 5, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 13, 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, 2, 2, 2, 1, 1, 13, 2, 2, 2, 2, 2, 2, 2, 2, 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, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 9, 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, 2, 2, 2, 2, 2, 4, 3, 2, 4, 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, 2, 2, 2, 2, 2, 1, 0 }; static const char _lexer_range_lengths[] = { 0, 1, 0, 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, 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, 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, 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, 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, 1, 1, 0, 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 }; static const short _lexer_index_offsets[] = { 0, 0, 19, 21, 23, 41, 43, 45, 49, 54, 59, 64, 69, 73, 77, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 117, 122, 129, 134, 136, 139, 141, 143, 145, 160, 163, 166, 169, 172, 175, 178, 181, 184, 187, 190, 193, 196, 199, 202, 205, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 250, 253, 256, 259, 262, 265, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 297, 299, 301, 303, 305, 307, 309, 311, 313, 328, 331, 334, 337, 340, 343, 346, 349, 352, 355, 358, 361, 364, 367, 370, 373, 376, 379, 382, 385, 388, 391, 394, 397, 400, 403, 406, 409, 412, 415, 418, 421, 424, 427, 430, 433, 436, 439, 442, 444, 446, 461, 464, 467, 470, 473, 476, 479, 482, 485, 488, 491, 494, 497, 500, 503, 506, 509, 513, 516, 519, 522, 525, 528, 531, 534, 537, 540, 543, 546, 549, 552, 555, 558, 561, 565, 568, 571, 574, 577, 580, 583, 586, 589, 592, 595, 597, 599, 601, 603, 605, 607, 609, 611, 622, 625, 628, 631, 634, 637, 640, 643, 646, 649, 652, 655, 658, 661, 664, 667, 670, 673, 676, 679, 682, 685, 688, 691, 694, 697, 700, 703, 707, 710, 713, 716, 719, 722, 725, 728, 731, 734, 737, 741, 747, 751, 754, 760, 778, 781, 784, 787, 790, 793, 796, 799, 802, 805, 808, 811, 814, 817, 820, 823, 826, 829, 833, 836, 839, 842, 845, 848, 851, 854, 857, 860, 863, 866, 868 }; static const short _lexer_trans_targs[] = { 2, 4, 4, 5, 14, 16, 30, 33, 36, 37, 58, 59, 75, 83, 183, 58, 230, 4, 0, 3, 0, 4, 0, 4, 4, 5, 14, 16, 30, 33, 36, 37, 58, 59, 75, 83, 183, 58, 230, 4, 0, 6, 0, 7, 0, 8, 7, 7, 0, 9, 9, 10, 9, 9, 9, 9, 10, 9, 9, 9, 9, 11, 9, 9, 9, 9, 12, 9, 9, 4, 13, 13, 0, 4, 13, 13, 0, 4, 15, 14, 4, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 266, 0, 31, 0, 0, 32, 4, 15, 32, 0, 0, 0, 0, 34, 35, 4, 35, 35, 33, 34, 34, 4, 35, 33, 35, 0, 30, 0, 38, 265, 0, 39, 0, 41, 40, 41, 40, 41, 41, 4, 42, 56, 4, 236, 237, 239, 240, 248, 260, 239, 41, 40, 41, 43, 40, 41, 44, 40, 41, 45, 40, 41, 46, 40, 41, 47, 40, 41, 48, 40, 41, 49, 40, 41, 50, 40, 41, 51, 40, 41, 52, 40, 41, 53, 40, 41, 54, 40, 41, 55, 40, 41, 4, 40, 41, 57, 40, 4, 4, 5, 14, 16, 30, 33, 36, 37, 58, 59, 75, 83, 183, 58, 230, 4, 0, 36, 0, 60, 0, 61, 0, 62, 0, 63, 0, 64, 0, 65, 0, 66, 0, 68, 67, 68, 67, 68, 68, 4, 69, 4, 68, 67, 68, 70, 67, 68, 71, 67, 68, 72, 67, 68, 73, 67, 68, 74, 67, 68, 57, 67, 76, 0, 77, 0, 78, 0, 79, 0, 80, 0, 81, 0, 82, 0, 30, 0, 84, 0, 85, 0, 86, 0, 87, 0, 88, 0, 89, 136, 0, 90, 0, 91, 0, 92, 0, 93, 0, 94, 0, 95, 0, 97, 96, 97, 96, 97, 97, 4, 98, 112, 4, 113, 114, 116, 117, 125, 131, 116, 97, 96, 97, 99, 96, 97, 100, 96, 97, 101, 96, 97, 102, 96, 97, 103, 96, 97, 104, 96, 97, 105, 96, 97, 106, 96, 97, 107, 96, 97, 108, 96, 97, 109, 96, 97, 110, 96, 97, 111, 96, 97, 4, 96, 97, 57, 96, 97, 112, 96, 97, 115, 96, 97, 112, 96, 97, 113, 96, 97, 118, 96, 97, 119, 96, 97, 120, 96, 97, 121, 96, 97, 122, 96, 97, 123, 96, 97, 124, 96, 97, 112, 96, 97, 126, 96, 97, 127, 96, 97, 128, 96, 97, 129, 96, 97, 130, 96, 97, 57, 96, 97, 132, 96, 97, 133, 96, 97, 134, 96, 97, 135, 96, 97, 130, 96, 138, 137, 138, 137, 138, 138, 4, 139, 153, 4, 154, 155, 158, 159, 167, 178, 158, 138, 137, 138, 140, 137, 138, 141, 137, 138, 142, 137, 138, 143, 137, 138, 144, 137, 138, 145, 137, 138, 146, 137, 138, 147, 137, 138, 148, 137, 138, 149, 137, 138, 150, 137, 138, 151, 137, 138, 152, 137, 138, 4, 137, 138, 57, 137, 138, 153, 137, 138, 156, 157, 137, 138, 57, 137, 138, 153, 137, 138, 154, 137, 138, 160, 137, 138, 161, 137, 138, 162, 137, 138, 163, 137, 138, 164, 137, 138, 165, 137, 138, 166, 137, 138, 153, 137, 138, 168, 137, 138, 169, 137, 138, 170, 137, 138, 171, 137, 138, 172, 137, 138, 173, 57, 137, 138, 174, 137, 138, 175, 137, 138, 176, 137, 138, 177, 137, 138, 156, 137, 138, 179, 137, 138, 180, 137, 138, 181, 137, 138, 182, 137, 138, 156, 137, 184, 0, 185, 0, 186, 0, 187, 0, 188, 0, 189, 0, 191, 190, 191, 190, 191, 191, 4, 192, 4, 206, 208, 214, 225, 191, 190, 191, 193, 190, 191, 194, 190, 191, 195, 190, 191, 196, 190, 191, 197, 190, 191, 198, 190, 191, 199, 190, 191, 200, 190, 191, 201, 190, 191, 202, 190, 191, 203, 190, 191, 204, 190, 191, 205, 190, 191, 4, 190, 191, 207, 190, 191, 57, 190, 191, 209, 190, 191, 210, 190, 191, 211, 190, 191, 212, 190, 191, 213, 190, 191, 207, 190, 191, 215, 190, 191, 216, 190, 191, 217, 190, 191, 218, 190, 191, 219, 190, 191, 220, 57, 190, 191, 221, 190, 191, 222, 190, 191, 223, 190, 191, 224, 190, 191, 207, 190, 191, 226, 190, 191, 227, 190, 191, 228, 190, 191, 229, 190, 191, 207, 190, 230, 231, 230, 0, 235, 234, 233, 231, 234, 232, 0, 233, 231, 232, 0, 233, 232, 235, 234, 233, 231, 234, 232, 235, 235, 5, 14, 16, 30, 33, 36, 37, 58, 59, 75, 83, 183, 58, 230, 235, 0, 41, 56, 40, 41, 238, 40, 41, 56, 40, 41, 236, 40, 41, 241, 40, 41, 242, 40, 41, 243, 40, 41, 244, 40, 41, 245, 40, 41, 246, 40, 41, 247, 40, 41, 56, 40, 41, 249, 40, 41, 250, 40, 41, 251, 40, 41, 252, 40, 41, 253, 40, 41, 254, 57, 40, 41, 255, 40, 41, 256, 40, 41, 257, 40, 41, 258, 40, 41, 259, 40, 41, 57, 40, 41, 261, 40, 41, 262, 40, 41, 263, 40, 41, 264, 40, 41, 259, 40, 30, 0, 0, 0 }; static const char _lexer_trans_actions[] = { 0, 47, 0, 5, 1, 0, 25, 1, 25, 25, 25, 25, 25, 25, 25, 25, 31, 0, 39, 0, 39, 0, 39, 47, 0, 5, 1, 0, 25, 1, 25, 25, 25, 25, 25, 25, 25, 25, 31, 0, 39, 0, 39, 0, 39, 47, 0, 0, 39, 119, 41, 41, 41, 3, 111, 29, 29, 29, 0, 111, 29, 29, 29, 0, 111, 29, 0, 29, 0, 95, 7, 7, 39, 47, 0, 0, 39, 103, 21, 0, 47, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 39, 50, 99, 19, 0, 39, 39, 39, 39, 0, 23, 107, 23, 23, 44, 23, 0, 47, 0, 1, 0, 39, 0, 39, 0, 0, 39, 0, 39, 124, 50, 47, 0, 47, 0, 65, 29, 77, 65, 77, 77, 77, 77, 77, 77, 77, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 11, 0, 47, 11, 0, 115, 27, 53, 50, 27, 56, 50, 56, 56, 56, 56, 56, 56, 56, 56, 59, 27, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 124, 50, 47, 0, 47, 0, 74, 77, 74, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 17, 0, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 124, 50, 47, 0, 47, 0, 71, 29, 77, 71, 77, 77, 77, 77, 77, 77, 77, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 15, 0, 47, 15, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 15, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 124, 50, 47, 0, 47, 0, 68, 29, 77, 68, 77, 77, 77, 77, 77, 77, 77, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 13, 0, 47, 13, 0, 47, 0, 0, 47, 0, 0, 0, 47, 13, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 13, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 0, 39, 124, 50, 47, 0, 47, 0, 62, 29, 62, 77, 77, 77, 77, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 9, 0, 47, 0, 0, 47, 9, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 9, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 0, 0, 0, 39, 47, 33, 33, 80, 33, 33, 39, 0, 35, 0, 39, 0, 0, 47, 0, 0, 35, 0, 0, 47, 0, 86, 83, 37, 89, 83, 89, 89, 89, 89, 89, 89, 89, 89, 92, 0, 39, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 11, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 11, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 47, 0, 0, 0, 39, 0, 0 }; static const char _lexer_eof_actions[] = { 0, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39 }; 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 248 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.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 split; } 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); rb_funcall(con, rb_intern("strip!"), 0); rb_funcall(listener, rb_intern(event_name), 3, kw, con, INT2FIX(current_line)); } static void store_multiline_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, int eol) { VALUE con = Qnil, kw = Qnil, name = Qnil, desc = Qnil; kw = ENCODED_STR_NEW(keyword_at, keyword_length); con = ENCODED_STR_NEW(at, length); VALUE split = multiline_strip(con); name = rb_funcall(split, rb_intern("shift"), 0); desc = rb_ary_join(split, rb_str_new2( \ eol == CRLF_FLAG ? CRLF : LF )); if( name == Qnil ) { name = rb_str_new2(""); } if( rb_funcall(desc, rb_intern("size"), 0) == 0) { desc = rb_str_new2(""); } rb_funcall(name, rb_intern("strip!"), 0); rb_funcall(desc, rb_intern("strip!"), 0); rb_funcall(listener, rb_intern(event_name), 4, kw, name, desc, 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, "^[\t ]{0,%d}", start_col); VALUE re = rb_reg_regcomp(rb_str_new2(pat)); VALUE re2 = rb_reg_regcomp(rb_str_new2("\r\\Z")); VALUE unescape_escaped_quotes = rb_reg_regcomp(rb_str_new2("\\\\\"\\\\\"\\\\\"")); rb_funcall(con, rb_intern("gsub!"), 2, re, rb_str_new2("")); rb_funcall(con, rb_intern("sub!"), 2, re2, rb_str_new2("")); rb_funcall(con, rb_intern("gsub!"), 2, unescape_escaped_quotes, rb_str_new2("\"\"\"")); rb_funcall(listener, rb_intern("py_string"), 2, con, INT2FIX(current_line)); } static void raise_lexer_error(const char * at, int line) { rb_raise(rb_eGherkinLexingError, "Lexing error on line %d: '%s'. See http://wiki.github.com/aslakhellesoy/gherkin/lexingerror for more information.", line, at); } static int count_char(char char_to_count, char *str) { int count = 0; int i = 0; while(str[i] != '\0') { if(str[i] == char_to_count) { count++; } i++; } return count; } static void lexer_init(lexer_state *lexer) { lexer->content_start = 0; lexer->content_end = 0; lexer->content_len = 0; lexer->mark = 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; lexer->eol = LF_FLAG; } 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) { VALUE listener = rb_iv_get(self, "@listener"); 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); size_t len = RSTRING_LEN(input_copy); if (count_char('\r', data) > (count_char('\n', data) / 2)) { lexer->eol = CRLF_FLAG; } if (len == 0) { rb_raise(rb_eGherkinLexingError, "No content to lex."); } else { const char *p, *pe, *eof; int cs = 0; VALUE current_row = Qnil; p = data; pe = data + len; eof = pe; assert(*pe == '\0' && "pointer does not end on NULL"); #line 795 "ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.c" { cs = lexer_start; } #line 430 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" #line 802 "ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.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 87 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { MARK(content_start, p); lexer->current_line = lexer->line_number; } break; case 1: #line 92 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { MARK(content_start, p); } break; case 2: #line 96 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { lexer->current_line = lexer->line_number; lexer->start_col = p - data - lexer->last_newline; } break; case 3: #line 101 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.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 109 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { STORE_KW_END_CON(feature); } break; case 5: #line 113 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { STORE_KW_END_CON(background); } break; case 6: #line 117 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { STORE_KW_END_CON(scenario); } break; case 7: #line 121 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { STORE_KW_END_CON(scenario_outline); } break; case 8: #line 125 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { STORE_KW_END_CON(examples); } break; case 9: #line 129 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.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 136 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { STORE_ATTR(comment); lexer->mark = 0; } break; case 11: #line 141 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { STORE_ATTR(tag); lexer->mark = 0; } break; case 12: #line 146 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { lexer->line_number += 1; MARK(final_newline, p); } break; case 13: #line 151 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { MARK(last_newline, p + 1); } break; case 14: #line 155 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { if (lexer->mark == 0) { MARK(mark, p); } } break; case 15: #line 161 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { MARK(keyword_end, p); MARK(keyword_start, PTR_TO(mark)); MARK(content_start, p + 1); lexer->mark = 0; } break; case 16: #line 168 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { MARK(content_end, p); } break; case 17: #line 172 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { p = p - 1; lexer->current_line = lexer->line_number; current_row = rb_ary_new(); } break; case 18: #line 178 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { MARK(content_start, p); } break; case 19: #line 182 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { VALUE con = ENCODED_STR_NEW(PTR_TO(content_start), LEN(content_start, p)); rb_funcall(con, rb_intern("strip!"), 0); VALUE re_pipe = rb_reg_regcomp(rb_str_new2("\\\\\\|")); VALUE re_backslash = rb_reg_regcomp(rb_str_new2("\\\\\\\\")); rb_funcall(con, rb_intern("gsub!"), 2, re_pipe, rb_str_new2("|")); rb_funcall(con, rb_intern("gsub!"), 2, re_backslash, rb_str_new2("\\")); rb_ary_push(current_row, con); } break; case 20: #line 193 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { rb_funcall(listener, rb_intern("row"), 2, current_row, INT2FIX(lexer->current_line)); } break; case 21: #line 197 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { if (cs < lexer_first_final) { if (raise_lexer_error != NULL) { size_t count = 0; VALUE newstr_val; char *newstr; 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; } // Allocate as a ruby string so that it gets cleaned up by GC newstr_val = rb_str_new(buff, len); newstr = RSTRING_PTR(newstr_val); 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(newstr, line); } } else { rb_funcall(listener, rb_intern("eof"), 0); } } break; #line 1074 "ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.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 21: #line 197 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.c.rl" { if (cs < lexer_first_final) { if (raise_lexer_error != NULL) { size_t count = 0; VALUE newstr_val; char *newstr; 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; } // Allocate as a ruby string so that it gets cleaned up by GC newstr_val = rb_str_new(buff, len); newstr = RSTRING_PTR(newstr_val); 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(newstr, line); } } else { rb_funcall(listener, rb_intern("eof"), 0); } } break; #line 1137 "ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.c" } } } _out: {} } #line 431 "/Users/aslakhellesoy/scm/gherkin/tasks/../ragel/i18n/en_lol.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"); // Reset lexer by re-initializing the whole thing lexer_init(lexer); if (cs == lexer_error) { rb_raise(rb_eGherkinLexingError, "Invalid format, lexing fails."); } else { return Qtrue; } } } void Init_gherkin_lexer_en_lol() { mGherkin = rb_define_module("Gherkin"); mGherkinLexer = rb_define_module_under(mGherkin, "Lexer"); rb_eGherkinLexingError = rb_const_get(mGherkinLexer, rb_intern("LexingError")); mCLexer = rb_define_module_under(mGherkin, "CLexer"); cI18nLexer = rb_define_class_under(mCLexer, "En_lol", 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); }