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/ragel/lexer.java.rl.erb
DELETED
@@ -1,219 +0,0 @@
|
|
1
|
-
package gherkin.lexer;
|
2
|
-
|
3
|
-
import java.io.UnsupportedEncodingException;
|
4
|
-
import java.util.List;
|
5
|
-
import java.util.ArrayList;
|
6
|
-
import java.util.regex.Pattern;
|
7
|
-
import gherkin.lexer.Lexer;
|
8
|
-
import gherkin.lexer.Listener;
|
9
|
-
import gherkin.lexer.LexingError;
|
10
|
-
|
11
|
-
public class <%= @i18n.underscored_iso_code.capitalize %> implements Lexer {
|
12
|
-
%%{
|
13
|
-
machine lexer;
|
14
|
-
alphtype byte;
|
15
|
-
|
16
|
-
action begin_content {
|
17
|
-
contentStart = p;
|
18
|
-
currentLine = lineNumber;
|
19
|
-
if(keyword != null) {
|
20
|
-
startCol = p - lastNewline - (keyword.length() + 1);
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
action start_docstring {
|
25
|
-
currentLine = lineNumber;
|
26
|
-
startCol = p - lastNewline;
|
27
|
-
}
|
28
|
-
|
29
|
-
action begin_docstring_content {
|
30
|
-
contentStart = p;
|
31
|
-
}
|
32
|
-
|
33
|
-
action start_docstring_content_type {
|
34
|
-
docstringContentTypeStart = p;
|
35
|
-
}
|
36
|
-
|
37
|
-
action end_docstring_content_type {
|
38
|
-
docstringContentTypeEnd = p;
|
39
|
-
}
|
40
|
-
|
41
|
-
action store_docstring_content {
|
42
|
-
String con = unindent(startCol, substring(data, contentStart, nextKeywordStart-1).replaceFirst("(\\r?\\n)?([\\t ])*\\Z", "").replace("\\\"\\\"\\\"", "\"\"\""));
|
43
|
-
String conType = substring(data, docstringContentTypeStart, docstringContentTypeEnd).trim();
|
44
|
-
listener.docString(conType, con, currentLine);
|
45
|
-
}
|
46
|
-
|
47
|
-
action store_feature_content {
|
48
|
-
String[] nameDescription = nameAndUnindentedDescription(startCol, keywordContent(data, p, eof, nextKeywordStart, contentStart));
|
49
|
-
listener.feature(keyword, nameDescription[0], nameDescription[1], currentLine);
|
50
|
-
if(nextKeywordStart != -1) p = nextKeywordStart - 1;
|
51
|
-
nextKeywordStart = -1;
|
52
|
-
}
|
53
|
-
|
54
|
-
action store_background_content {
|
55
|
-
String[] nameDescription = nameAndUnindentedDescription(startCol, keywordContent(data, p, eof, nextKeywordStart, contentStart));
|
56
|
-
listener.background(keyword, nameDescription[0], nameDescription[1], currentLine);
|
57
|
-
if(nextKeywordStart != -1) p = nextKeywordStart - 1;
|
58
|
-
nextKeywordStart = -1;
|
59
|
-
}
|
60
|
-
|
61
|
-
action store_scenario_content {
|
62
|
-
String[] nameDescription = nameAndUnindentedDescription(startCol, keywordContent(data, p, eof, nextKeywordStart, contentStart));
|
63
|
-
listener.scenario(keyword, nameDescription[0], nameDescription[1], currentLine);
|
64
|
-
if(nextKeywordStart != -1) p = nextKeywordStart - 1;
|
65
|
-
nextKeywordStart = -1;
|
66
|
-
}
|
67
|
-
|
68
|
-
action store_scenario_outline_content {
|
69
|
-
String[] nameDescription = nameAndUnindentedDescription(startCol, keywordContent(data, p, eof, nextKeywordStart, contentStart));
|
70
|
-
listener.scenarioOutline(keyword, nameDescription[0], nameDescription[1], currentLine);
|
71
|
-
if(nextKeywordStart != -1) p = nextKeywordStart - 1;
|
72
|
-
nextKeywordStart = -1;
|
73
|
-
}
|
74
|
-
|
75
|
-
action store_examples_content {
|
76
|
-
String[] nameDescription = nameAndUnindentedDescription(startCol, keywordContent(data, p, eof, nextKeywordStart, contentStart));
|
77
|
-
listener.examples(keyword, nameDescription[0], nameDescription[1], currentLine);
|
78
|
-
if(nextKeywordStart != -1) p = nextKeywordStart - 1;
|
79
|
-
nextKeywordStart = -1;
|
80
|
-
}
|
81
|
-
|
82
|
-
action store_step_content {
|
83
|
-
listener.step(keyword, substring(data, contentStart, p).trim(), currentLine);
|
84
|
-
}
|
85
|
-
|
86
|
-
action store_comment_content {
|
87
|
-
listener.comment(substring(data, contentStart, p).trim(), lineNumber);
|
88
|
-
keywordStart = -1;
|
89
|
-
}
|
90
|
-
|
91
|
-
action store_tag_content {
|
92
|
-
listener.tag(substring(data, contentStart, p).trim(), currentLine);
|
93
|
-
keywordStart = -1;
|
94
|
-
}
|
95
|
-
|
96
|
-
action inc_line_number {
|
97
|
-
lineNumber++;
|
98
|
-
}
|
99
|
-
|
100
|
-
action last_newline {
|
101
|
-
lastNewline = p + 1;
|
102
|
-
}
|
103
|
-
|
104
|
-
action start_keyword {
|
105
|
-
if(keywordStart == -1) keywordStart = p;
|
106
|
-
}
|
107
|
-
|
108
|
-
action end_keyword {
|
109
|
-
keyword = substring(data, keywordStart, p).replaceFirst(":$","");
|
110
|
-
keywordStart = -1;
|
111
|
-
}
|
112
|
-
|
113
|
-
action next_keyword_start {
|
114
|
-
nextKeywordStart = p;
|
115
|
-
}
|
116
|
-
|
117
|
-
action start_row {
|
118
|
-
p = p - 1;
|
119
|
-
currentRow = new ArrayList<String>();
|
120
|
-
currentLine = lineNumber;
|
121
|
-
}
|
122
|
-
|
123
|
-
action begin_cell_content {
|
124
|
-
contentStart = p;
|
125
|
-
}
|
126
|
-
|
127
|
-
action store_cell_content {
|
128
|
-
String con = substring(data, contentStart, p).trim();
|
129
|
-
currentRow.add(con
|
130
|
-
.replace("\\|", "|")
|
131
|
-
.replace("\\n", "\n")
|
132
|
-
.replace("\\\\", "\\")
|
133
|
-
);
|
134
|
-
}
|
135
|
-
|
136
|
-
action store_row {
|
137
|
-
listener.row(currentRow, currentLine);
|
138
|
-
}
|
139
|
-
|
140
|
-
action end_feature {
|
141
|
-
if(cs < lexer_first_final) {
|
142
|
-
String content = currentLineContent(data, lastNewline);
|
143
|
-
throw new LexingError("Lexing error on line " + lineNumber + ": '" + content + "'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.");
|
144
|
-
} else {
|
145
|
-
listener.eof();
|
146
|
-
}
|
147
|
-
}
|
148
|
-
|
149
|
-
include lexer_common "lexer_common.<%= @i18n.underscored_iso_code %>.rl";
|
150
|
-
}%%
|
151
|
-
|
152
|
-
private final Listener listener;
|
153
|
-
|
154
|
-
public <%= @i18n.underscored_iso_code.capitalize %>(Listener listener) {
|
155
|
-
this.listener = listener;
|
156
|
-
}
|
157
|
-
|
158
|
-
%% write data noerror;
|
159
|
-
|
160
|
-
public void scan(String source) {
|
161
|
-
String input = source + "\n%_FEATURE_END_%";
|
162
|
-
byte[] data = null;
|
163
|
-
try {
|
164
|
-
data = input.getBytes("UTF-8");
|
165
|
-
} catch(UnsupportedEncodingException e) {
|
166
|
-
throw new RuntimeException(e);
|
167
|
-
}
|
168
|
-
int cs, p = 0, pe = data.length;
|
169
|
-
int eof = pe;
|
170
|
-
|
171
|
-
int lineNumber = 1;
|
172
|
-
int lastNewline = 0;
|
173
|
-
|
174
|
-
int contentStart = -1;
|
175
|
-
int currentLine = -1;
|
176
|
-
int docstringContentTypeStart = -1;
|
177
|
-
int docstringContentTypeEnd = -1;
|
178
|
-
int startCol = -1;
|
179
|
-
int nextKeywordStart = -1;
|
180
|
-
int keywordStart = -1;
|
181
|
-
String keyword = null;
|
182
|
-
List<String> currentRow = null;
|
183
|
-
|
184
|
-
%% write init;
|
185
|
-
%% write exec;
|
186
|
-
}
|
187
|
-
|
188
|
-
private String keywordContent(byte[] data, int p, int eof, int nextKeywordStart, int contentStart) {
|
189
|
-
int endPoint = (nextKeywordStart == -1 || (p == eof)) ? p : nextKeywordStart;
|
190
|
-
return substring(data, contentStart, endPoint);
|
191
|
-
}
|
192
|
-
|
193
|
-
private String[] nameAndUnindentedDescription(int startCol, String text) {
|
194
|
-
String[] lines = text.split("\n");
|
195
|
-
String name = lines.length > 0 ? lines[0].trim() : "";
|
196
|
-
StringBuffer description = new StringBuffer();
|
197
|
-
for(int i = 1; i < lines.length; i++) {
|
198
|
-
description.append(lines[i]);
|
199
|
-
description.append("\n");
|
200
|
-
}
|
201
|
-
return new String[]{name, unindent(startCol+2, description.toString()).replaceAll("\\s+$", "")};
|
202
|
-
}
|
203
|
-
|
204
|
-
private String unindent(int startCol, String text) {
|
205
|
-
return Pattern.compile("^[\t ]{0," + startCol + "}", Pattern.MULTILINE).matcher(text).replaceAll("");
|
206
|
-
}
|
207
|
-
|
208
|
-
private String currentLineContent(byte[] data, int lastNewline) {
|
209
|
-
return substring(data, lastNewline, data.length).trim();
|
210
|
-
}
|
211
|
-
|
212
|
-
private String substring(byte[] data, int start, int end) {
|
213
|
-
try {
|
214
|
-
return new String(data, start, end-start, "utf-8");
|
215
|
-
} catch(java.io.UnsupportedEncodingException e) {
|
216
|
-
throw new RuntimeException("Internal error", e);
|
217
|
-
}
|
218
|
-
}
|
219
|
-
}
|
data/ragel/lexer.js.rl.erb
DELETED
@@ -1,322 +0,0 @@
|
|
1
|
-
;(function() {
|
2
|
-
|
3
|
-
%%{
|
4
|
-
machine lexer;
|
5
|
-
|
6
|
-
action begin_content {
|
7
|
-
this.content_start = p;
|
8
|
-
this.current_line = this.line_number;
|
9
|
-
this.start_col = p - this.last_newline - (this.keyword+':').length;
|
10
|
-
}
|
11
|
-
|
12
|
-
action start_docstring {
|
13
|
-
this.current_line = this.line_number;
|
14
|
-
this.start_col = p - this.last_newline;
|
15
|
-
}
|
16
|
-
|
17
|
-
action begin_docstring_content {
|
18
|
-
this.content_start = p;
|
19
|
-
}
|
20
|
-
|
21
|
-
action start_docstring_content_type {
|
22
|
-
this.docstring_content_type_start = p;
|
23
|
-
}
|
24
|
-
|
25
|
-
action end_docstring_content_type {
|
26
|
-
this.docstring_content_type_end = p;
|
27
|
-
}
|
28
|
-
|
29
|
-
action store_docstring_content {
|
30
|
-
var con = this.unindent(
|
31
|
-
this.start_col,
|
32
|
-
this.bytesToString(data.slice(this.content_start, this.next_keyword_start-1)).replace(/(\r?\n)?([\t ])*$/, '').replace(/ESCAPED_TRIPLE_QUOTE/mg, '"""')
|
33
|
-
);
|
34
|
-
var con_type = this.bytesToString(data.slice(this.docstring_content_type_start, this.docstring_content_type_end)).trim();
|
35
|
-
this.listener.doc_string(con_type, con, this.current_line);
|
36
|
-
}
|
37
|
-
|
38
|
-
action store_feature_content {
|
39
|
-
p = this.store_keyword_content('feature', data, p, eof);
|
40
|
-
}
|
41
|
-
|
42
|
-
action store_background_content {
|
43
|
-
p = this.store_keyword_content('background', data, p, eof);
|
44
|
-
}
|
45
|
-
|
46
|
-
action store_scenario_content {
|
47
|
-
p = this.store_keyword_content('scenario', data, p, eof);
|
48
|
-
}
|
49
|
-
|
50
|
-
action store_scenario_outline_content {
|
51
|
-
p = this.store_keyword_content('scenario_outline', data, p, eof);
|
52
|
-
}
|
53
|
-
|
54
|
-
action store_examples_content {
|
55
|
-
p = this.store_keyword_content('examples', data, p, eof);
|
56
|
-
}
|
57
|
-
|
58
|
-
action store_step_content {
|
59
|
-
var con = this.bytesToString(data.slice(this.content_start, p)).trim();
|
60
|
-
this.listener.step(this.keyword, con, this.current_line);
|
61
|
-
}
|
62
|
-
|
63
|
-
action store_comment_content {
|
64
|
-
var con = this.bytesToString(data.slice(this.content_start, p)).trim();
|
65
|
-
this.listener.comment(con, this.line_number);
|
66
|
-
this.keyword_start = null;
|
67
|
-
}
|
68
|
-
|
69
|
-
action store_tag_content {
|
70
|
-
var con = this.bytesToString(data.slice(this.content_start, p)).trim();
|
71
|
-
this.listener.tag(con, this.line_number);
|
72
|
-
this.keyword_start = null;
|
73
|
-
}
|
74
|
-
|
75
|
-
action inc_line_number {
|
76
|
-
this.line_number++;
|
77
|
-
}
|
78
|
-
|
79
|
-
action last_newline {
|
80
|
-
this.last_newline = p + 1;
|
81
|
-
}
|
82
|
-
|
83
|
-
action start_keyword {
|
84
|
-
this.keyword_start = this.keyword_start || p;
|
85
|
-
}
|
86
|
-
|
87
|
-
action end_keyword {
|
88
|
-
this.keyword = this.bytesToString(data.slice(this.keyword_start, p)).replace(/:$/, '');
|
89
|
-
this.keyword_start = null;
|
90
|
-
}
|
91
|
-
|
92
|
-
action next_keyword_start {
|
93
|
-
this.next_keyword_start = p;
|
94
|
-
}
|
95
|
-
|
96
|
-
action start_row {
|
97
|
-
p = p - 1;
|
98
|
-
current_row = [];
|
99
|
-
this.current_line = this.line_number;
|
100
|
-
}
|
101
|
-
|
102
|
-
action begin_cell_content {
|
103
|
-
this.content_start = p;
|
104
|
-
}
|
105
|
-
|
106
|
-
action store_cell_content {
|
107
|
-
var con = this.bytesToString(data.slice(this.content_start, p)).trim();
|
108
|
-
current_row.push(con.replace(/\\\|/, "|").replace(/\\n/, "\n").replace(/\\\\/, "\\"));
|
109
|
-
}
|
110
|
-
|
111
|
-
action store_row {
|
112
|
-
this.listener.row(current_row, this.current_line);
|
113
|
-
}
|
114
|
-
|
115
|
-
action end_feature {
|
116
|
-
if(this.cs < lexer_first_final) {
|
117
|
-
var content = this.current_line_content(data, p);
|
118
|
-
throw new Error("Lexing error on line " + this.line_number + ": '" + content + "'. See http://wiki.github.com/cucumber/gherkin/lexingerror for more information.");
|
119
|
-
} else {
|
120
|
-
this.listener.eof();
|
121
|
-
}
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
include lexer_common "lexer_common.<%= @i18n.underscored_iso_code %>.rl";
|
126
|
-
}%%
|
127
|
-
|
128
|
-
%% write data;
|
129
|
-
%% access this.;
|
130
|
-
%% variable data data;
|
131
|
-
%% getkey signedCharValue(data[p]);
|
132
|
-
|
133
|
-
var Lexer = function(listener) {
|
134
|
-
// Check that listener has the required functions
|
135
|
-
var events = ['comment', 'tag', 'feature', 'background', 'scenario', 'scenario_outline', 'examples', 'step', 'doc_string', 'row', 'eof'];
|
136
|
-
for(var i=0, len=events.length; i<len; i++) {
|
137
|
-
var event = events[i];
|
138
|
-
if(typeof listener[event] != 'function') {
|
139
|
-
throw new Error("Error. No " + event + " function exists on " + JSON.stringify(listener));
|
140
|
-
}
|
141
|
-
}
|
142
|
-
this.listener = listener;
|
143
|
-
};
|
144
|
-
|
145
|
-
Lexer.prototype.scan = function(data) {
|
146
|
-
var ending = "\n%_FEATURE_END_%";
|
147
|
-
if(typeof data == 'string') {
|
148
|
-
data = this.stringToBytes(data + ending);
|
149
|
-
} else if(typeof Buffer != 'undefined' && Buffer.isBuffer(data)) {
|
150
|
-
// Node.js
|
151
|
-
var buf = new Buffer(data.length + ending.length);
|
152
|
-
data.copy(buf, 0, 0);
|
153
|
-
new Buffer(ending).copy(buf, data.length, 0);
|
154
|
-
data = buf;
|
155
|
-
}
|
156
|
-
var eof = pe = data.length;
|
157
|
-
var p = 0;
|
158
|
-
|
159
|
-
this.line_number = 1;
|
160
|
-
this.last_newline = 0;
|
161
|
-
var signedCharValue=function(v){return v > 127 ? v-256 : v; };
|
162
|
-
|
163
|
-
%% write init;
|
164
|
-
%% write exec;
|
165
|
-
};
|
166
|
-
|
167
|
-
|
168
|
-
/*
|
169
|
-
* Decode utf-8 byte sequence to string.
|
170
|
-
*/
|
171
|
-
var decodeUtf8 = function(bytes) {
|
172
|
-
var result = "";
|
173
|
-
var i = 0;
|
174
|
-
var wc;
|
175
|
-
var c;
|
176
|
-
|
177
|
-
while (i < bytes.length) {
|
178
|
-
/* parse as UTF-8 lead byte */
|
179
|
-
wc = bytes[i++];
|
180
|
-
if (wc < 0x80) {
|
181
|
-
count = 0;
|
182
|
-
} else if (wc < 0xC2 || wc >= 0xF8) {
|
183
|
-
throw new Error("input is not a valid UTF-8 lead octet");
|
184
|
-
} else if (wc < 0xE0) {
|
185
|
-
count = 1;
|
186
|
-
wc = (wc & 0x1F) << 6;
|
187
|
-
} else if (wc < 0xF0) {
|
188
|
-
count = 2;
|
189
|
-
wc = (wc & 0x0F) << 12;
|
190
|
-
} else /* wc < 0xF8 */ {
|
191
|
-
count = 3;
|
192
|
-
wc = (wc & 0x07) << 18;
|
193
|
-
}
|
194
|
-
|
195
|
-
/* parse trail bytes, if any */
|
196
|
-
while (count) {
|
197
|
-
if (!(i < bytes.length)) {
|
198
|
-
throw new Error("short read");
|
199
|
-
}
|
200
|
-
if ((c = bytes[i++] ^ 0x80) > 0x3F) {
|
201
|
-
throw new Error("input is not a valid UTF-8 trail octet");
|
202
|
-
}
|
203
|
-
wc |= c << (6 * --count);
|
204
|
-
if (wc < (1 << (5 * count + 6))) {
|
205
|
-
throw new Error("invalid non-minimal encoded input");
|
206
|
-
}
|
207
|
-
}
|
208
|
-
|
209
|
-
/* handle conversion to UTF-16 if needed */
|
210
|
-
if (wc > 0xFFFF) {
|
211
|
-
wc -= 0x10000;
|
212
|
-
result += String.fromCharCode(0xD800 + (wc >> 10));
|
213
|
-
wc = 0xDC00 + (wc & 0x3FF);
|
214
|
-
}
|
215
|
-
result += String.fromCharCode(wc);
|
216
|
-
}
|
217
|
-
|
218
|
-
return result;
|
219
|
-
};
|
220
|
-
|
221
|
-
/*
|
222
|
-
* Encode string to an array of bytes using utf8 encoding.
|
223
|
-
*
|
224
|
-
* Javascript internally stores character data as utf16 (like java).
|
225
|
-
* String.charCodeAt() does *not* produce unicode points, but simply
|
226
|
-
* reflects this internal representation. Thus, it is necessary
|
227
|
-
* to first decode the utf-16 representation before encoding to
|
228
|
-
* utf-8.
|
229
|
-
*/
|
230
|
-
var encodeUtf8 = function(string) {
|
231
|
-
var bytes = [];
|
232
|
-
var i = 0;
|
233
|
-
var j = 0;
|
234
|
-
var wc;
|
235
|
-
|
236
|
-
while (i < string.length) {
|
237
|
-
wc = string.charCodeAt(i++);
|
238
|
-
if (wc >= 0xD800 && wc <= 0xDBFF && i < string.length && string.charCodeAt(i) >= 0xDC00 && string.charCodeAt(i) <= 0xDFFF) {
|
239
|
-
/* decode UTF-16 */
|
240
|
-
wc = 0x10000 + ((wc & 0x3FF) << 10) + (string.charCodeAt(i++) & 0x3FF);
|
241
|
-
}
|
242
|
-
|
243
|
-
/* emit lead byte */
|
244
|
-
if (wc < 0x80) {
|
245
|
-
bytes[j++] = wc;
|
246
|
-
count = 0;
|
247
|
-
} else if (wc < 0x800) {
|
248
|
-
bytes[j++] = 0xC0 | (wc >> 6);
|
249
|
-
count = 1;
|
250
|
-
} else if (wc < 0x10000) {
|
251
|
-
bytes[j++] = 0xE0 | (wc >> 12);
|
252
|
-
count = 2;
|
253
|
-
} else {
|
254
|
-
/* SMP: 21-bit Unicode */
|
255
|
-
bytes[j++] = 0xF0 | (wc >> 18);
|
256
|
-
count = 3;
|
257
|
-
}
|
258
|
-
|
259
|
-
/* emit trail bytes, if any */
|
260
|
-
while (count) {
|
261
|
-
bytes[j++] = 0x80 | ((wc >> (6 * --count)) & 0x3F);
|
262
|
-
}
|
263
|
-
}
|
264
|
-
|
265
|
-
return bytes;
|
266
|
-
|
267
|
-
};
|
268
|
-
|
269
|
-
Lexer.prototype.bytesToString = function(bytes) {
|
270
|
-
if(typeof bytes.write == 'function') {
|
271
|
-
// Node.js
|
272
|
-
return bytes.toString('utf-8');
|
273
|
-
}
|
274
|
-
return decodeUtf8(bytes);
|
275
|
-
};
|
276
|
-
|
277
|
-
Lexer.prototype.stringToBytes = function(string) {
|
278
|
-
return encodeUtf8(string);
|
279
|
-
};
|
280
|
-
|
281
|
-
Lexer.prototype.unindent = function(startcol, text) {
|
282
|
-
startcol = startcol || 0;
|
283
|
-
return text.replace(new RegExp('^[\t ]{0,' + startcol + '}', 'gm'), '');
|
284
|
-
};
|
285
|
-
|
286
|
-
Lexer.prototype.store_keyword_content = function(event, data, p, eof) {
|
287
|
-
var end_point = (!this.next_keyword_start || (p == eof)) ? p : this.next_keyword_start;
|
288
|
-
var content = this.unindent(this.start_col + 2, this.bytesToString(data.slice(this.content_start, end_point))).replace(/\s+$/,"");
|
289
|
-
var content_lines = content.split("\n")
|
290
|
-
var name = content_lines.shift() || "";
|
291
|
-
name = name.trim();
|
292
|
-
var description = content_lines.join("\n");
|
293
|
-
this.listener[event](this.keyword, name, description, this.current_line);
|
294
|
-
var nks = this.next_keyword_start;
|
295
|
-
this.next_keyword_start = null;
|
296
|
-
return nks ? nks - 1 : p;
|
297
|
-
};
|
298
|
-
|
299
|
-
Lexer.prototype.current_line_content = function(data, p) {
|
300
|
-
var rest = Array.prototype.slice.call(data,this.last_newline, -1);
|
301
|
-
var end = rest.indexOf(10) || -1;
|
302
|
-
return this.bytesToString(rest.slice(0, end)).trim();
|
303
|
-
};
|
304
|
-
|
305
|
-
// Node.js export
|
306
|
-
if(typeof module !== 'undefined') {
|
307
|
-
module.exports = Lexer;
|
308
|
-
}
|
309
|
-
// Require.js export
|
310
|
-
if (typeof define !== 'undefined') {
|
311
|
-
if(define.amd) {
|
312
|
-
define('gherkin/lexer/<%= @i18n.underscored_iso_code %>', [], function() {
|
313
|
-
return Lexer;
|
314
|
-
});
|
315
|
-
} else {
|
316
|
-
define('gherkin/lexer/<%= @i18n.underscored_iso_code %>', function(require, exports, module) {
|
317
|
-
exports.Lexer = Lexer;
|
318
|
-
});
|
319
|
-
}
|
320
|
-
}
|
321
|
-
|
322
|
-
})();
|