aslakhellesoy-cucumber 0.1.99.3 → 0.1.99.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (257) hide show
  1. data/Manifest.txt +6 -0
  2. metadata +1 -1
  3. data/cucumber.yml +0 -1
  4. data/examples/cs/README.textile +0 -1
  5. data/examples/cs/Rakefile +0 -12
  6. data/examples/cs/compile.bat +0 -1
  7. data/examples/cs/features/addition.feature +0 -16
  8. data/examples/cs/features/step_definitons/calculator_steps.rb +0 -19
  9. data/examples/cs/src/demo/Calculator.cs +0 -20
  10. data/examples/dos_line_endings/Rakefile +0 -6
  11. data/examples/dos_line_endings/features/dos_line_endings.feature +0 -9
  12. data/examples/i18n/README.textile +0 -18
  13. data/examples/i18n/Rakefile +0 -32
  14. data/examples/i18n/ar/Rakefile +0 -6
  15. data/examples/i18n/ar/features/addition.feature +0 -17
  16. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +0 -28
  17. data/examples/i18n/ar/lib/calculator.rb +0 -10
  18. data/examples/i18n/da/Rakefile +0 -6
  19. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +0 -24
  20. data/examples/i18n/da/features/summering.feature +0 -17
  21. data/examples/i18n/da/lib/kalkulator.rb +0 -11
  22. data/examples/i18n/de/Rakefile +0 -6
  23. data/examples/i18n/de/features/addition.feature +0 -16
  24. data/examples/i18n/de/features/division.feature +0 -9
  25. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +0 -24
  26. data/examples/i18n/de/lib/calculator.rb +0 -14
  27. data/examples/i18n/en/Rakefile +0 -6
  28. data/examples/i18n/en/features/addition.feature +0 -16
  29. data/examples/i18n/en/features/division.feature +0 -9
  30. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +0 -24
  31. data/examples/i18n/en/lib/calculator.rb +0 -14
  32. data/examples/i18n/es/Rakefile +0 -6
  33. data/examples/i18n/es/features/adicion.feature +0 -17
  34. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +0 -24
  35. data/examples/i18n/es/lib/calculador.rb +0 -11
  36. data/examples/i18n/et/Rakefile +0 -6
  37. data/examples/i18n/et/features/liitmine.feature +0 -17
  38. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +0 -24
  39. data/examples/i18n/et/lib/kalkulaator.rb +0 -10
  40. data/examples/i18n/fi/Rakefile +0 -6
  41. data/examples/i18n/fi/features/jakolasku.feature +0 -9
  42. data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +0 -24
  43. data/examples/i18n/fi/features/yhteenlasku.feature +0 -16
  44. data/examples/i18n/fi/lib/laskin.rb +0 -14
  45. data/examples/i18n/fr/Rakefile +0 -6
  46. data/examples/i18n/fr/features/addition.feature +0 -15
  47. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +0 -27
  48. data/examples/i18n/fr/lib/calculatrice.rb +0 -10
  49. data/examples/i18n/id/Rakefile +0 -6
  50. data/examples/i18n/id/features/addition.feature +0 -16
  51. data/examples/i18n/id/features/division.feature +0 -9
  52. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +0 -24
  53. data/examples/i18n/id/lib/calculator.rb +0 -14
  54. data/examples/i18n/it/Rakefile +0 -6
  55. data/examples/i18n/it/features/somma.feature +0 -10
  56. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +0 -24
  57. data/examples/i18n/it/lib/calcolatrice.rb +0 -11
  58. data/examples/i18n/ja/README.txt +0 -5
  59. data/examples/i18n/ja/Rakefile +0 -6
  60. data/examples/i18n/ja/features/addition.feature +0 -16
  61. data/examples/i18n/ja/features/division.feature +0 -9
  62. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +0 -24
  63. data/examples/i18n/ja/lib/calculator.rb +0 -14
  64. data/examples/i18n/ko/Rakefile +0 -6
  65. data/examples/i18n/ko/features/addition.feature +0 -16
  66. data/examples/i18n/ko/features/division.feature +0 -10
  67. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +0 -24
  68. data/examples/i18n/ko/lib/calculator.rb +0 -14
  69. data/examples/i18n/lt/Rakefile +0 -6
  70. data/examples/i18n/lt/features/addition.feature +0 -17
  71. data/examples/i18n/lt/features/division.feature +0 -9
  72. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +0 -24
  73. data/examples/i18n/lt/lib/calculator.rb +0 -14
  74. data/examples/i18n/no/Rakefile +0 -6
  75. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +0 -24
  76. data/examples/i18n/no/features/summering.feature +0 -18
  77. data/examples/i18n/no/lib/kalkulator.rb +0 -11
  78. data/examples/i18n/pt/Rakefile +0 -6
  79. data/examples/i18n/pt/features/adicao.feature +0 -10
  80. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +0 -24
  81. data/examples/i18n/pt/lib/calculadora.rb +0 -10
  82. data/examples/i18n/ro/Rakefile +0 -6
  83. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +0 -24
  84. data/examples/i18n/ro/features/suma.feature +0 -10
  85. data/examples/i18n/ro/lib/calculator.rb +0 -11
  86. data/examples/i18n/se/Rakefile +0 -6
  87. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +0 -24
  88. data/examples/i18n/se/features/summering.feature +0 -17
  89. data/examples/i18n/se/lib/kalkulator.rb +0 -11
  90. data/examples/i18n/zh-CN/Rakefile +0 -6
  91. data/examples/i18n/zh-CN/features/addition.feature +0 -17
  92. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +0 -26
  93. data/examples/i18n/zh-CN/lib/calculator.rb +0 -10
  94. data/examples/java/README.textile +0 -22
  95. data/examples/java/Rakefile +0 -12
  96. data/examples/java/features/hello.feature +0 -11
  97. data/examples/java/features/step_definitons/hello_steps.rb +0 -25
  98. data/examples/java/features/step_definitons/tree_steps.rb +0 -14
  99. data/examples/java/features/tree.feature +0 -9
  100. data/examples/jbehave/README.textile +0 -17
  101. data/examples/jbehave/features/support/env.rb +0 -7
  102. data/examples/jbehave/features/trading.feature +0 -24
  103. data/examples/jbehave/pom.xml +0 -48
  104. data/examples/selenium/Rakefile +0 -6
  105. data/examples/selenium/features/search.feature +0 -9
  106. data/examples/selenium/features/step_definitons/stories_steps.rb +0 -40
  107. data/examples/self_test/README.textile +0 -6
  108. data/examples/self_test/features/call_undefined_step_from_step_def.feature +0 -7
  109. data/examples/self_test/features/lots_of_undefined.feature +0 -8
  110. data/examples/self_test/features/outline_sample.feature +0 -12
  111. data/examples/self_test/features/sample.feature +0 -16
  112. data/examples/self_test/features/step_definitions/sample_steps.rb +0 -25
  113. data/examples/test_unit/Rakefile +0 -6
  114. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +0 -26
  115. data/examples/test_unit/features/test_unit.feature +0 -9
  116. data/examples/tickets/Rakefile +0 -11
  117. data/examples/tickets/cucumber.yml +0 -2
  118. data/examples/tickets/features/lib/eatting_machine.rb +0 -18
  119. data/examples/tickets/features/lib/pantry.rb +0 -20
  120. data/examples/tickets/features/scenario_outline.feature +0 -90
  121. data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +0 -42
  122. data/examples/tickets/features/step_definitons/tickets_steps.rb +0 -61
  123. data/examples/tickets/features/tickets.feature +0 -28
  124. data/examples/watir/README.textile +0 -16
  125. data/examples/watir/Rakefile +0 -6
  126. data/examples/watir/features/search.feature +0 -9
  127. data/examples/watir/features/step_definitons/search_steps.rb +0 -24
  128. data/examples/watir/features/support/env.rb +0 -32
  129. data/features/cucumber_cli.feature +0 -327
  130. data/features/cucumber_cli_outlines.feature +0 -81
  131. data/features/report_called_undefined_steps.feature +0 -32
  132. data/features/step_definitions/cucumber_steps.rb +0 -31
  133. data/features/step_definitions/extra_steps.rb +0 -2
  134. data/features/support/env.rb +0 -7
  135. data/gem_tasks/deployment.rake +0 -11
  136. data/gem_tasks/environment.rake +0 -7
  137. data/gem_tasks/features.rake +0 -6
  138. data/gem_tasks/fix_cr_lf.rake +0 -10
  139. data/gem_tasks/flog.rake +0 -4
  140. data/gem_tasks/gemspec.rake +0 -10
  141. data/gem_tasks/rspec.rake +0 -35
  142. data/gem_tasks/yard.rake +0 -8
  143. data/lib/autotest/cucumber.rb +0 -6
  144. data/lib/autotest/cucumber_mixin.rb +0 -124
  145. data/lib/autotest/cucumber_rails.rb +0 -6
  146. data/lib/autotest/cucumber_rails_rspec.rb +0 -6
  147. data/lib/autotest/cucumber_rspec.rb +0 -6
  148. data/lib/autotest/discover.rb +0 -9
  149. data/lib/cucumber/ast/comment.rb +0 -26
  150. data/lib/cucumber/ast/examples.rb +0 -22
  151. data/lib/cucumber/ast/feature.rb +0 -60
  152. data/lib/cucumber/ast/features.rb +0 -39
  153. data/lib/cucumber/ast/filter.rb +0 -22
  154. data/lib/cucumber/ast/outline_table.rb +0 -49
  155. data/lib/cucumber/ast/py_string.rb +0 -52
  156. data/lib/cucumber/ast/scenario.rb +0 -95
  157. data/lib/cucumber/ast/scenario_outline.rb +0 -83
  158. data/lib/cucumber/ast/step.rb +0 -139
  159. data/lib/cucumber/ast/table.rb +0 -214
  160. data/lib/cucumber/ast/tags.rb +0 -33
  161. data/lib/cucumber/ast/visitor.rb +0 -93
  162. data/lib/cucumber/ast.rb +0 -27
  163. data/lib/cucumber/broadcaster.rb +0 -15
  164. data/lib/cucumber/cli.rb +0 -410
  165. data/lib/cucumber/core_ext/exception.rb +0 -53
  166. data/lib/cucumber/core_ext/instance_exec.rb +0 -54
  167. data/lib/cucumber/core_ext/proc.rb +0 -33
  168. data/lib/cucumber/core_ext/string.rb +0 -48
  169. data/lib/cucumber/formatter/ansicolor.rb +0 -106
  170. data/lib/cucumber/formatter/console.rb +0 -116
  171. data/lib/cucumber/formatter/pretty.rb +0 -158
  172. data/lib/cucumber/formatter/profile.rb +0 -77
  173. data/lib/cucumber/formatter/progress.rb +0 -68
  174. data/lib/cucumber/formatter/rerun.rb +0 -35
  175. data/lib/cucumber/formatter.rb +0 -1
  176. data/lib/cucumber/formatters/autotest_formatter.rb +0 -21
  177. data/lib/cucumber/formatters/cucumber.css +0 -132
  178. data/lib/cucumber/formatters/cucumber.js +0 -11
  179. data/lib/cucumber/formatters/html_formatter.rb +0 -152
  180. data/lib/cucumber/formatters/jquery.js +0 -32
  181. data/lib/cucumber/formatters/pretty_formatter.rb +0 -285
  182. data/lib/cucumber/formatters/unicode.rb +0 -35
  183. data/lib/cucumber/jbehave.rb +0 -104
  184. data/lib/cucumber/languages.yml +0 -314
  185. data/lib/cucumber/parser/basic.rb +0 -0
  186. data/lib/cucumber/parser/feature.rb +0 -1315
  187. data/lib/cucumber/parser/feature.tt +0 -160
  188. data/lib/cucumber/parser/i18n.tt +0 -27
  189. data/lib/cucumber/parser/table.rb +0 -396
  190. data/lib/cucumber/parser/table.tt +0 -53
  191. data/lib/cucumber/parser/treetop_ext.rb +0 -67
  192. data/lib/cucumber/parser.rb +0 -24
  193. data/lib/cucumber/platform.rb +0 -18
  194. data/lib/cucumber/rails/rspec.rb +0 -5
  195. data/lib/cucumber/rails/world.rb +0 -73
  196. data/lib/cucumber/rake/task.rb +0 -106
  197. data/lib/cucumber/step_definition.rb +0 -87
  198. data/lib/cucumber/step_mother.rb +0 -164
  199. data/lib/cucumber/treetop_parser/feature_fi.rb +0 -1951
  200. data/lib/cucumber/version.rb +0 -10
  201. data/lib/cucumber.rb +0 -72
  202. data/pretty.txt +0 -486
  203. data/rails_generators/cucumber/USAGE +0 -11
  204. data/rails_generators/cucumber/cucumber_generator.rb +0 -31
  205. data/rails_generators/cucumber/templates/cucumber +0 -8
  206. data/rails_generators/cucumber/templates/cucumber.rake +0 -7
  207. data/rails_generators/cucumber/templates/env.rb +0 -16
  208. data/rails_generators/cucumber/templates/paths.rb +0 -12
  209. data/rails_generators/cucumber/templates/webrat_steps.rb +0 -99
  210. data/rails_generators/feature/USAGE +0 -12
  211. data/rails_generators/feature/feature_generator.rb +0 -36
  212. data/rails_generators/feature/templates/feature.erb +0 -31
  213. data/rails_generators/feature/templates/steps.erb +0 -24
  214. data/spec/cucumber/ast/feature_factory.rb +0 -54
  215. data/spec/cucumber/ast/feature_spec.rb +0 -60
  216. data/spec/cucumber/ast/py_string_spec.rb +0 -40
  217. data/spec/cucumber/ast/scenario_outline_spec.rb +0 -64
  218. data/spec/cucumber/ast/scenario_spec.rb +0 -82
  219. data/spec/cucumber/ast/step_spec.rb +0 -45
  220. data/spec/cucumber/ast/table_spec.rb +0 -81
  221. data/spec/cucumber/broadcaster_spec.rb +0 -14
  222. data/spec/cucumber/cli_spec.rb +0 -416
  223. data/spec/cucumber/core_ext/proc_spec.rb +0 -37
  224. data/spec/cucumber/core_ext/string_spec.rb +0 -42
  225. data/spec/cucumber/formatter/ansicolor_spec.rb +0 -35
  226. data/spec/cucumber/formatter/html/cucumber.css +0 -37
  227. data/spec/cucumber/formatter/html/cucumber.js +0 -11
  228. data/spec/cucumber/formatter/html/index.html +0 -45
  229. data/spec/cucumber/formatter/html/jquery-1.3.min.js +0 -19
  230. data/spec/cucumber/formatter/html/jquery.uitableedit.js +0 -100
  231. data/spec/cucumber/formatters/autotest_formatter_spec.rb +0 -27
  232. data/spec/cucumber/formatters/features.html +0 -269
  233. data/spec/cucumber/formatters/profile_formatter_spec.rb +0 -198
  234. data/spec/cucumber/parser/feature_parser_spec.rb +0 -247
  235. data/spec/cucumber/parser/table_parser_spec.rb +0 -48
  236. data/spec/cucumber/rails/stubs/mini_rails.rb +0 -18
  237. data/spec/cucumber/rails/stubs/test_help.rb +0 -1
  238. data/spec/cucumber/rails/world_spec.rb +0 -11
  239. data/spec/cucumber/sell_cucumbers.feature +0 -19
  240. data/spec/cucumber/step_definition_spec.rb +0 -62
  241. data/spec/cucumber/step_mom_spec.rb +0 -49
  242. data/spec/cucumber/treetop_parser/empty_feature.feature +0 -4
  243. data/spec/cucumber/treetop_parser/empty_scenario.feature +0 -9
  244. data/spec/cucumber/treetop_parser/empty_scenario_outline.feature +0 -3
  245. data/spec/cucumber/treetop_parser/fit_scenario.feature +0 -8
  246. data/spec/cucumber/treetop_parser/given_scenario.feature +0 -9
  247. data/spec/cucumber/treetop_parser/invalid_scenario_outlines.feature +0 -7
  248. data/spec/cucumber/treetop_parser/multiline_steps.feature +0 -17
  249. data/spec/cucumber/treetop_parser/multiple_tables.feature +0 -27
  250. data/spec/cucumber/treetop_parser/scenario_outline.feature +0 -16
  251. data/spec/cucumber/treetop_parser/spaces.feature +0 -12
  252. data/spec/cucumber/treetop_parser/test_dos.feature +0 -25
  253. data/spec/cucumber/treetop_parser/with_comments.feature +0 -10
  254. data/spec/cucumber/treetop_parser/with_tags.feature +0 -18
  255. data/spec/cucumber/world/pending_spec.rb +0 -47
  256. data/spec/spec.opts +0 -2
  257. data/spec/spec_helper.rb +0 -21
