gherkin 2.12.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -15
- data/CONTRIBUTING.md +23 -0
- data/Gemfile +0 -3
- data/LICENSE +18 -17
- data/Makefile +65 -0
- data/README.md +9 -268
- data/Rakefile +17 -19
- data/bin/gherkin-generate-ast +21 -0
- data/bin/gherkin-generate-pickles +25 -0
- data/bin/gherkin-generate-tokens +12 -0
- data/gherkin-ruby.razor +218 -0
- data/gherkin.gemspec +22 -76
- data/lib/gherkin/ast_builder.rb +243 -0
- data/lib/gherkin/ast_node.rb +30 -0
- data/lib/gherkin/dialect.rb +58 -0
- data/lib/gherkin/errors.rb +45 -0
- data/lib/gherkin/gherkin-languages.json +2968 -0
- data/lib/gherkin/gherkin_line.rb +95 -0
- data/lib/gherkin/parser.rb +1910 -0
- data/lib/gherkin/pickles/compiler.rb +164 -0
- data/lib/gherkin/token.rb +18 -0
- data/lib/gherkin/token_formatter_builder.rb +39 -0
- data/lib/gherkin/token_matcher.rb +169 -0
- data/lib/gherkin/token_scanner.rb +40 -0
- data/spec/capture_warnings.rb +68 -0
- data/spec/coverage.rb +10 -0
- data/spec/gherkin/parser_spec.rb +146 -0
- metadata +60 -567
- data/.gitattributes +0 -2
- data/.mailmap +0 -2
- data/.rbenv-gemsets +0 -1
- data/.rspec +0 -1
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.yardopts +0 -5
- data/History.md +0 -881
- data/build_native_gems.sh +0 -7
- data/cucumber.yml +0 -5
- data/examples/parse_and_output_json.rb +0 -19
- data/ext/gherkin_lexer_ar/extconf.rb +0 -6
- data/ext/gherkin_lexer_ar/gherkin_lexer_ar.c +0 -1432
- data/ext/gherkin_lexer_bg/extconf.rb +0 -6
- data/ext/gherkin_lexer_bg/gherkin_lexer_bg.c +0 -1655
- data/ext/gherkin_lexer_bm/extconf.rb +0 -6
- data/ext/gherkin_lexer_bm/gherkin_lexer_bm.c +0 -1516
- data/ext/gherkin_lexer_ca/extconf.rb +0 -6
- data/ext/gherkin_lexer_ca/gherkin_lexer_ca.c +0 -1581
- data/ext/gherkin_lexer_cs/extconf.rb +0 -6
- data/ext/gherkin_lexer_cs/gherkin_lexer_cs.c +0 -1515
- data/ext/gherkin_lexer_cy_gb/extconf.rb +0 -6
- data/ext/gherkin_lexer_cy_gb/gherkin_lexer_cy_gb.c +0 -1282
- data/ext/gherkin_lexer_da/extconf.rb +0 -6
- data/ext/gherkin_lexer_da/gherkin_lexer_da.c +0 -1298
- data/ext/gherkin_lexer_de/extconf.rb +0 -6
- data/ext/gherkin_lexer_de/gherkin_lexer_de.c +0 -1425
- data/ext/gherkin_lexer_el/extconf.rb +0 -6
- data/ext/gherkin_lexer_el/gherkin_lexer_el.c +0 -1919
- data/ext/gherkin_lexer_en/extconf.rb +0 -6
- data/ext/gherkin_lexer_en/gherkin_lexer_en.c +0 -1418
- data/ext/gherkin_lexer_en_au/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_au/gherkin_lexer_en_au.c +0 -1765
- data/ext/gherkin_lexer_en_lol/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.c +0 -1177
- data/ext/gherkin_lexer_en_old/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_old/gherkin_lexer_en_old.c +0 -1309
- data/ext/gherkin_lexer_en_pirate/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_pirate/gherkin_lexer_en_pirate.c +0 -1471
- data/ext/gherkin_lexer_en_scouse/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_scouse/gherkin_lexer_en_scouse.c +0 -1634
- data/ext/gherkin_lexer_en_tx/extconf.rb +0 -6
- data/ext/gherkin_lexer_en_tx/gherkin_lexer_en_tx.c +0 -1265
- data/ext/gherkin_lexer_eo/extconf.rb +0 -6
- data/ext/gherkin_lexer_eo/gherkin_lexer_eo.c +0 -1241
- data/ext/gherkin_lexer_es/extconf.rb +0 -6
- data/ext/gherkin_lexer_es/gherkin_lexer_es.c +0 -1399
- data/ext/gherkin_lexer_et/extconf.rb +0 -6
- data/ext/gherkin_lexer_et/gherkin_lexer_et.c +0 -1236
- data/ext/gherkin_lexer_fa/extconf.rb +0 -6
- data/ext/gherkin_lexer_fa/gherkin_lexer_fa.c +0 -1475
- data/ext/gherkin_lexer_fi/extconf.rb +0 -6
- data/ext/gherkin_lexer_fi/gherkin_lexer_fi.c +0 -1215
- data/ext/gherkin_lexer_fr/extconf.rb +0 -6
- data/ext/gherkin_lexer_fr/gherkin_lexer_fr.c +0 -1493
- data/ext/gherkin_lexer_gl/extconf.rb +0 -6
- data/ext/gherkin_lexer_gl/gherkin_lexer_gl.c +0 -1374
- data/ext/gherkin_lexer_he/extconf.rb +0 -6
- data/ext/gherkin_lexer_he/gherkin_lexer_he.c +0 -1374
- data/ext/gherkin_lexer_hi/extconf.rb +0 -6
- data/ext/gherkin_lexer_hi/gherkin_lexer_hi.c +0 -1848
- data/ext/gherkin_lexer_hr/extconf.rb +0 -6
- data/ext/gherkin_lexer_hr/gherkin_lexer_hr.c +0 -1323
- data/ext/gherkin_lexer_hu/extconf.rb +0 -6
- data/ext/gherkin_lexer_hu/gherkin_lexer_hu.c +0 -1376
- data/ext/gherkin_lexer_id/extconf.rb +0 -6
- data/ext/gherkin_lexer_id/gherkin_lexer_id.c +0 -1208
- data/ext/gherkin_lexer_is/extconf.rb +0 -6
- data/ext/gherkin_lexer_is/gherkin_lexer_is.c +0 -1376
- data/ext/gherkin_lexer_it/extconf.rb +0 -6
- data/ext/gherkin_lexer_it/gherkin_lexer_it.c +0 -1340
- data/ext/gherkin_lexer_ja/extconf.rb +0 -6
- data/ext/gherkin_lexer_ja/gherkin_lexer_ja.c +0 -1699
- data/ext/gherkin_lexer_kn/extconf.rb +0 -6
- data/ext/gherkin_lexer_kn/gherkin_lexer_kn.c +0 -1965
- data/ext/gherkin_lexer_ko/extconf.rb +0 -6
- data/ext/gherkin_lexer_ko/gherkin_lexer_ko.c +0 -1360
- data/ext/gherkin_lexer_lt/extconf.rb +0 -6
- data/ext/gherkin_lexer_lt/gherkin_lexer_lt.c +0 -1296
- data/ext/gherkin_lexer_lu/extconf.rb +0 -6
- data/ext/gherkin_lexer_lu/gherkin_lexer_lu.c +0 -1389
- data/ext/gherkin_lexer_lv/extconf.rb +0 -6
- data/ext/gherkin_lexer_lv/gherkin_lexer_lv.c +0 -1425
- data/ext/gherkin_lexer_nl/extconf.rb +0 -6
- data/ext/gherkin_lexer_nl/gherkin_lexer_nl.c +0 -1368
- data/ext/gherkin_lexer_no/extconf.rb +0 -6
- data/ext/gherkin_lexer_no/gherkin_lexer_no.c +0 -1311
- data/ext/gherkin_lexer_pa/extconf.rb +0 -6
- data/ext/gherkin_lexer_pa/gherkin_lexer_pa.c +0 -2160
- data/ext/gherkin_lexer_pl/extconf.rb +0 -6
- data/ext/gherkin_lexer_pl/gherkin_lexer_pl.c +0 -1738
- data/ext/gherkin_lexer_pt/extconf.rb +0 -6
- data/ext/gherkin_lexer_pt/gherkin_lexer_pt.c +0 -1711
- data/ext/gherkin_lexer_ro/extconf.rb +0 -6
- data/ext/gherkin_lexer_ro/gherkin_lexer_ro.c +0 -1427
- data/ext/gherkin_lexer_ru/extconf.rb +0 -6
- data/ext/gherkin_lexer_ru/gherkin_lexer_ru.c +0 -2071
- data/ext/gherkin_lexer_sk/extconf.rb +0 -6
- data/ext/gherkin_lexer_sk/gherkin_lexer_sk.c +0 -1739
- data/ext/gherkin_lexer_sr_cyrl/extconf.rb +0 -6
- data/ext/gherkin_lexer_sr_cyrl/gherkin_lexer_sr_cyrl.c +0 -2112
- data/ext/gherkin_lexer_sr_latn/extconf.rb +0 -6
- data/ext/gherkin_lexer_sr_latn/gherkin_lexer_sr_latn.c +0 -1567
- data/ext/gherkin_lexer_sv/extconf.rb +0 -6
- data/ext/gherkin_lexer_sv/gherkin_lexer_sv.c +0 -1324
- data/ext/gherkin_lexer_th/extconf.rb +0 -6
- data/ext/gherkin_lexer_th/gherkin_lexer_th.c +0 -2840
- data/ext/gherkin_lexer_tl/extconf.rb +0 -6
- data/ext/gherkin_lexer_tl/gherkin_lexer_tl.c +0 -2021
- data/ext/gherkin_lexer_tr/extconf.rb +0 -6
- data/ext/gherkin_lexer_tr/gherkin_lexer_tr.c +0 -1347
- data/ext/gherkin_lexer_tt/extconf.rb +0 -6
- data/ext/gherkin_lexer_tt/gherkin_lexer_tt.c +0 -1936
- data/ext/gherkin_lexer_uk/extconf.rb +0 -6
- data/ext/gherkin_lexer_uk/gherkin_lexer_uk.c +0 -1941
- data/ext/gherkin_lexer_uz/extconf.rb +0 -6
- data/ext/gherkin_lexer_uz/gherkin_lexer_uz.c +0 -1651
- data/ext/gherkin_lexer_vi/extconf.rb +0 -6
- data/ext/gherkin_lexer_vi/gherkin_lexer_vi.c +0 -1458
- data/ext/gherkin_lexer_zh_cn/extconf.rb +0 -6
- data/ext/gherkin_lexer_zh_cn/gherkin_lexer_zh_cn.c +0 -1314
- data/ext/gherkin_lexer_zh_tw/extconf.rb +0 -6
- data/ext/gherkin_lexer_zh_tw/gherkin_lexer_zh_tw.c +0 -1307
- data/features/.cucumber/stepdefs.json +0 -244
- data/features/escaped_pipes.feature +0 -8
- data/features/feature_parser.feature +0 -237
- data/features/json_formatter.feature +0 -498
- data/features/json_parser.feature +0 -331
- data/features/native_lexer.feature +0 -19
- data/features/parser_with_native_lexer.feature +0 -205
- data/features/pretty_formatter.feature +0 -17
- data/features/step_definitions/eyeball_steps.rb +0 -3
- data/features/step_definitions/gherkin_steps.rb +0 -29
- data/features/step_definitions/json_formatter_steps.rb +0 -30
- data/features/step_definitions/json_parser_steps.rb +0 -21
- data/features/step_definitions/pretty_formatter_steps.rb +0 -85
- data/features/steps_parser.feature +0 -46
- data/features/support/env.rb +0 -41
- data/install_mingw_os_x.sh +0 -5
- data/js/.npmignore +0 -1
- data/js/lib/gherkin/lexer/.npmignore +0 -0
- data/lib/gherkin.rb +0 -2
- data/lib/gherkin/README.md +0 -7
- data/lib/gherkin/c_lexer.rb +0 -17
- data/lib/gherkin/formatter/ansi_escapes.rb +0 -97
- data/lib/gherkin/formatter/argument.rb +0 -16
- data/lib/gherkin/formatter/escaping.rb +0 -15
- data/lib/gherkin/formatter/filter_formatter.rb +0 -150
- data/lib/gherkin/formatter/hashable.rb +0 -25
- data/lib/gherkin/formatter/json_formatter.rb +0 -133
- data/lib/gherkin/formatter/line_filter.rb +0 -26
- data/lib/gherkin/formatter/model.rb +0 -281
- data/lib/gherkin/formatter/pretty_formatter.rb +0 -245
- data/lib/gherkin/formatter/regexp_filter.rb +0 -21
- data/lib/gherkin/formatter/step_printer.rb +0 -21
- data/lib/gherkin/formatter/tag_count_formatter.rb +0 -47
- data/lib/gherkin/formatter/tag_filter.rb +0 -19
- data/lib/gherkin/i18n.json +0 -786
- data/lib/gherkin/i18n.rb +0 -176
- data/lib/gherkin/json_parser.rb +0 -177
- data/lib/gherkin/lexer/ar.rb +0 -1170
- data/lib/gherkin/lexer/bg.rb +0 -1382
- data/lib/gherkin/lexer/bm.rb +0 -1250
- data/lib/gherkin/lexer/ca.rb +0 -1310
- data/lib/gherkin/lexer/cs.rb +0 -1246
- data/lib/gherkin/lexer/cy_gb.rb +0 -1032
- data/lib/gherkin/lexer/da.rb +0 -1048
- data/lib/gherkin/lexer/de.rb +0 -1166
- data/lib/gherkin/lexer/el.rb +0 -1628
- data/lib/gherkin/lexer/en.rb +0 -1156
- data/lib/gherkin/lexer/en_au.rb +0 -1486
- data/lib/gherkin/lexer/en_lol.rb +0 -934
- data/lib/gherkin/lexer/en_old.rb +0 -1037
- data/lib/gherkin/lexer/en_pirate.rb +0 -1210
- data/lib/gherkin/lexer/en_scouse.rb +0 -1362
- data/lib/gherkin/lexer/en_tx.rb +0 -1016
- data/lib/gherkin/lexer/encoding.rb +0 -41
- data/lib/gherkin/lexer/eo.rb +0 -995
- data/lib/gherkin/lexer/es.rb +0 -1140
- data/lib/gherkin/lexer/et.rb +0 -990
- data/lib/gherkin/lexer/fa.rb +0 -1214
- data/lib/gherkin/lexer/fi.rb +0 -969
- data/lib/gherkin/lexer/fr.rb +0 -1228
- data/lib/gherkin/lexer/gl.rb +0 -1117
- data/lib/gherkin/lexer/he.rb +0 -1118
- data/lib/gherkin/lexer/hi.rb +0 -1559
- data/lib/gherkin/lexer/hr.rb +0 -1066
- data/lib/gherkin/lexer/hu.rb +0 -1118
- data/lib/gherkin/lexer/i18n_lexer.rb +0 -48
- data/lib/gherkin/lexer/id.rb +0 -963
- data/lib/gherkin/lexer/is.rb +0 -1120
- data/lib/gherkin/lexer/it.rb +0 -1086
- data/lib/gherkin/lexer/ja.rb +0 -1418
- data/lib/gherkin/lexer/kn.rb +0 -1672
- data/lib/gherkin/lexer/ko.rb +0 -1102
- data/lib/gherkin/lexer/lt.rb +0 -1045
- data/lib/gherkin/lexer/lu.rb +0 -1132
- data/lib/gherkin/lexer/lv.rb +0 -1166
- data/lib/gherkin/lexer/nl.rb +0 -1115
- data/lib/gherkin/lexer/no.rb +0 -1060
- data/lib/gherkin/lexer/pa.rb +0 -1852
- data/lib/gherkin/lexer/pl.rb +0 -1457
- data/lib/gherkin/lexer/pt.rb +0 -1430
- data/lib/gherkin/lexer/ro.rb +0 -1164
- data/lib/gherkin/lexer/ru.rb +0 -1766
- data/lib/gherkin/lexer/sk.rb +0 -1452
- data/lib/gherkin/lexer/sr_cyrl.rb +0 -1803
- data/lib/gherkin/lexer/sr_latn.rb +0 -1294
- data/lib/gherkin/lexer/sv.rb +0 -1070
- data/lib/gherkin/lexer/th.rb +0 -2492
- data/lib/gherkin/lexer/tl.rb +0 -1726
- data/lib/gherkin/lexer/tr.rb +0 -1092
- data/lib/gherkin/lexer/tt.rb +0 -1643
- data/lib/gherkin/lexer/uk.rb +0 -1646
- data/lib/gherkin/lexer/uz.rb +0 -1376
- data/lib/gherkin/lexer/vi.rb +0 -1198
- data/lib/gherkin/lexer/zh_cn.rb +0 -1058
- data/lib/gherkin/lexer/zh_tw.rb +0 -1052
- data/lib/gherkin/listener/event.rb +0 -45
- data/lib/gherkin/listener/formatter_listener.rb +0 -150
- data/lib/gherkin/native.rb +0 -7
- data/lib/gherkin/native/java.rb +0 -72
- data/lib/gherkin/native/null.rb +0 -5
- data/lib/gherkin/native/therubyracer.rb +0 -41
- data/lib/gherkin/parser/meta.txt +0 -5
- data/lib/gherkin/parser/parser.rb +0 -166
- data/lib/gherkin/parser/root.txt +0 -11
- data/lib/gherkin/parser/steps.txt +0 -4
- data/lib/gherkin/platform.rb +0 -13
- data/lib/gherkin/rubify.rb +0 -31
- data/lib/gherkin/tag_expression.rb +0 -63
- data/ragel/lexer.c.rl.erb +0 -454
- data/ragel/lexer.java.rl.erb +0 -219
- data/ragel/lexer.js.rl.erb +0 -322
- data/ragel/lexer.rb.rl.erb +0 -179
- data/ragel/lexer_common.rl.erb +0 -50
- data/spec/gherkin/c_lexer_spec.rb +0 -22
- data/spec/gherkin/fixtures/1.feature +0 -8
- data/spec/gherkin/fixtures/comments_in_table.feature +0 -9
- data/spec/gherkin/fixtures/complex.feature +0 -45
- data/spec/gherkin/fixtures/complex.json +0 -139
- data/spec/gherkin/fixtures/complex_for_filtering.feature +0 -60
- data/spec/gherkin/fixtures/complex_with_tags.feature +0 -61
- data/spec/gherkin/fixtures/dos_line_endings.feature +0 -45
- data/spec/gherkin/fixtures/examples_with_only_header.feature +0 -14
- data/spec/gherkin/fixtures/hantu_pisang.feature +0 -35
- data/spec/gherkin/fixtures/i18n_fr.feature +0 -14
- data/spec/gherkin/fixtures/i18n_fr2.feature +0 -8
- data/spec/gherkin/fixtures/i18n_no.feature +0 -7
- data/spec/gherkin/fixtures/i18n_pt1.feature +0 -44
- data/spec/gherkin/fixtures/i18n_pt2.feature +0 -4
- data/spec/gherkin/fixtures/i18n_pt3.feature +0 -4
- data/spec/gherkin/fixtures/i18n_pt4.feature +0 -4
- data/spec/gherkin/fixtures/i18n_zh-CN.feature +0 -9
- data/spec/gherkin/fixtures/iso-8859-1.feature +0 -6
- data/spec/gherkin/fixtures/issue_145.feature +0 -22
- data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +0 -13
- data/spec/gherkin/fixtures/scenario_without_steps.feature +0 -5
- data/spec/gherkin/fixtures/simple_with_comments.feature +0 -7
- data/spec/gherkin/fixtures/simple_with_tags.feature +0 -11
- data/spec/gherkin/fixtures/with_bom.feature +0 -3
- data/spec/gherkin/fixtures/with_bom_and_language_spec.feature +0 -4
- data/spec/gherkin/formatter/ansi_escapes_spec.rb +0 -32
- data/spec/gherkin/formatter/filter_formatter_spec.rb +0 -204
- data/spec/gherkin/formatter/json_formatter_spec.rb +0 -179
- data/spec/gherkin/formatter/model_spec.rb +0 -28
- data/spec/gherkin/formatter/pretty_formatter_spec.rb +0 -184
- data/spec/gherkin/formatter/spaces.feature +0 -9
- data/spec/gherkin/formatter/step_printer_spec.rb +0 -55
- data/spec/gherkin/formatter/tabs.feature +0 -9
- data/spec/gherkin/formatter/tag_count_formatter_spec.rb +0 -30
- data/spec/gherkin/i18n_spec.rb +0 -256
- data/spec/gherkin/java_lexer_spec.rb +0 -20
- data/spec/gherkin/json_parser_spec.rb +0 -165
- data/spec/gherkin/lexer/i18n_lexer_spec.rb +0 -65
- data/spec/gherkin/native_lexer_spec.rb +0 -29
- data/spec/gherkin/parser/parser_spec.rb +0 -16
- data/spec/gherkin/rubify_spec.rb +0 -23
- data/spec/gherkin/sexp_recorder.rb +0 -59
- data/spec/gherkin/shared/doc_string_group.rb +0 -161
- data/spec/gherkin/shared/encoding_group.rb +0 -48
- data/spec/gherkin/shared/lexer_group.rb +0 -589
- data/spec/gherkin/shared/row_group.rb +0 -123
- data/spec/gherkin/shared/tags_group.rb +0 -52
- data/spec/gherkin/tag_expression_spec.rb +0 -146
- data/spec/spec_helper.rb +0 -94
- data/tasks/apidoc.rake +0 -32
- data/tasks/bench.rake +0 -184
- data/tasks/bench/feature_builder.rb +0 -49
- data/tasks/bench/null_listener.rb +0 -4
- data/tasks/compile.rake +0 -83
- data/tasks/cucumber.rake +0 -23
- data/tasks/gems.rake +0 -46
- data/tasks/ikvm.rake +0 -126
- data/tasks/ragel_task.rb +0 -124
- data/tasks/release.rake +0 -34
- data/tasks/rspec.rake +0 -6
- data/tasks/yard/default/layout/html/bubble_32x32.png +0 -0
- data/tasks/yard/default/layout/html/bubble_48x48.png +0 -0
- data/tasks/yard/default/layout/html/footer.erb +0 -5
- data/tasks/yard/default/layout/html/index.erb +0 -1
- data/tasks/yard/default/layout/html/layout.erb +0 -25
- data/tasks/yard/default/layout/html/logo.erb +0 -1
- data/tasks/yard/default/layout/html/setup.rb +0 -4
data/lib/gherkin/parser/root.txt
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
| | feature | background | scenario | scenario_outline | examples | step | row | doc_string | eof | comment | tag |
|
2
|
-
| root | feature | E | E | E | E | E | E | E | eof | push(meta) | push(meta) |
|
3
|
-
| feature | E | background | scenario | scenario_outline | E | E | E | E | eof | push(meta) | push(meta) |
|
4
|
-
| step | E | E | scenario | scenario_outline | E | step | step | step | eof | push(meta) | push(meta) |
|
5
|
-
| outline_step | E | E | scenario | scenario_outline | examples | outline_step | outline_step | outline_step | eof | push(meta) | push(meta) |
|
6
|
-
| background | E | E | scenario | scenario_outline | E | step | E | E | eof | push(meta) | push(meta) |
|
7
|
-
| scenario | E | E | scenario | scenario_outline | E | step | E | E | eof | push(meta) | push(meta) |
|
8
|
-
| scenario_outline | E | E | E | E | E | outline_step | E | E | eof | push(meta) | push(meta) |
|
9
|
-
| examples | E | E | E | E | E | E | examples_table | E | eof | push(meta) | push(meta) |
|
10
|
-
| examples_table | E | E | scenario | scenario_outline | examples | E | examples_table | E | eof | push(meta) | push(meta) |
|
11
|
-
| eof | E | E | E | E | E | E | E | E | E | E | E |
|
@@ -1,4 +0,0 @@
|
|
1
|
-
| | feature | background | scenario | scenario_outline | examples | step | row | doc_string | eof | comment | tag |
|
2
|
-
| steps | E | E | E | E | E | step | E | E | eof | E | E |
|
3
|
-
| step | E | E | E | E | E | step | step | steps | eof | E | E |
|
4
|
-
| eof | E | E | E | E | E | E | E | E | E | E | E |
|
data/lib/gherkin/platform.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# Detect the platform we're running and warn if it is not supported
|
2
|
-
|
3
|
-
module Gherkin
|
4
|
-
unless defined?(Gherkin::VERSION)
|
5
|
-
# See the comment in gherkin.gemspec if you bump the MINOR version (MAJOR.MINOR.PATCH).
|
6
|
-
VERSION = '2.12.2'
|
7
|
-
JRUBY = defined?(JRUBY_VERSION)
|
8
|
-
|
9
|
-
if !JRUBY && !(RUBY_VERSION =~ /^(1\.9\.3|2\.0)/)
|
10
|
-
warn("WARNING: Unsupported Ruby version - #{RUBY_VERSION}")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/gherkin/rubify.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Gherkin
|
2
|
-
module Rubify
|
3
|
-
if defined?(JRUBY_VERSION)
|
4
|
-
# Translate Java objects to Ruby.
|
5
|
-
# This is especially important to convert java.util.List coming
|
6
|
-
# from Java and back to a Ruby Array.
|
7
|
-
def rubify(o)
|
8
|
-
case (o)
|
9
|
-
when Java.java.util.Collection, Array
|
10
|
-
rubified_array = o.map{ |e| rubify(e) }
|
11
|
-
if o.respond_to?(:line)
|
12
|
-
class << rubified_array
|
13
|
-
attr_accessor :line
|
14
|
-
end
|
15
|
-
rubified_array.line = o.line
|
16
|
-
end
|
17
|
-
rubified_array
|
18
|
-
when Java.gherkin.formatter.model.DocString
|
19
|
-
require 'gherkin/formatter/model'
|
20
|
-
Formatter::Model::DocString.new(o.content_type, o.value, o.line)
|
21
|
-
else
|
22
|
-
o
|
23
|
-
end
|
24
|
-
end
|
25
|
-
else
|
26
|
-
def rubify(o)
|
27
|
-
o
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'gherkin/native'
|
2
|
-
|
3
|
-
module Gherkin
|
4
|
-
class TagExpression
|
5
|
-
native_impl('gherkin')
|
6
|
-
|
7
|
-
attr_reader :limits
|
8
|
-
|
9
|
-
def initialize(tag_expressions)
|
10
|
-
@ands = []
|
11
|
-
@limits = {}
|
12
|
-
tag_expressions.each do |expr|
|
13
|
-
add(expr.strip.split(/\s*,\s*/))
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def empty?
|
18
|
-
@ands.empty?
|
19
|
-
end
|
20
|
-
|
21
|
-
def evaluate(tags)
|
22
|
-
return true if @ands.flatten.empty?
|
23
|
-
vars = Hash[*tags.map{|tag| [tag.name, true]}.flatten]
|
24
|
-
raise "No vars" if vars.nil? # Useless statement to prevent ruby warnings about unused var
|
25
|
-
!!Kernel.eval(ruby_expression)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def add(tags_with_negation_and_limits)
|
31
|
-
negatives, positives = tags_with_negation_and_limits.partition{|tag| tag =~ /^~/}
|
32
|
-
@ands << (store_and_extract_limits(negatives, true) + store_and_extract_limits(positives, false))
|
33
|
-
end
|
34
|
-
|
35
|
-
def store_and_extract_limits(tags_with_negation_and_limits, negated)
|
36
|
-
tags_with_negation = []
|
37
|
-
tags_with_negation_and_limits.each do |tag_with_negation_and_limit|
|
38
|
-
tag_with_negation, limit = tag_with_negation_and_limit.split(':')
|
39
|
-
tags_with_negation << tag_with_negation
|
40
|
-
if limit
|
41
|
-
tag_without_negation = negated ? tag_with_negation[1..-1] : tag_with_negation
|
42
|
-
if @limits[tag_without_negation] && @limits[tag_without_negation] != limit.to_i
|
43
|
-
raise "Inconsistent tag limits for #{tag_without_negation}: #{@limits[tag_without_negation]} and #{limit.to_i}"
|
44
|
-
end
|
45
|
-
@limits[tag_without_negation] = limit.to_i
|
46
|
-
end
|
47
|
-
end
|
48
|
-
tags_with_negation
|
49
|
-
end
|
50
|
-
|
51
|
-
def ruby_expression
|
52
|
-
"(" + @ands.map do |ors|
|
53
|
-
ors.map do |tag|
|
54
|
-
if tag =~ /^~(.*)/
|
55
|
-
"!vars['#{$1}']"
|
56
|
-
else
|
57
|
-
"vars['#{tag}']"
|
58
|
-
end
|
59
|
-
end.join("||")
|
60
|
-
end.join(")&&(") + ")"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
data/ragel/lexer.c.rl.erb
DELETED
@@ -1,454 +0,0 @@
|
|
1
|
-
#include <assert.h>
|
2
|
-
#include <ruby.h>
|
3
|
-
|
4
|
-
#if defined(_WIN32)
|
5
|
-
#include <stddef.h>
|
6
|
-
#endif
|
7
|
-
|
8
|
-
#ifdef HAVE_RUBY_RE_H
|
9
|
-
#include <ruby/re.h>
|
10
|
-
#else
|
11
|
-
#include <re.h>
|
12
|
-
#endif
|
13
|
-
|
14
|
-
#ifdef HAVE_RUBY_ENCODING_H
|
15
|
-
#include <ruby/encoding.h>
|
16
|
-
#define ENCODED_STR_NEW(ptr, len) \
|
17
|
-
rb_enc_str_new(ptr, len, rb_utf8_encoding())
|
18
|
-
#else
|
19
|
-
#define ENCODED_STR_NEW(ptr, len) \
|
20
|
-
rb_str_new(ptr, len)
|
21
|
-
#endif
|
22
|
-
|
23
|
-
#ifndef RSTRING_PTR
|
24
|
-
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
25
|
-
#endif
|
26
|
-
|
27
|
-
#ifndef RSTRING_LEN
|
28
|
-
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
29
|
-
#endif
|
30
|
-
|
31
|
-
#define DATA_GET(FROM, TYPE, NAME) \
|
32
|
-
Data_Get_Struct(FROM, TYPE, NAME); \
|
33
|
-
if (NAME == NULL) { \
|
34
|
-
rb_raise(rb_eArgError, "NULL found for " # NAME " when it shouldn't be."); \
|
35
|
-
}
|
36
|
-
|
37
|
-
typedef struct lexer_state {
|
38
|
-
int content_len;
|
39
|
-
int line_number;
|
40
|
-
int current_line;
|
41
|
-
int start_col;
|
42
|
-
size_t mark;
|
43
|
-
size_t keyword_start;
|
44
|
-
size_t keyword_end;
|
45
|
-
size_t next_keyword_start;
|
46
|
-
size_t content_start;
|
47
|
-
size_t content_end;
|
48
|
-
size_t docstring_content_type_start;
|
49
|
-
size_t docstring_content_type_end;
|
50
|
-
size_t query_start;
|
51
|
-
size_t last_newline;
|
52
|
-
size_t final_newline;
|
53
|
-
} lexer_state;
|
54
|
-
|
55
|
-
static VALUE mGherkin;
|
56
|
-
static VALUE mGherkinLexer;
|
57
|
-
static VALUE mCLexer;
|
58
|
-
static VALUE cI18nLexer;
|
59
|
-
static VALUE rb_eGherkinLexingError;
|
60
|
-
|
61
|
-
#define LEN(AT, P) (P - data - lexer->AT)
|
62
|
-
#define MARK(M, P) (lexer->M = (P) - data)
|
63
|
-
#define PTR_TO(P) (data + lexer->P)
|
64
|
-
|
65
|
-
#define STORE_KW_END_CON(EVENT) \
|
66
|
-
store_multiline_kw_con(listener, # EVENT, \
|
67
|
-
PTR_TO(keyword_start), LEN(keyword_start, PTR_TO(keyword_end - 1)), \
|
68
|
-
PTR_TO(content_start), LEN(content_start, PTR_TO(content_end)), \
|
69
|
-
lexer->current_line, lexer->start_col); \
|
70
|
-
if (lexer->content_end != 0) { \
|
71
|
-
p = PTR_TO(content_end - 1); \
|
72
|
-
} \
|
73
|
-
lexer->content_end = 0
|
74
|
-
|
75
|
-
#define STORE_ATTR(ATTR) \
|
76
|
-
store_attr(listener, # ATTR, \
|
77
|
-
PTR_TO(content_start), LEN(content_start, p), \
|
78
|
-
lexer->line_number)
|
79
|
-
|
80
|
-
%%{
|
81
|
-
machine lexer;
|
82
|
-
|
83
|
-
action begin_content {
|
84
|
-
MARK(content_start, p);
|
85
|
-
lexer->current_line = lexer->line_number;
|
86
|
-
lexer->start_col = lexer->content_start - lexer->last_newline - (lexer->keyword_end - lexer->keyword_start) + 2;
|
87
|
-
}
|
88
|
-
|
89
|
-
action begin_docstring_content {
|
90
|
-
MARK(content_start, p);
|
91
|
-
}
|
92
|
-
|
93
|
-
action start_docstring {
|
94
|
-
lexer->current_line = lexer->line_number;
|
95
|
-
lexer->start_col = p - data - lexer->last_newline;
|
96
|
-
}
|
97
|
-
|
98
|
-
action store_docstring_content {
|
99
|
-
int len = LEN(content_start, PTR_TO(final_newline));
|
100
|
-
int type_len = LEN(docstring_content_type_start, PTR_TO(docstring_content_type_end));
|
101
|
-
|
102
|
-
if (len < 0) len = 0;
|
103
|
-
if (type_len < 0) len = 0;
|
104
|
-
|
105
|
-
store_docstring_content(listener, lexer->start_col, PTR_TO(docstring_content_type_start), type_len, PTR_TO(content_start), len, lexer->current_line);
|
106
|
-
}
|
107
|
-
|
108
|
-
action start_docstring_content_type {
|
109
|
-
MARK(docstring_content_type_start, p);
|
110
|
-
}
|
111
|
-
|
112
|
-
action end_docstring_content_type {
|
113
|
-
MARK(docstring_content_type_end, p);
|
114
|
-
}
|
115
|
-
|
116
|
-
action store_feature_content {
|
117
|
-
STORE_KW_END_CON(feature);
|
118
|
-
}
|
119
|
-
|
120
|
-
action store_background_content {
|
121
|
-
STORE_KW_END_CON(background);
|
122
|
-
}
|
123
|
-
|
124
|
-
action store_scenario_content {
|
125
|
-
STORE_KW_END_CON(scenario);
|
126
|
-
}
|
127
|
-
|
128
|
-
action store_scenario_outline_content {
|
129
|
-
STORE_KW_END_CON(scenario_outline);
|
130
|
-
}
|
131
|
-
|
132
|
-
action store_examples_content {
|
133
|
-
STORE_KW_END_CON(examples);
|
134
|
-
}
|
135
|
-
|
136
|
-
action store_step_content {
|
137
|
-
store_kw_con(listener, "step",
|
138
|
-
PTR_TO(keyword_start), LEN(keyword_start, PTR_TO(keyword_end)),
|
139
|
-
PTR_TO(content_start), LEN(content_start, p),
|
140
|
-
lexer->current_line);
|
141
|
-
}
|
142
|
-
|
143
|
-
action store_comment_content {
|
144
|
-
STORE_ATTR(comment);
|
145
|
-
lexer->mark = 0;
|
146
|
-
}
|
147
|
-
|
148
|
-
action store_tag_content {
|
149
|
-
STORE_ATTR(tag);
|
150
|
-
lexer->mark = 0;
|
151
|
-
}
|
152
|
-
|
153
|
-
action inc_line_number {
|
154
|
-
lexer->line_number += 1;
|
155
|
-
MARK(final_newline, p);
|
156
|
-
}
|
157
|
-
|
158
|
-
action last_newline {
|
159
|
-
MARK(last_newline, p + 1);
|
160
|
-
}
|
161
|
-
|
162
|
-
action start_keyword {
|
163
|
-
if (lexer->mark == 0) {
|
164
|
-
MARK(mark, p);
|
165
|
-
}
|
166
|
-
}
|
167
|
-
|
168
|
-
action end_keyword {
|
169
|
-
MARK(keyword_end, p);
|
170
|
-
MARK(keyword_start, PTR_TO(mark));
|
171
|
-
MARK(content_start, p + 1);
|
172
|
-
lexer->mark = 0;
|
173
|
-
}
|
174
|
-
|
175
|
-
action next_keyword_start {
|
176
|
-
MARK(content_end, p);
|
177
|
-
}
|
178
|
-
|
179
|
-
action start_row {
|
180
|
-
p = p - 1;
|
181
|
-
lexer->current_line = lexer->line_number;
|
182
|
-
current_row = rb_ary_new();
|
183
|
-
}
|
184
|
-
|
185
|
-
action begin_cell_content {
|
186
|
-
MARK(content_start, p);
|
187
|
-
}
|
188
|
-
|
189
|
-
action store_cell_content {
|
190
|
-
VALUE re_pipe, re_newline, re_backslash;
|
191
|
-
VALUE con = ENCODED_STR_NEW(PTR_TO(content_start), LEN(content_start, p));
|
192
|
-
rb_funcall(con, rb_intern("strip!"), 0);
|
193
|
-
re_pipe = rb_reg_regcomp(rb_str_new2("\\\\\\|"));
|
194
|
-
re_newline = rb_reg_regcomp(rb_str_new2("\\\\n"));
|
195
|
-
re_backslash = rb_reg_regcomp(rb_str_new2("\\\\\\\\"));
|
196
|
-
rb_funcall(con, rb_intern("gsub!"), 2, re_pipe, rb_str_new2("|"));
|
197
|
-
rb_funcall(con, rb_intern("gsub!"), 2, re_newline, rb_str_new2("\n"));
|
198
|
-
rb_funcall(con, rb_intern("gsub!"), 2, re_backslash, rb_str_new2("\\"));
|
199
|
-
|
200
|
-
rb_ary_push(current_row, con);
|
201
|
-
}
|
202
|
-
|
203
|
-
action store_row {
|
204
|
-
rb_funcall(listener, rb_intern("row"), 2, current_row, INT2FIX(lexer->current_line));
|
205
|
-
}
|
206
|
-
|
207
|
-
action end_feature {
|
208
|
-
int line;
|
209
|
-
if (cs < lexer_first_final) {
|
210
|
-
size_t count = 0;
|
211
|
-
VALUE newstr_val;
|
212
|
-
char *newstr;
|
213
|
-
int newstr_count = 0;
|
214
|
-
size_t len;
|
215
|
-
const char *buff;
|
216
|
-
if (lexer->last_newline != 0) {
|
217
|
-
len = LEN(last_newline, eof);
|
218
|
-
buff = PTR_TO(last_newline);
|
219
|
-
} else {
|
220
|
-
len = strlen(data);
|
221
|
-
buff = data;
|
222
|
-
}
|
223
|
-
|
224
|
-
/* Allocate as a ruby string so that it gets cleaned up by GC */
|
225
|
-
newstr_val = rb_str_new(buff, len);
|
226
|
-
newstr = RSTRING_PTR(newstr_val);
|
227
|
-
|
228
|
-
|
229
|
-
for (count = 0; count < len; count++) {
|
230
|
-
if(buff[count] == 10) {
|
231
|
-
newstr[newstr_count] = '\0'; /* terminate new string at first newline found */
|
232
|
-
break;
|
233
|
-
} else {
|
234
|
-
if (buff[count] == '%') {
|
235
|
-
newstr[newstr_count++] = buff[count];
|
236
|
-
newstr[newstr_count] = buff[count];
|
237
|
-
} else {
|
238
|
-
newstr[newstr_count] = buff[count];
|
239
|
-
}
|
240
|
-
}
|
241
|
-
newstr_count++;
|
242
|
-
}
|
243
|
-
|
244
|
-
line = lexer->line_number;
|
245
|
-
lexer_init(lexer); /* Re-initialize so we can scan again with the same lexer */
|
246
|
-
raise_lexer_error(newstr, line);
|
247
|
-
} else {
|
248
|
-
rb_funcall(listener, rb_intern("eof"), 0);
|
249
|
-
}
|
250
|
-
}
|
251
|
-
|
252
|
-
include lexer_common "lexer_common.<%= @i18n.underscored_iso_code %>.rl";
|
253
|
-
|
254
|
-
}%%
|
255
|
-
|
256
|
-
/** Data **/
|
257
|
-
%% write data;
|
258
|
-
|
259
|
-
static VALUE
|
260
|
-
unindent(VALUE con, int start_col)
|
261
|
-
{
|
262
|
-
VALUE re;
|
263
|
-
/* Gherkin will crash gracefully if the string representation of start_col pushes the pattern past 32 characters */
|
264
|
-
char pat[32];
|
265
|
-
snprintf(pat, 32, "^[\t ]{0,%d}", start_col);
|
266
|
-
re = rb_reg_regcomp(rb_str_new2(pat));
|
267
|
-
rb_funcall(con, rb_intern("gsub!"), 2, re, rb_str_new2(""));
|
268
|
-
|
269
|
-
return Qnil;
|
270
|
-
|
271
|
-
}
|
272
|
-
|
273
|
-
static void
|
274
|
-
store_kw_con(VALUE listener, const char * event_name,
|
275
|
-
const char * keyword_at, size_t keyword_length,
|
276
|
-
const char * at, size_t length,
|
277
|
-
int current_line)
|
278
|
-
{
|
279
|
-
VALUE con = Qnil, kw = Qnil;
|
280
|
-
kw = ENCODED_STR_NEW(keyword_at, keyword_length);
|
281
|
-
con = ENCODED_STR_NEW(at, length);
|
282
|
-
rb_funcall(con, rb_intern("strip!"), 0);
|
283
|
-
rb_funcall(listener, rb_intern(event_name), 3, kw, con, INT2FIX(current_line));
|
284
|
-
}
|
285
|
-
|
286
|
-
static void
|
287
|
-
store_multiline_kw_con(VALUE listener, const char * event_name,
|
288
|
-
const char * keyword_at, size_t keyword_length,
|
289
|
-
const char * at, size_t length,
|
290
|
-
int current_line, int start_col)
|
291
|
-
{
|
292
|
-
VALUE split;
|
293
|
-
VALUE con = Qnil, kw = Qnil, name = Qnil, desc = Qnil;
|
294
|
-
|
295
|
-
kw = ENCODED_STR_NEW(keyword_at, keyword_length);
|
296
|
-
con = ENCODED_STR_NEW(at, length);
|
297
|
-
|
298
|
-
unindent(con, start_col);
|
299
|
-
|
300
|
-
split = rb_str_split(con, "\n");
|
301
|
-
|
302
|
-
name = rb_funcall(split, rb_intern("shift"), 0);
|
303
|
-
desc = rb_ary_join(split, rb_str_new2( "\n" ));
|
304
|
-
|
305
|
-
if( name == Qnil )
|
306
|
-
{
|
307
|
-
name = rb_str_new2("");
|
308
|
-
}
|
309
|
-
if( rb_funcall(desc, rb_intern("size"), 0) == 0)
|
310
|
-
{
|
311
|
-
desc = rb_str_new2("");
|
312
|
-
}
|
313
|
-
rb_funcall(name, rb_intern("strip!"), 0);
|
314
|
-
rb_funcall(desc, rb_intern("rstrip!"), 0);
|
315
|
-
rb_funcall(listener, rb_intern(event_name), 4, kw, name, desc, INT2FIX(current_line));
|
316
|
-
}
|
317
|
-
|
318
|
-
static void
|
319
|
-
store_attr(VALUE listener, const char * attr_type,
|
320
|
-
const char * at, size_t length,
|
321
|
-
int line)
|
322
|
-
{
|
323
|
-
VALUE val = ENCODED_STR_NEW(at, length);
|
324
|
-
rb_funcall(listener, rb_intern(attr_type), 2, val, INT2FIX(line));
|
325
|
-
}
|
326
|
-
static void
|
327
|
-
store_docstring_content(VALUE listener,
|
328
|
-
int start_col,
|
329
|
-
const char *type_at, size_t type_length,
|
330
|
-
const char *at, size_t length,
|
331
|
-
int current_line)
|
332
|
-
{
|
333
|
-
VALUE re2;
|
334
|
-
VALUE unescape_escaped_quotes;
|
335
|
-
VALUE con = ENCODED_STR_NEW(at, length);
|
336
|
-
VALUE con_type = ENCODED_STR_NEW(type_at, type_length);
|
337
|
-
|
338
|
-
unindent(con, start_col);
|
339
|
-
|
340
|
-
re2 = rb_reg_regcomp(rb_str_new2("\r\\Z"));
|
341
|
-
unescape_escaped_quotes = rb_reg_regcomp(rb_str_new2("\\\\\"\\\\\"\\\\\""));
|
342
|
-
rb_funcall(con, rb_intern("sub!"), 2, re2, rb_str_new2(""));
|
343
|
-
rb_funcall(con_type, rb_intern("strip!"), 0);
|
344
|
-
rb_funcall(con, rb_intern("gsub!"), 2, unescape_escaped_quotes, rb_str_new2("\"\"\""));
|
345
|
-
rb_funcall(listener, rb_intern("doc_string"), 3, con_type, con, INT2FIX(current_line));
|
346
|
-
}
|
347
|
-
static void
|
348
|
-
raise_lexer_error(const char * at, int line)
|
349
|
-
{
|
350
|
-
rb_raise(rb_eGherkinLexingError, "Lexing error on line %d: '%s'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.", line, at);
|
351
|
-
}
|
352
|
-
|
353
|
-
static void lexer_init(lexer_state *lexer) {
|
354
|
-
lexer->content_start = 0;
|
355
|
-
lexer->content_end = 0;
|
356
|
-
lexer->content_len = 0;
|
357
|
-
lexer->docstring_content_type_start = 0;
|
358
|
-
lexer->docstring_content_type_end = 0;
|
359
|
-
lexer->mark = 0;
|
360
|
-
lexer->keyword_start = 0;
|
361
|
-
lexer->keyword_end = 0;
|
362
|
-
lexer->next_keyword_start = 0;
|
363
|
-
lexer->line_number = 1;
|
364
|
-
lexer->last_newline = 0;
|
365
|
-
lexer->final_newline = 0;
|
366
|
-
lexer->start_col = 0;
|
367
|
-
}
|
368
|
-
|
369
|
-
static VALUE CLexer_alloc(VALUE klass)
|
370
|
-
{
|
371
|
-
VALUE obj;
|
372
|
-
lexer_state *lxr = ALLOC(lexer_state);
|
373
|
-
lexer_init(lxr);
|
374
|
-
|
375
|
-
obj = Data_Wrap_Struct(klass, NULL, -1, lxr);
|
376
|
-
|
377
|
-
return obj;
|
378
|
-
}
|
379
|
-
|
380
|
-
static VALUE CLexer_init(VALUE self, VALUE listener)
|
381
|
-
{
|
382
|
-
lexer_state *lxr;
|
383
|
-
rb_iv_set(self, "@listener", listener);
|
384
|
-
|
385
|
-
lxr = NULL;
|
386
|
-
DATA_GET(self, lexer_state, lxr);
|
387
|
-
lexer_init(lxr);
|
388
|
-
|
389
|
-
return self;
|
390
|
-
}
|
391
|
-
|
392
|
-
static VALUE CLexer_scan(VALUE self, VALUE input)
|
393
|
-
{
|
394
|
-
VALUE input_copy;
|
395
|
-
char *data;
|
396
|
-
size_t len;
|
397
|
-
VALUE listener = rb_iv_get(self, "@listener");
|
398
|
-
|
399
|
-
lexer_state *lexer;
|
400
|
-
lexer = NULL;
|
401
|
-
DATA_GET(self, lexer_state, lexer);
|
402
|
-
|
403
|
-
input_copy = rb_str_dup(input);
|
404
|
-
|
405
|
-
rb_str_append(input_copy, rb_str_new2("\n%_FEATURE_END_%"));
|
406
|
-
data = RSTRING_PTR(input_copy);
|
407
|
-
len = RSTRING_LEN(input_copy);
|
408
|
-
|
409
|
-
if (len == 0) {
|
410
|
-
rb_raise(rb_eGherkinLexingError, "No content to lex.");
|
411
|
-
} else {
|
412
|
-
|
413
|
-
const char *p, *pe, *eof;
|
414
|
-
int cs = 0;
|
415
|
-
|
416
|
-
VALUE current_row = Qnil;
|
417
|
-
|
418
|
-
p = data;
|
419
|
-
pe = data + len;
|
420
|
-
eof = pe;
|
421
|
-
|
422
|
-
assert(*pe == '\0' && "pointer does not end on NULL");
|
423
|
-
|
424
|
-
%% write init;
|
425
|
-
%% write exec;
|
426
|
-
|
427
|
-
assert(p <= pe && "data overflow after parsing execute");
|
428
|
-
assert(lexer->content_start <= len && "content starts after data end");
|
429
|
-
assert(lexer->mark < len && "mark is after data end");
|
430
|
-
|
431
|
-
/* Reset lexer by re-initializing the whole thing */
|
432
|
-
lexer_init(lexer);
|
433
|
-
|
434
|
-
if (cs == lexer_error) {
|
435
|
-
rb_raise(rb_eGherkinLexingError, "Invalid format, lexing fails.");
|
436
|
-
} else {
|
437
|
-
return Qtrue;
|
438
|
-
}
|
439
|
-
}
|
440
|
-
}
|
441
|
-
|
442
|
-
void Init_gherkin_lexer_<%= @i18n.underscored_iso_code %>()
|
443
|
-
{
|
444
|
-
mGherkin = rb_define_module("Gherkin");
|
445
|
-
mGherkinLexer = rb_define_module_under(mGherkin, "Lexer");
|
446
|
-
rb_eGherkinLexingError = rb_const_get(mGherkinLexer, rb_intern("LexingError"));
|
447
|
-
|
448
|
-
mCLexer = rb_define_module_under(mGherkin, "CLexer");
|
449
|
-
cI18nLexer = rb_define_class_under(mCLexer, "<%= @i18n.underscored_iso_code.capitalize %>", rb_cObject);
|
450
|
-
rb_define_alloc_func(cI18nLexer, CLexer_alloc);
|
451
|
-
rb_define_method(cI18nLexer, "initialize", CLexer_init, 1);
|
452
|
-
rb_define_method(cI18nLexer, "scan", CLexer_scan, 1);
|
453
|
-
}
|
454
|
-
|