notch8-cucumber 0.1.99.23

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