gherkin 2.2.5-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. data/.gitattributes +2 -0
  2. data/.gitignore +11 -0
  3. data/.mailmap +2 -0
  4. data/.rspec +1 -0
  5. data/.rvmrc +1 -0
  6. data/Gemfile +5 -0
  7. data/History.txt +306 -0
  8. data/LICENSE +20 -0
  9. data/README.rdoc +59 -0
  10. data/Rakefile +16 -0
  11. data/VERSION +1 -0
  12. data/bin/gherkin +5 -0
  13. data/build_native_gems.sh +8 -0
  14. data/cucumber.yml +3 -0
  15. data/features/escaped_pipes.feature +8 -0
  16. data/features/feature_parser.feature +237 -0
  17. data/features/json_formatter.feature +278 -0
  18. data/features/json_parser.feature +318 -0
  19. data/features/native_lexer.feature +19 -0
  20. data/features/parser_with_native_lexer.feature +205 -0
  21. data/features/pretty_formatter.feature +15 -0
  22. data/features/step_definitions/eyeball_steps.rb +3 -0
  23. data/features/step_definitions/gherkin_steps.rb +29 -0
  24. data/features/step_definitions/json_formatter_steps.rb +28 -0
  25. data/features/step_definitions/json_parser_steps.rb +20 -0
  26. data/features/step_definitions/pretty_formatter_steps.rb +82 -0
  27. data/features/steps_parser.feature +46 -0
  28. data/features/support/env.rb +38 -0
  29. data/gherkin.gemspec +59 -0
  30. data/ikvm/.gitignore +3 -0
  31. data/java/.gitignore +2 -0
  32. data/java/src/main/java/gherkin/lexer/i18n/.gitignore +1 -0
  33. data/java/src/main/resources/gherkin/.gitignore +1 -0
  34. data/lib/.gitignore +4 -0
  35. data/lib/gherkin.rb +2 -0
  36. data/lib/gherkin/c_lexer.rb +17 -0
  37. data/lib/gherkin/cli/main.rb +33 -0
  38. data/lib/gherkin/formatter/argument.rb +28 -0
  39. data/lib/gherkin/formatter/colors.rb +119 -0
  40. data/lib/gherkin/formatter/escaping.rb +15 -0
  41. data/lib/gherkin/formatter/filter_formatter.rb +136 -0
  42. data/lib/gherkin/formatter/json_formatter.rb +72 -0
  43. data/lib/gherkin/formatter/line_filter.rb +26 -0
  44. data/lib/gherkin/formatter/model.rb +231 -0
  45. data/lib/gherkin/formatter/monochrome_format.rb +9 -0
  46. data/lib/gherkin/formatter/pretty_formatter.rb +174 -0
  47. data/lib/gherkin/formatter/regexp_filter.rb +21 -0
  48. data/lib/gherkin/formatter/tag_count_formatter.rb +47 -0
  49. data/lib/gherkin/formatter/tag_filter.rb +19 -0
  50. data/lib/gherkin/i18n.rb +180 -0
  51. data/lib/gherkin/i18n.yml +601 -0
  52. data/lib/gherkin/json_parser.rb +88 -0
  53. data/lib/gherkin/lexer/i18n_lexer.rb +47 -0
  54. data/lib/gherkin/listener/event.rb +45 -0
  55. data/lib/gherkin/listener/formatter_listener.rb +113 -0
  56. data/lib/gherkin/native.rb +7 -0
  57. data/lib/gherkin/native/ikvm.rb +55 -0
  58. data/lib/gherkin/native/java.rb +55 -0
  59. data/lib/gherkin/native/null.rb +9 -0
  60. data/lib/gherkin/parser/meta.txt +5 -0
  61. data/lib/gherkin/parser/parser.rb +164 -0
  62. data/lib/gherkin/parser/root.txt +11 -0
  63. data/lib/gherkin/parser/steps.txt +4 -0
  64. data/lib/gherkin/rb_lexer.rb +8 -0
  65. data/lib/gherkin/rb_lexer/.gitignore +1 -0
  66. data/lib/gherkin/rb_lexer/README.rdoc +8 -0
  67. data/lib/gherkin/rubify.rb +24 -0
  68. data/lib/gherkin/tag_expression.rb +62 -0
  69. data/lib/gherkin/tools.rb +8 -0
  70. data/lib/gherkin/tools/files.rb +34 -0
  71. data/lib/gherkin/tools/reformat.rb +20 -0
  72. data/lib/gherkin/tools/stats.rb +20 -0
  73. data/lib/gherkin/tools/stats_listener.rb +60 -0
  74. data/lib/gherkin/version.rb +3 -0
  75. data/ragel/i18n/.gitignore +1 -0
  76. data/ragel/lexer.c.rl.erb +459 -0
  77. data/ragel/lexer.java.rl.erb +224 -0
  78. data/ragel/lexer.rb.rl.erb +179 -0
  79. data/ragel/lexer_common.rl.erb +50 -0
  80. data/spec/gherkin/c_lexer_spec.rb +21 -0
  81. data/spec/gherkin/fixtures/1.feature +8 -0
  82. data/spec/gherkin/fixtures/comments_in_table.feature +9 -0
  83. data/spec/gherkin/fixtures/complex.feature +45 -0
  84. data/spec/gherkin/fixtures/complex.json +143 -0
  85. data/spec/gherkin/fixtures/complex_for_filtering.feature +60 -0
  86. data/spec/gherkin/fixtures/complex_with_tags.feature +61 -0
  87. data/spec/gherkin/fixtures/dos_line_endings.feature +45 -0
  88. data/spec/gherkin/fixtures/hantu_pisang.feature +35 -0
  89. data/spec/gherkin/fixtures/i18n_fr.feature +14 -0
  90. data/spec/gherkin/fixtures/i18n_no.feature +7 -0
  91. data/spec/gherkin/fixtures/i18n_zh-CN.feature +9 -0
  92. data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +13 -0
  93. data/spec/gherkin/fixtures/scenario_without_steps.feature +5 -0
  94. data/spec/gherkin/fixtures/simple_with_comments.feature +7 -0
  95. data/spec/gherkin/fixtures/simple_with_tags.feature +11 -0
  96. data/spec/gherkin/fixtures/with_bom.feature +3 -0
  97. data/spec/gherkin/formatter/argument_spec.rb +28 -0
  98. data/spec/gherkin/formatter/colors_spec.rb +18 -0
  99. data/spec/gherkin/formatter/filter_formatter_spec.rb +165 -0
  100. data/spec/gherkin/formatter/model_spec.rb +15 -0
  101. data/spec/gherkin/formatter/pretty_formatter_spec.rb +140 -0
  102. data/spec/gherkin/formatter/spaces.feature +9 -0
  103. data/spec/gherkin/formatter/tabs.feature +9 -0
  104. data/spec/gherkin/formatter/tag_count_formatter_spec.rb +30 -0
  105. data/spec/gherkin/i18n_spec.rb +149 -0
  106. data/spec/gherkin/java_lexer_spec.rb +20 -0
  107. data/spec/gherkin/json.rb +5 -0
  108. data/spec/gherkin/json_parser_spec.rb +67 -0
  109. data/spec/gherkin/lexer/i18n_lexer_spec.rb +43 -0
  110. data/spec/gherkin/output_stream_string_io.rb +24 -0
  111. data/spec/gherkin/parser/parser_spec.rb +16 -0
  112. data/spec/gherkin/rb_lexer_spec.rb +19 -0
  113. data/spec/gherkin/sexp_recorder.rb +56 -0
  114. data/spec/gherkin/shared/lexer_group.rb +592 -0
  115. data/spec/gherkin/shared/py_string_group.rb +153 -0
  116. data/spec/gherkin/shared/row_group.rb +120 -0
  117. data/spec/gherkin/shared/tags_group.rb +54 -0
  118. data/spec/gherkin/tag_expression_spec.rb +137 -0
  119. data/spec/spec_helper.rb +68 -0
  120. data/tasks/bench.rake +184 -0
  121. data/tasks/bench/feature_builder.rb +49 -0
  122. data/tasks/bench/generated/.gitignore +1 -0
  123. data/tasks/bench/null_listener.rb +4 -0
  124. data/tasks/compile.rake +102 -0
  125. data/tasks/cucumber.rake +18 -0
  126. data/tasks/gems.rake +42 -0
  127. data/tasks/ikvm.rake +54 -0
  128. data/tasks/ragel_task.rb +70 -0
  129. data/tasks/rdoc.rake +9 -0
  130. data/tasks/release.rake +30 -0
  131. data/tasks/rspec.rake +8 -0
  132. metadata +447 -0