@@ -1,160 +0,0 @@
1
- module Cucumber
2
- module Parser
3
- # TIP: When you hack on the grammar, just delete feature.rb in this directory.
4
- # Treetop will then generate the parser in-memory. When you're happy, just generate
5
- # the rb file with tt feature.tt
6
- grammar Feature
7
- include I18n
8
- include Table
9
-
10
- rule feature
11
- white comment white tags white header:(!(scenario_outline / scenario) .)* feature_elements {
12
- def build
13
- Ast::Feature.new(comment.build, tags.build, header.text_value, feature_elements.build)
14
- end
15
- }
16
- end
17
-
18
- rule tags
19
- white ts:(tag (space/eol)+)* {
20
- def build
21
- tag_names = ts.elements.map{|e| e.tag.tag_name.text_value}
22
- Ast::Tags.new(ts.line, tag_names)
23
- end
24
- }
25
- end
26
-
27
- rule tag
28
- '@' tag_name:([a-z0-9])+
29
- end
30
-
31
- rule comment
32
- (comment_line eol+)* {
33
- def build
34
- Ast::Comment.new(text_value)
35
- end
36
- }
37
- end
38
-
39
- rule comment_line
40
- '#' line_to_eol
41
- end
42
-
43
- rule feature_elements
44
- (scenario / scenario_outline)* {
45
- def build
46
- elements.map{|s| s.build}
47
- end
48
- }
49
- end
50
-
51
- rule scenario
52
- comment tags white scenario_keyword space* name:line_to_eol (eol+ / eof) steps {
53
- def build
54
- Ast::Scenario.new(
55
- comment.build,
56
- tags.build,
57
- scenario_keyword.line,
58
- scenario_keyword.text_value,
59
- name.text_value,
60
- steps.build
61
- )
62
- end
63
- }
64
- end
65
-
66
- rule scenario_outline
67
- comment tags white scenario_outline_keyword space* name:line_to_eol white steps examples_sections {
68
- def build
69
- Ast::ScenarioOutline.new(
70
- comment.build,
71
- tags.build,
72
- scenario_outline_keyword.line,
73
- scenario_outline_keyword.text_value,
74
- name.text_value,
75
- steps.build,
76
- examples_sections.build
77
- )
78
- end
79
- }
80
- end
81
-
82
- rule steps
83
- step* {
84
- def build
85
- elements.map{|e| e.build}
86
- end
87
- }
88
- end
89
-
90
- rule step
91
- space* step_keyword space* name:line_to_eol (eol+ / eof) multi:multiline_arg? {
92
- def build
93
- if multi.respond_to?(:build)
94
- Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value, multi.build)
95
- else
96
- Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value)
97
- end
98
- end
99
- }
100
- end
101
-
102
- rule examples_sections
103
- examples+ {
104
- def build
105
- elements.map{|e| e.build}
106
- end
107
- }
108
- end
109
-
110
- rule examples
111
- space* examples_keyword white table {
112
- def build
113
- [examples_keyword.line, examples_keyword.text_value, "", table.raw]
114
- end
115
- }
116
- end
117
-
118
- rule multiline_arg
119
- table / py_string
120
- end
121
-
122
- rule line_to_eol
123
- (!eol .)+
124
- end
125
-
126
- rule py_string
127
- open_py_string s:(!close_py_string .)* close_py_string {
128
- def build
129
- Ast::PyString.new(open_py_string.line, close_py_string.line, s.text_value, open_py_string.indentation)
130
- end
131
- }
132
- end
133
-
134
- rule open_py_string
135
- white '"""' space* eol {
136
- def indentation
137
- white.text_value.length
138
- end
139
-
140
- def line
141
- white.line
142
- end
143
- }
144
- end
145
-
146
- rule close_py_string
147
- eol space* quotes:'"""' white {
148
- def line
149
- quotes.line
150
- end
151
- }
152
- end
153
-
154
- rule white
155
- (space / eol)*
156
- end
157
-
158
- end
159
- end
160
- end
@@ -1,27 +0,0 @@
1
- module Cucumber
2
- module Parser
3
- grammar I18n
4
-
5
- rule scenario_keyword
6
- '<%= keywords['scenario'] %>:'
7
- end
8
-
9
- rule scenario_outline_keyword
10
- '<%= keywords['scenario_outline'] %>:'
11
- end
12
-
13
- rule step_keyword
14
- '<%= keywords['given'] %>' /
15
- '<%= keywords['when'] %>' /
16
- '<%= keywords['then'] %>' /
17
- '<%= keywords['and'] %>' /
18
- '<%= keywords['but'] %>'
19
- end
20
-
21
- rule examples_keyword
22
- '<%= keywords['examples'] %>' ':'?
23
- end
24
-
25
- end
26
- end
27
- end
@@ -1,396 +0,0 @@
1
- module Cucumber
2
- module Parser
3
- module Table
4
- include Treetop::Runtime
5
-
6
- def root
7
- @root || :table
8
- end
9
-
10
- module Table0
11
- def build
12
- Ast::Table.new(raw)
13
- end
14
-
15
- def raw
16
- elements.map{|e| e.build}
17
- end
18
- end
19
-
20
- def _nt_table
21
- start_index = index
22
- if node_cache[:table].has_key?(index)
23
- cached = node_cache[:table][index]
24
- @index = cached.interval.end if cached
25
- return cached
26
- end
27
-
28
- s0, i0 = [], index
29
- loop do
30
- r1 = _nt_table_row
31
- if r1
32
- s0 << r1
33
- else
34
- break
35
- end
36
- end
37
- if s0.empty?
38
- self.index = i0
39
- r0 = nil
40
- else
41
- r0 = SyntaxNode.new(input, i0...index, s0)
42
- r0.extend(Table0)
43
- end
44
-
45
- node_cache[:table][start_index] = r0
46
-
47
- return r0
48
- end
49
-
50
- module TableRow0
51
- def cell
52
- elements[0]
53
- end
54
-
55
- end
56
-
57
- module TableRow1
58
- def cells
59
- elements[2]
60
- end
61
-
62
- end
63
-
64
- module TableRow2
65
- def build
66
- row = cells.elements.map do |elt|
67
- value = elt.cell.text_value.strip
68
- value.empty? ? nil : value
69
- end
70
-
71
- class << row
72
- attr_accessor :line
73
- end
74
- row.line = cells.line
75
-
76
- row
77
- end
78
- end
79
-
80
- def _nt_table_row
81
- start_index = index
82
- if node_cache[:table_row].has_key?(index)
83
- cached = node_cache[:table_row][index]
84
- @index = cached.interval.end if cached
85
- return cached
86
- end
87
-
88
- i0, s0 = index, []
89
- s1, i1 = [], index
90
- loop do
91
- r2 = _nt_space
92
- if r2
93
- s1 << r2
94
- else
95
- break
96
- end
97
- end
98
- r1 = SyntaxNode.new(input, i1...index, s1)
99
- s0 << r1
100
- if r1
101
- if input.index('|', index) == index
102
- r3 = (SyntaxNode).new(input, index...(index + 1))
103
- @index += 1
104
- else
105
- terminal_parse_failure('|')
106
- r3 = nil
107
- end
108
- s0 << r3
109
- if r3
110
- s4, i4 = [], index
111
- loop do
112
- i5, s5 = index, []
113
- r6 = _nt_cell
114
- s5 << r6
115
- if r6
116
- if input.index('|', index) == index
117
- r7 = (SyntaxNode).new(input, index...(index + 1))
118
- @index += 1
119
- else
120
- terminal_parse_failure('|')
121
- r7 = nil
122
- end
123
- s5 << r7
124
- end
125
- if s5.last
126
- r5 = (SyntaxNode).new(input, i5...index, s5)
127
- r5.extend(TableRow0)
128
- else
129
- self.index = i5
130
- r5 = nil
131
- end
132
- if r5
133
- s4 << r5
134
- else
135
- break
136
- end
137
- end
138
- if s4.empty?
139
- self.index = i4
140
- r4 = nil
141
- else
142
- r4 = SyntaxNode.new(input, i4...index, s4)
143
- end
144
- s0 << r4
145
- if r4
146
- s8, i8 = [], index
147
- loop do
148
- r9 = _nt_space
149
- if r9
150
- s8 << r9
151
- else
152
- break
153
- end
154
- end
155
- r8 = SyntaxNode.new(input, i8...index, s8)
156
- s0 << r8
157
- if r8
158
- i10 = index
159
- s11, i11 = [], index
160
- loop do
161
- r12 = _nt_eol
162
- if r12
163
- s11 << r12
164
- else
165
- break
166
- end
167
- end
168
- if s11.empty?
169
- self.index = i11
170
- r11 = nil
171
- else
172
- r11 = SyntaxNode.new(input, i11...index, s11)
173
- end
174
- if r11
175
- r10 = r11
176
- else
177
- r13 = _nt_eof
178
- if r13
179
- r10 = r13
180
- else
181
- self.index = i10
182
- r10 = nil
183
- end
184
- end
185
- s0 << r10
186
- end
187
- end
188
- end
189
- end
190
- if s0.last
191
- r0 = (SyntaxNode).new(input, i0...index, s0)
192
- r0.extend(TableRow1)
193
- r0.extend(TableRow2)
194
- else
195
- self.index = i0
196
- r0 = nil
197
- end
198
-
199
- node_cache[:table_row][start_index] = r0
200
-
201
- return r0
202
- end
203
-
204
- module Cell0
205
- end
206
-
207
- def _nt_cell
208
- start_index = index
209
- if node_cache[:cell].has_key?(index)
210
- cached = node_cache[:cell][index]
211
- @index = cached.interval.end if cached
212
- return cached
213
- end
214
-
215
- s0, i0 = [], index
216
- loop do
217
- i1, s1 = index, []
218
- i2 = index
219
- i3 = index
220
- if input.index('|', index) == index
221
- r4 = (SyntaxNode).new(input, index...(index + 1))
222
- @index += 1
223
- else
224
- terminal_parse_failure('|')
225
- r4 = nil
226
- end
227
- if r4
228
- r3 = r4
229
- else
230
- r5 = _nt_eol
231
- if r5
232
- r3 = r5
233
- else
234
- self.index = i3
235
- r3 = nil
236
- end
237
- end
238
- if r3
239
- r2 = nil
240
- else
241
- self.index = i2
242
- r2 = SyntaxNode.new(input, index...index)
243
- end
244
- s1 << r2
245
- if r2
246
- if index < input_length
247
- r6 = (SyntaxNode).new(input, index...(index + 1))
248
- @index += 1
249
- else
250
- terminal_parse_failure("any character")
251
- r6 = nil
252
- end
253
- s1 << r6
254
- end
255
- if s1.last
256
- r1 = (SyntaxNode).new(input, i1...index, s1)
257
- r1.extend(Cell0)
258
- else
259
- self.index = i1
260
- r1 = nil
261
- end
262
- if r1
263
- s0 << r1
264
- else
265
- break
266
- end
267
- end
268
- r0 = SyntaxNode.new(input, i0...index, s0)
269
-
270
- node_cache[:cell][start_index] = r0
271
-
272
- return r0
273
- end
274
-
275
- def _nt_space
276
- start_index = index
277
- if node_cache[:space].has_key?(index)
278
- cached = node_cache[:space][index]
279
- @index = cached.interval.end if cached
280
- return cached
281
- end
282
-
283
- if input.index(Regexp.new('[ \\t]'), index) == index
284
- r0 = (SyntaxNode).new(input, index...(index + 1))
285
- @index += 1
286
- else
287
- r0 = nil
288
- end
289
-
290
- node_cache[:space][start_index] = r0
291
-
292
- return r0
293
- end
294
-
295
- module Eol0
296
- end
297
-
298
- def _nt_eol
299
- start_index = index
300
- if node_cache[:eol].has_key?(index)
301
- cached = node_cache[:eol][index]
302
- @index = cached.interval.end if cached
303
- return cached
304
- end
305
-
306
- i0 = index
307
- if input.index("\n", index) == index
308
- r1 = (SyntaxNode).new(input, index...(index + 1))
309
- @index += 1
310
- else
311
- terminal_parse_failure("\n")
312
- r1 = nil
313
- end
314
- if r1
315
- r0 = r1
316
- else
317
- i2, s2 = index, []
318
- if input.index("\r", index) == index
319
- r3 = (SyntaxNode).new(input, index...(index + 1))
320
- @index += 1
321
- else
322
- terminal_parse_failure("\r")
323
- r3 = nil
324
- end
325
- s2 << r3
326
- if r3
327
- if input.index("\n", index) == index
328
- r5 = (SyntaxNode).new(input, index...(index + 1))
329
- @index += 1
330
- else
331
- terminal_parse_failure("\n")
332
- r5 = nil
333
- end
334
- if r5
335
- r4 = r5
336
- else
337
- r4 = SyntaxNode.new(input, index...index)
338
- end
339
- s2 << r4
340
- end
341
- if s2.last
342
- r2 = (SyntaxNode).new(input, i2...index, s2)
343
- r2.extend(Eol0)
344
- else
345
- self.index = i2
346
- r2 = nil
347
- end
348
- if r2
349
- r0 = r2
350
- else
351
- self.index = i0
352
- r0 = nil
353
- end
354
- end
355
-
356
- node_cache[:eol][start_index] = r0
357
-
358
- return r0
359
- end
360
-
361
- def _nt_eof
362
- start_index = index
363
- if node_cache[:eof].has_key?(index)
364
- cached = node_cache[:eof][index]
365
- @index = cached.interval.end if cached
366
- return cached
367
- end
368
-
369
- i0 = index
370
- if index < input_length
371
- r1 = (SyntaxNode).new(input, index...(index + 1))
372
- @index += 1
373
- else
374
- terminal_parse_failure("any character")
375
- r1 = nil
376
- end
377
- if r1
378
- r0 = nil
379
- else
380
- self.index = i0
381
- r0 = SyntaxNode.new(input, index...index)
382
- end
383
-
384
- node_cache[:eof][start_index] = r0
385
-
386
- return r0
387
- end
388
-
389
- end
390
-
391
- class TableParser < Treetop::Runtime::CompiledParser
392
- include Table
393
- end
394
-
395
- end
396
- end
@@ -1,53 +0,0 @@
1
- module Cucumber
2
- module Parser
3
- grammar Table
4
-
5
- rule table
6
- table_row+ {
7
- def build
8
- Ast::Table.new(raw)
9
- end
10
-
11
- def raw
12
- elements.map{|e| e.build}
13
- end
14
- }
15
- end
16
-
17
- rule table_row
18
- space* '|' cells:(cell '|')+ space* (eol+ / eof) {
19
- def build
20
- row = cells.elements.map do |elt|
21
- value = elt.cell.text_value.strip
22
- value.empty? ? nil : value
23
- end
24
-
25
- class << row
26
- attr_accessor :line
27
- end
28
- row.line = cells.line
29
-
30
- row
31
- end
32
- }
33
- end
34
-
35
- rule cell
36
- (!('|' / eol) .)*
37
- end
38
-
39
- rule space
40
- [ \t]
41
- end
42
-
43
- rule eol
44
- "\n" / ("\r" "\n"?)
45
- end
46
-
47
- rule eof
48
- !.
49
- end
50
-
51
- end
52
- end
53
- end
@@ -1,67 +0,0 @@
1
- require 'treetop'
2
- require 'treetop/runtime'
3
- require 'treetop/ruby_extensions'
4
-
5
- module Cucumber
6
- module Parser
7
- module TreetopExt
8
- FILE_LINE_PATTERN = /^([\w\W]*?):([\d:]+)$/
9
-
10
- # Parses a file and returns a Cucumber::Ast
11
- def parse_file(file)
12
- _, path, lines = *FILE_LINE_PATTERN.match(file)
13
- if path
14
- lines = lines.split(':').map { |line| line.to_i }
15
- else
16
- path = file
17
- lines = []
18
- end
19
-
20
- feature = File.open(path, Cucumber.file_mode('r')) do |io|
21
- parse_or_fail(io.read, path)
22
- end
23
- feature.lines = lines
24
- feature
25
- end
26
- end
27
-
28
- class SyntaxError < StandardError
29
- def initialize(parser, file, line_offset)
30
- tf = parser.terminal_failures
31
- expected = tf.size == 1 ? tf[0].expected_string.inspect : "one of #{tf.map{|f| f.expected_string.inspect}.uniq*', '}"
32
- after = parser.input[parser.index...parser.failure_index]
33
- found = parser.input[parser.failure_index..parser.failure_index]
34
-
35
- line = parser.failure_line + line_offset
36
- message = "#{file}:#{line}:#{parser.failure_column}: " +
37
- "Parse error, expected #{expected}. After #{after.inspect}. Found: #{found.inspect}"
38
- super(message)
39
- end
40
- end
41
- end
42
- end
43
-
44
- module Treetop
45
- module Runtime
46
- class SyntaxNode
47
- def line
48
- input.line_of(interval.first)
49
- end
50
- end
51
-
52
- class CompiledParser
53
- include Cucumber::Parser::TreetopExt
54
-
55
- def parse_or_fail(s, file=nil, line=0)
56
- parse_tree = parse(s)
57
- if parse_tree.nil?
58
- raise Cucumber::Parser::SyntaxError.new(self, file, line)
59
- else
60
- ast = parse_tree.build
61
- ast.file = file
62
- ast
63
- end
64
- end
65
- end
66
- end
67
- end