@@ -0,0 +1,224 @@
1
+ package gherkin.lexer.i18n;
2
+
3
+ import java.io.UnsupportedEncodingException;
4
+ import java.util.List;
5
+ import java.util.ArrayList;
6
+ import java.util.regex.Pattern;
7
+ import java.util.regex.Matcher;
8
+ import gherkin.lexer.Lexer;
9
+ import gherkin.lexer.Listener;
10
+ import gherkin.lexer.LexingError;
11
+
12
+ public class <%= @i18n.underscored_iso_code.upcase %> implements Lexer {
13
+ %%{
14
+ machine lexer;
15
+ alphtype byte;
16
+
17
+ action begin_content {
18
+ contentStart = p;
19
+ currentLine = lineNumber;
20
+ }
21
+
22
+ action start_pystring {
23
+ currentLine = lineNumber;
24
+ startCol = p - lastNewline;
25
+ }
26
+
27
+ action begin_pystring_content {
28
+ contentStart = p;
29
+ }
30
+
31
+ action store_pystring_content {
32
+ String con = unindent(startCol, substring(data, contentStart, nextKeywordStart-1).replaceFirst("(\\r?\\n)?([\\t ])*\\Z", "").replaceAll("\\\\\"\\\\\"\\\\\"", "\"\"\""));
33
+ listener.pyString(con, currentLine);
34
+ }
35
+
36
+ action store_feature_content {
37
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
38
+ listener.feature(keyword, nameDescription[0], nameDescription[1], currentLine);
39
+ if(nextKeywordStart != -1) p = nextKeywordStart - 1;
40
+ nextKeywordStart = -1;
41
+ }
42
+
43
+ action store_background_content {
44
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
45
+ listener.background(keyword, nameDescription[0], nameDescription[1], currentLine);
46
+ if(nextKeywordStart != -1) p = nextKeywordStart - 1;
47
+ nextKeywordStart = -1;
48
+ }
49
+
50
+ action store_scenario_content {
51
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
52
+ listener.scenario(keyword, nameDescription[0], nameDescription[1], currentLine);
53
+ if(nextKeywordStart != -1) p = nextKeywordStart - 1;
54
+ nextKeywordStart = -1;
55
+ }
56
+
57
+ action store_scenario_outline_content {
58
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
59
+ listener.scenarioOutline(keyword, nameDescription[0], nameDescription[1], currentLine);
60
+ if(nextKeywordStart != -1) p = nextKeywordStart - 1;
61
+ nextKeywordStart = -1;
62
+ }
63
+
64
+ action store_examples_content {
65
+ String[] nameDescription = nameAndDescriptionWithPlatformNewlinesIntact(keywordContent(data, p, eof, nextKeywordStart, contentStart));
66
+ listener.examples(keyword, nameDescription[0], nameDescription[1], currentLine);
67
+ if(nextKeywordStart != -1) p = nextKeywordStart - 1;
68
+ nextKeywordStart = -1;
69
+ }
70
+
71
+ action store_step_content {
72
+ listener.step(keyword, substring(data, contentStart, p).trim(), currentLine);
73
+ }
74
+
75
+ action store_comment_content {
76
+ listener.comment(substring(data, contentStart, p).trim(), lineNumber);
77
+ keywordStart = -1;
78
+ }
79
+
80
+ action store_tag_content {
81
+ listener.tag(substring(data, contentStart, p).trim(), currentLine);
82
+ keywordStart = -1;
83
+ }
84
+
85
+ action inc_line_number {
86
+ lineNumber++;
87
+ }
88
+
89
+ action last_newline {
90
+ lastNewline = p + 1;
91
+ }
92
+
93
+ action start_keyword {
94
+ if(keywordStart == -1) keywordStart = p;
95
+ }
96
+
97
+ action end_keyword {
98
+ keyword = substring(data, keywordStart, p).replaceFirst(":$","");
99
+ keywordStart = -1;
100
+ }
101
+
102
+ action next_keyword_start {
103
+ nextKeywordStart = p;
104
+ }
105
+
106
+ action start_row {
107
+ p = p - 1;
108
+ currentRow = new ArrayList<String>();
109
+ currentLine = lineNumber;
110
+ }
111
+
112
+ action begin_cell_content {
113
+ contentStart = p;
114
+ }
115
+
116
+ action store_cell_content {
117
+ String con = substring(data, contentStart, p).trim();
118
+ currentRow.add(con.replaceAll("\\\\\\|", "|").replaceAll("\\\\\\\\", "\\\\"));
119
+ }
120
+
121
+ action store_row {
122
+ listener.row(currentRow, currentLine);
123
+ }
124
+
125
+ action end_feature {
126
+ if(cs < lexer_first_final) {
127
+ String content = currentLineContent(data, lastNewline);
128
+ throw new LexingError("Lexing error on line " + lineNumber + ": '" + content + "'. See http://wiki.github.com/aslakhellesoy/gherkin/lexingerror for more information.");
129
+ } else {
130
+ listener.eof();
131
+ }
132
+ }
133
+
134
+ include lexer_common "lexer_common.<%= @i18n.underscored_iso_code %>.rl";
135
+ }%%
136
+
137
+ private final Listener listener;
138
+
139
+ public <%= @i18n.underscored_iso_code.upcase %>(Listener listener) {
140
+ this.listener = listener;
141
+ }
142
+
143
+ %% write data noerror;
144
+
145
+ public void scan(String source) {
146
+ String input = source + "\n%_FEATURE_END_%";
147
+ byte[] data = null;
148
+ try {
149
+ data = input.getBytes("UTF-8");
150
+ } catch(UnsupportedEncodingException e) {
151
+ throw new RuntimeException(e);
152
+ }
153
+ int cs, p = 0, pe = data.length;
154
+ int eof = pe;
155
+
156
+ int lineNumber = 1;
157
+ int lastNewline = 0;
158
+
159
+ int contentStart = -1;
160
+ int currentLine = -1;
161
+ int startCol = -1;
162
+ int nextKeywordStart = -1;
163
+ int keywordStart = -1;
164
+ String keyword = null;
165
+ List<String> currentRow = null;
166
+
167
+ %% write init;
168
+ %% write exec;
169
+ }
170
+
171
+ private String keywordContent(byte[] data, int p, int eof, int nextKeywordStart, int contentStart) {
172
+ int endPoint = (nextKeywordStart == -1 || (p == eof)) ? p : nextKeywordStart;
173
+ return substring(data, contentStart, endPoint);
174
+ }
175
+
176
+ private static final Pattern CRLF_RE = Pattern.compile("\r\n");
177
+ private static final Pattern LF_RE = Pattern.compile("[^\r]\n");
178
+ private static final String CRLF = "\r\n";
179
+ private static final String LF = "\n";
180
+
181
+ private String[] nameAndDescriptionWithPlatformNewlinesIntact(String text) {
182
+ int crlfCount = matchCount(CRLF_RE.matcher(text));
183
+ int lfCount = matchCount(LF_RE.matcher(text));
184
+ String eol = crlfCount > lfCount ? CRLF : LF;
185
+
186
+ String name = null;
187
+ StringBuffer description = new StringBuffer();
188
+ for(String s : text.split("\r?\n")) {
189
+ if(name == null) {
190
+ name = s.trim();
191
+ } else {
192
+ description.append(s.trim()).append(eol);
193
+ }
194
+ }
195
+ if(name == null) {
196
+ name = "";
197
+ }
198
+ return new String[]{name, description.toString().trim()};
199
+ }
200
+
201
+ private int matchCount(Matcher m) {
202
+ int count = 0;
203
+ while(m.find()) {
204
+ count++;
205
+ }
206
+ return count;
207
+ }
208
+
209
+ private String unindent(int startCol, String text) {
210
+ return Pattern.compile("^[\t ]{0," + startCol + "}", Pattern.MULTILINE).matcher(text).replaceAll("");
211
+ }
212
+
213
+ private String currentLineContent(byte[] data, int lastNewline) {
214
+ return substring(data, lastNewline, data.length).trim();
215
+ }
216
+
217
+ private String substring(byte[] data, int start, int end) {
218
+ try {
219
+ return new String(data, start, end-start, "utf-8");
220
+ } catch(java.io.UnsupportedEncodingException e) {
221
+ throw new RuntimeException("Internal error", e);
222
+ }
223
+ }
224
+ }
@@ -0,0 +1,179 @@
1
+ require 'gherkin/lexer/i18n_lexer'
2
+
3
+ module Gherkin
4
+ module RbLexer
5
+ class <%= @i18n.underscored_iso_code.capitalize %> #:nodoc:
6
+ %%{
7
+ machine lexer;
8
+
9
+ action begin_content {
10
+ @content_start = p
11
+ @current_line = @line_number
12
+ }
13
+
14
+ action start_pystring {
15
+ @current_line = @line_number
16
+ @start_col = p - @last_newline
17
+ }
18
+
19
+ action begin_pystring_content {
20
+ @content_start = p
21
+ }
22
+
23
+ action store_pystring_content {
24
+ con = unindent(@start_col, utf8_pack(data[@content_start...@next_keyword_start-1]).sub(/(\r?\n)?([\t ])*\Z/, '').gsub(/\\"\\"\\"/, '"""'))
25
+ @listener.py_string(con, @current_line)
26
+ }
27
+
28
+ action store_feature_content {
29
+ store_keyword_content(:feature, data, p, eof) { |con| multiline_strip(con) }
30
+ p = @next_keyword_start - 1 if @next_keyword_start
31
+ @next_keyword_start = nil
32
+ }
33
+
34
+ action store_background_content {
35
+ store_keyword_content(:background, data, p, eof) { |con| multiline_strip(con) }
36
+ p = @next_keyword_start - 1 if @next_keyword_start
37
+ @next_keyword_start = nil
38
+ }
39
+
40
+ action store_scenario_content {
41
+ store_keyword_content(:scenario, data, p, eof) { |con| multiline_strip(con) }
42
+ p = @next_keyword_start - 1 if @next_keyword_start
43
+ @next_keyword_start = nil
44
+ }
45
+
46
+ action store_scenario_outline_content {
47
+ store_keyword_content(:scenario_outline, data, p, eof) { |con| multiline_strip(con) }
48
+ p = @next_keyword_start - 1 if @next_keyword_start
49
+ @next_keyword_start = nil
50
+ }
51
+
52
+ action store_examples_content {
53
+ store_keyword_content(:examples, data, p, eof) { |con| multiline_strip(con) }
54
+ p = @next_keyword_start - 1 if @next_keyword_start
55
+ @next_keyword_start = nil
56
+ }
57
+
58
+ action store_step_content {
59
+ con = utf8_pack(data[@content_start...p]).strip
60
+ @listener.step(@keyword, con, @current_line)
61
+ }
62
+
63
+ action store_comment_content {
64
+ con = utf8_pack(data[@content_start...p]).strip
65
+ @listener.comment(con, @line_number)
66
+ @keyword_start = nil
67
+ }
68
+
69
+ action store_tag_content {
70
+ con = utf8_pack(data[@content_start...p]).strip
71
+ @listener.tag(con, @current_line)
72
+ @keyword_start = nil
73
+ }
74
+
75
+ action inc_line_number {
76
+ @line_number += 1
77
+ }
78
+
79
+ action last_newline {
80
+ @last_newline = p + 1
81
+ }
82
+
83
+ action start_keyword {
84
+ @keyword_start ||= p
85
+ }
86
+
87
+ action end_keyword {
88
+ @keyword = utf8_pack(data[@keyword_start...p]).sub(/:$/,'')
89
+ @keyword_start = nil
90
+ }
91
+
92
+ action next_keyword_start {
93
+ @next_keyword_start = p
94
+ }
95
+
96
+ action start_row {
97
+ p = p - 1
98
+ current_row = []
99
+ @current_line = @line_number
100
+ }
101
+
102
+ action begin_cell_content {
103
+ @content_start = p
104
+ }
105
+
106
+ action store_cell_content {
107
+ con = utf8_pack(data[@content_start...p]).strip
108
+ current_row << con.gsub(/\\\|/, "|").gsub(/\\\\/, "\\")
109
+ }
110
+
111
+ action store_row {
112
+ @listener.row(current_row, @current_line)
113
+ }
114
+
115
+ action end_feature {
116
+ if cs < lexer_first_final
117
+ content = current_line_content(data, p)
118
+ raise Gherkin::Lexer::LexingError.new("Lexing error on line %d: '%s'. See http://wiki.github.com/aslakhellesoy/gherkin/lexingerror for more information." % [@line_number, content])
119
+ else
120
+ @listener.eof
121
+ end
122
+ }
123
+
124
+ include lexer_common "lexer_common.<%= @i18n.underscored_iso_code %>.rl";
125
+ }%%
126
+
127
+ def initialize(listener)
128
+ @listener = listener
129
+ %% write data;
130
+ end
131
+
132
+ def scan(data)
133
+ data = (data + "\n%_FEATURE_END_%").unpack("c*") # Explicit EOF simplifies things considerably
134
+ eof = pe = data.length
135
+
136
+ @line_number = 1
137
+ @last_newline = 0
138
+
139
+ %% write init;
140
+ %% write exec;
141
+ end
142
+
143
+ CRLF_RE = /\r\n/
144
+ LF_RE = /[^\r]\n/
145
+ CRLF = "\r\n"
146
+ LF = "\n"
147
+
148
+ def multiline_strip(text)
149
+ crlf_count = text.scan(CRLF_RE).size
150
+ lf_count = text.scan(LF_RE).size
151
+ eol = crlf_count > lf_count ? CRLF : LF
152
+ text.split(/\r?\n/).map{|s| s.strip}.join(eol).strip
153
+ end
154
+
155
+ def unindent(startcol, text)
156
+ text.gsub(/^[\t ]{0,#{startcol}}/, "")
157
+ end
158
+
159
+ def store_keyword_content(event, data, p, eof)
160
+ end_point = (!@next_keyword_start or (p == eof)) ? p : @next_keyword_start
161
+ content = yield utf8_pack(data[@content_start...end_point])
162
+ content_lines = content.split("\n")
163
+ name = content_lines.shift || ""
164
+ name.strip!
165
+ description = content_lines.join("\n")
166
+ @listener.__send__(event, @keyword, name, description, @current_line)
167
+ end
168
+
169
+ def current_line_content(data, p)
170
+ rest = data[@last_newline..-1]
171
+ utf8_pack(rest[0..rest.index(10)||-1]).strip
172
+ end
173
+
174
+ def utf8_pack(array)
175
+ (RUBY_VERSION =~ /^1\.9/) ? array.pack("c*").force_encoding("UTF-8") : array.pack("c*")
176
+ end
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,50 @@
1
+ %%{
2
+ machine lexer_common;
3
+
4
+ # Language specific
5
+ I18N_Feature = (<%= ragel_list(@i18n.keywords('feature')) %> ':') >start_keyword %end_keyword;
6
+ I18N_Background = (<%= ragel_list(@i18n.keywords('background')) %> ':') >start_keyword %end_keyword;
7
+ I18N_ScenarioOutline = (<%= ragel_list(@i18n.keywords('scenario_outline')) %> ':') >start_keyword %end_keyword;
8
+ I18N_Scenario = (<%= ragel_list(@i18n.keywords('scenario')) %> ':') >start_keyword %end_keyword;
9
+ I18N_Step = <%= ragel_list(@i18n.step_keywords) %> >start_keyword %end_keyword;
10
+ I18N_Examples = (<%= ragel_list(@i18n.keywords('examples')) %> ':') >start_keyword %end_keyword;
11
+
12
+ EOF = '%_FEATURE_END_%'; # Explicit EOF added before scanning begins
13
+ EOL = ('\n' | '\r\n') @inc_line_number @last_newline;
14
+ BOM = 0xEF 0xBB 0xBF; # http://en.wikipedia.org/wiki/Byte_order_mark
15
+
16
+ PIPE = '|';
17
+ ESCAPED_PIPE = '\\|';
18
+
19
+ FeatureHeadingEnd = EOL+ space* (I18N_Feature | I18N_Background | I18N_Scenario | I18N_ScenarioOutline | I18N_Examples | '@' | '#' | EOF) >next_keyword_start;
20
+ ScenarioHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Background | I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
21
+ BackgroundHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Scenario | I18N_ScenarioOutline | I18N_Step | '@' | '#'| EOF ) >next_keyword_start;
22
+ ScenarioOutlineHeadingEnd = EOL+ space* ( I18N_Feature | I18N_Scenario | I18N_Step | '@' | '#' | EOF ) >next_keyword_start;
23
+ ExamplesHeadingEnd = EOL+ space* ( I18N_Feature | '|' | '#') >next_keyword_start;
24
+
25
+ FeatureHeading = space* I18N_Feature %begin_content ^FeatureHeadingEnd* :>> FeatureHeadingEnd @store_feature_content;
26
+ BackgroundHeading = space* I18N_Background %begin_content ^BackgroundHeadingEnd* :>> BackgroundHeadingEnd @store_background_content;
27
+ ScenarioHeading = space* I18N_Scenario %begin_content ^ScenarioHeadingEnd* :>> ScenarioHeadingEnd @store_scenario_content;
28
+ ScenarioOutlineHeading = space* I18N_ScenarioOutline %begin_content ^ScenarioOutlineHeadingEnd* :>> ScenarioOutlineHeadingEnd @store_scenario_outline_content;
29
+ ExamplesHeading = space* I18N_Examples %begin_content ^ExamplesHeadingEnd* :>> ExamplesHeadingEnd @store_examples_content;
30
+
31
+ Step = space* I18N_Step %begin_content ^EOL+ %store_step_content :> EOL+;
32
+ Comment = space* '#' >begin_content ^EOL* %store_comment_content :> EOL+;
33
+
34
+ Tag = ( ('@' [^@\r\n\t ]+) >begin_content ) %store_tag_content;
35
+ Tags = space* (Tag space*)+ EOL+;
36
+
37
+ StartRow = space* PIPE >start_row;
38
+ EndRow = EOL space* ^PIPE >next_keyword_start;
39
+ Cell = PIPE (ESCAPED_PIPE | (any - (PIPE|EOL))+ )* >begin_cell_content %store_cell_content;
40
+ RowBody = space* Cell** PIPE :>> (space* EOL+ space*) %store_row;
41
+ Row = StartRow :>> RowBody <: EndRow?;
42
+
43
+ StartPyString = '"""' >start_pystring space* :>> EOL;
44
+ EndPyString = (space* '"""') >next_keyword_start;
45
+ PyString = space* StartPyString %begin_pystring_content (^EOL | EOL)* :>> EndPyString %store_pystring_content space* EOL+;
46
+
47
+ Tokens = BOM? (space | EOL)* (Tags | Comment | FeatureHeading | BackgroundHeading | ScenarioHeading | ScenarioOutlineHeading | ExamplesHeading | Step | Row | PyString)* (space | EOL)* EOF;
48
+
49
+ main := Tokens %end_feature @!end_feature;
50
+ }%%