fcoury-cucumber 0.2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (336) hide show
  1. data/History.txt +525 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +335 -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 +30 -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 +11 -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-lol/Rakefile +6 -0
  34. data/examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb +16 -0
  35. data/examples/i18n/en-lol/features/stuffing.feature +8 -0
  36. data/examples/i18n/en-lol/features/support/env.rb +8 -0
  37. data/examples/i18n/en-lol/lib/basket.rb +12 -0
  38. data/examples/i18n/en-lol/lib/belly.rb +11 -0
  39. data/examples/i18n/en/Rakefile +6 -0
  40. data/examples/i18n/en/features/addition.feature +16 -0
  41. data/examples/i18n/en/features/division.feature +9 -0
  42. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +24 -0
  43. data/examples/i18n/en/lib/calculator.rb +14 -0
  44. data/examples/i18n/es/Rakefile +6 -0
  45. data/examples/i18n/es/features/adicion.feature +16 -0
  46. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +21 -0
  47. data/examples/i18n/es/lib/calculador.rb +14 -0
  48. data/examples/i18n/et/Rakefile +6 -0
  49. data/examples/i18n/et/features/jagamine.feature +9 -0
  50. data/examples/i18n/et/features/liitmine.feature +16 -0
  51. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +24 -0
  52. data/examples/i18n/et/lib/kalkulaator.rb +14 -0
  53. data/examples/i18n/fi/Rakefile +6 -0
  54. data/examples/i18n/fi/features/jakolasku.feature +9 -0
  55. data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +24 -0
  56. data/examples/i18n/fi/features/yhteenlasku.feature +16 -0
  57. data/examples/i18n/fi/lib/laskin.rb +14 -0
  58. data/examples/i18n/fr/Rakefile +6 -0
  59. data/examples/i18n/fr/features/addition.feature +17 -0
  60. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +25 -0
  61. data/examples/i18n/fr/lib/calculatrice.rb +10 -0
  62. data/examples/i18n/id/Rakefile +6 -0
  63. data/examples/i18n/id/features/addition.feature +16 -0
  64. data/examples/i18n/id/features/division.feature +9 -0
  65. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +24 -0
  66. data/examples/i18n/id/lib/calculator.rb +14 -0
  67. data/examples/i18n/it/Rakefile +6 -0
  68. data/examples/i18n/it/features/somma.feature +10 -0
  69. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +24 -0
  70. data/examples/i18n/it/lib/calcolatrice.rb +11 -0
  71. data/examples/i18n/ja/Rakefile +6 -0
  72. data/examples/i18n/ja/features/addition.feature +16 -0
  73. data/examples/i18n/ja/features/division.feature +9 -0
  74. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +24 -0
  75. data/examples/i18n/ja/lib/calculator.rb +14 -0
  76. data/examples/i18n/ko/Rakefile +6 -0
  77. data/examples/i18n/ko/features/addition.feature +16 -0
  78. data/examples/i18n/ko/features/division.feature +10 -0
  79. data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +24 -0
  80. data/examples/i18n/ko/lib/calculator.rb +14 -0
  81. data/examples/i18n/lt/Rakefile +6 -0
  82. data/examples/i18n/lt/features/addition.feature +17 -0
  83. data/examples/i18n/lt/features/division.feature +9 -0
  84. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +24 -0
  85. data/examples/i18n/lt/lib/calculator.rb +14 -0
  86. data/examples/i18n/no/Rakefile +6 -0
  87. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +17 -0
  88. data/examples/i18n/no/features/summering.feature +18 -0
  89. data/examples/i18n/no/features/support/env.rb +6 -0
  90. data/examples/i18n/no/lib/kalkulator.rb +11 -0
  91. data/examples/i18n/pt/Rakefile +6 -0
  92. data/examples/i18n/pt/features/adicao.feature +10 -0
  93. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +24 -0
  94. data/examples/i18n/pt/lib/calculadora.rb +10 -0
  95. data/examples/i18n/ro/Rakefile +6 -0
  96. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +24 -0
  97. data/examples/i18n/ro/features/suma.feature +10 -0
  98. data/examples/i18n/ro/lib/calculator.rb +11 -0
  99. data/examples/i18n/ru/Rakefile +6 -0
  100. data/examples/i18n/ru/features/addition.feature +10 -0
  101. data/examples/i18n/ru/features/consecutive_calculations.feature +16 -0
  102. data/examples/i18n/ru/features/division.feature +15 -0
  103. data/examples/i18n/ru/features/step_definitons/calculator_steps.rb +19 -0
  104. data/examples/i18n/ru/features/support/env.rb +6 -0
  105. data/examples/i18n/ru/features/support/world.rb +7 -0
  106. data/examples/i18n/ru/lib/calculator.rb +24 -0
  107. data/examples/i18n/se/Rakefile +6 -0
  108. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +24 -0
  109. data/examples/i18n/se/features/summering.feature +17 -0
  110. data/examples/i18n/se/lib/kalkulator.rb +11 -0
  111. data/examples/i18n/sk/Rakefile +6 -0
  112. data/examples/i18n/sk/features/addition.feature +16 -0
  113. data/examples/i18n/sk/features/division.feature +9 -0
  114. data/examples/i18n/sk/features/step_definitons/calculator_steps.rb +24 -0
  115. data/examples/i18n/sk/lib/calculator.rb +14 -0
  116. data/examples/i18n/zh-CN/Rakefile +6 -0
  117. data/examples/i18n/zh-CN/features/addition.feature +17 -0
  118. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +26 -0
  119. data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
  120. data/examples/i18n/zh-TW/Rakefile +6 -0
  121. data/examples/i18n/zh-TW/features/addition.feature +16 -0
  122. data/examples/i18n/zh-TW/features/division.feature +10 -0
  123. data/examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb +24 -0
  124. data/examples/i18n/zh-TW/lib/calculator.rb +14 -0
  125. data/examples/java/README.textile +22 -0
  126. data/examples/java/Rakefile +12 -0
  127. data/examples/java/features/hello.feature +11 -0
  128. data/examples/java/features/step_definitons/hello_steps.rb +25 -0
  129. data/examples/java/features/step_definitons/tree_steps.rb +14 -0
  130. data/examples/java/features/tree.feature +9 -0
  131. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  132. data/examples/pure_java/README.textile +5 -0
  133. data/examples/selenium/Rakefile +6 -0
  134. data/examples/selenium/features/search.feature +9 -0
  135. data/examples/selenium/features/step_definitons/search_steps.rb +13 -0
  136. data/examples/selenium/features/support/env.rb +19 -0
  137. data/examples/selenium_webrat/Rakefile +6 -0
  138. data/examples/selenium_webrat/features/search.feature +9 -0
  139. data/examples/selenium_webrat/features/step_definitons/search_steps.rb +13 -0
  140. data/examples/selenium_webrat/features/support/env.rb +41 -0
  141. data/examples/self_test/README.textile +6 -0
  142. data/examples/self_test/Rakefile +6 -0
  143. data/examples/self_test/features/background/background_with_name.feature +7 -0
  144. data/examples/self_test/features/background/failing_background.feature +11 -0
  145. data/examples/self_test/features/background/failing_background_after_success.feature +11 -0
  146. data/examples/self_test/features/background/multiline_args_background.feature +32 -0
  147. data/examples/self_test/features/background/passing_background.feature +10 -0
  148. data/examples/self_test/features/background/pending_background.feature +10 -0
  149. data/examples/self_test/features/background/scenario_outline_failing_background.feature +16 -0
  150. data/examples/self_test/features/background/scenario_outline_passing_background.feature +16 -0
  151. data/examples/self_test/features/call_undefined_step_from_step_def.feature +7 -0
  152. data/examples/self_test/features/failing_expectation.feature +4 -0
  153. data/examples/self_test/features/lots_of_undefined.feature +8 -0
  154. data/examples/self_test/features/outline_sample.feature +15 -0
  155. data/examples/self_test/features/sample.feature +19 -0
  156. data/examples/self_test/features/step_definitions/sample_steps.rb +70 -0
  157. data/examples/self_test/features/support/env.rb +1 -0
  158. data/examples/self_test/features/support/tag_count_formatter.rb +25 -0
  159. data/examples/self_test/features/tons_of_cukes.feature +52 -0
  160. data/examples/self_test/features/undefined_multiline_args.feature +12 -0
  161. data/examples/sinatra/Rakefile +6 -0
  162. data/examples/sinatra/app.rb +14 -0
  163. data/examples/sinatra/features/add.feature +11 -0
  164. data/examples/sinatra/features/step_definitions/add_steps.rb +15 -0
  165. data/examples/sinatra/features/support/env.rb +24 -0
  166. data/examples/sinatra/views/add.erb +5 -0
  167. data/examples/sinatra/views/layout.erb +8 -0
  168. data/examples/test_unit/Rakefile +6 -0
  169. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +26 -0
  170. data/examples/test_unit/features/test_unit.feature +9 -0
  171. data/examples/tickets/Rakefile +16 -0
  172. data/examples/tickets/cucumber.yml +3 -0
  173. data/examples/tickets/features/172.feature +28 -0
  174. data/examples/tickets/features/177/1.feature +29 -0
  175. data/examples/tickets/features/177/2.feature +21 -0
  176. data/examples/tickets/features/177/3.feature +18 -0
  177. data/examples/tickets/features/180.feature +7 -0
  178. data/examples/tickets/features/236.feature +13 -0
  179. data/examples/tickets/features/241.feature +13 -0
  180. data/examples/tickets/features/246.feature +4 -0
  181. data/examples/tickets/features/248.feature +11 -0
  182. data/examples/tickets/features/lib/eatting_machine.rb +18 -0
  183. data/examples/tickets/features/lib/pantry.rb +20 -0
  184. data/examples/tickets/features/scenario_outline.feature +95 -0
  185. data/examples/tickets/features/step_definitons/246_steps.rb +3 -0
  186. data/examples/tickets/features/step_definitons/248_steps.rb +15 -0
  187. data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +42 -0
  188. data/examples/tickets/features/step_definitons/tickets_steps.rb +73 -0
  189. data/examples/tickets/features/tickets.feature +28 -0
  190. data/examples/watir/README.textile +16 -0
  191. data/examples/watir/Rakefile +6 -0
  192. data/examples/watir/features/search.feature +9 -0
  193. data/examples/watir/features/step_definitons/search_steps.rb +24 -0
  194. data/examples/watir/features/support/env.rb +32 -0
  195. data/features/background.feature +238 -0
  196. data/features/cucumber_cli.feature +402 -0
  197. data/features/cucumber_cli_diff_disabled.feature +45 -0
  198. data/features/cucumber_cli_outlines.feature +81 -0
  199. data/features/custom_formatter.feature +11 -0
  200. data/features/report_called_undefined_steps.feature +34 -0
  201. data/features/snippet.feature +23 -0
  202. data/features/step_definitions/cucumber_steps.rb +34 -0
  203. data/features/step_definitions/extra_steps.rb +2 -0
  204. data/features/support/env.rb +8 -0
  205. data/features/usage.feature +113 -0
  206. data/gem_tasks/deployment.rake +11 -0
  207. data/gem_tasks/environment.rake +7 -0
  208. data/gem_tasks/features.rake +6 -0
  209. data/gem_tasks/fix_cr_lf.rake +10 -0
  210. data/gem_tasks/flog.rake +4 -0
  211. data/gem_tasks/gemspec.rake +10 -0
  212. data/gem_tasks/rspec.rake +38 -0
  213. data/gem_tasks/yard.rake +8 -0
  214. data/lib/autotest/cucumber.rb +6 -0
  215. data/lib/autotest/cucumber_mixin.rb +125 -0
  216. data/lib/autotest/cucumber_rails.rb +6 -0
  217. data/lib/autotest/cucumber_rails_rspec.rb +6 -0
  218. data/lib/autotest/cucumber_rspec.rb +6 -0
  219. data/lib/autotest/discover.rb +9 -0
  220. data/lib/cucumber.rb +63 -0
  221. data/lib/cucumber/ast.rb +29 -0
  222. data/lib/cucumber/ast/background.rb +50 -0
  223. data/lib/cucumber/ast/comment.rb +26 -0
  224. data/lib/cucumber/ast/examples.rb +38 -0
  225. data/lib/cucumber/ast/feature.rb +62 -0
  226. data/lib/cucumber/ast/feature_element.rb +46 -0
  227. data/lib/cucumber/ast/features.rb +26 -0
  228. data/lib/cucumber/ast/outline_table.rb +81 -0
  229. data/lib/cucumber/ast/py_string.rb +62 -0
  230. data/lib/cucumber/ast/scenario.rb +64 -0
  231. data/lib/cucumber/ast/scenario_outline.rb +90 -0
  232. data/lib/cucumber/ast/step.rb +111 -0
  233. data/lib/cucumber/ast/step_collection.rb +66 -0
  234. data/lib/cucumber/ast/step_invocation.rb +122 -0
  235. data/lib/cucumber/ast/table.rb +347 -0
  236. data/lib/cucumber/ast/tags.rb +33 -0
  237. data/lib/cucumber/ast/visitor.rb +125 -0
  238. data/lib/cucumber/broadcaster.rb +13 -0
  239. data/lib/cucumber/cli/configuration.rb +361 -0
  240. data/lib/cucumber/cli/language_help_formatter.rb +59 -0
  241. data/lib/cucumber/cli/main.rb +102 -0
  242. data/lib/cucumber/core_ext/exception.rb +53 -0
  243. data/lib/cucumber/core_ext/instance_exec.rb +67 -0
  244. data/lib/cucumber/core_ext/proc.rb +33 -0
  245. data/lib/cucumber/core_ext/string.rb +48 -0
  246. data/lib/cucumber/formatter.rb +1 -0
  247. data/lib/cucumber/formatter/ansicolor.rb +110 -0
  248. data/lib/cucumber/formatter/color_io.rb +23 -0
  249. data/lib/cucumber/formatter/console.rb +110 -0
  250. data/lib/cucumber/formatter/cucumber.css +55 -0
  251. data/lib/cucumber/formatter/cucumber.sass +49 -0
  252. data/lib/cucumber/formatter/html.rb +176 -0
  253. data/lib/cucumber/formatter/pretty.rb +174 -0
  254. data/lib/cucumber/formatter/profile.rb +77 -0
  255. data/lib/cucumber/formatter/progress.rb +60 -0
  256. data/lib/cucumber/formatter/rerun.rb +43 -0
  257. data/lib/cucumber/formatter/unicode.rb +35 -0
  258. data/lib/cucumber/formatter/usage.rb +85 -0
  259. data/lib/cucumber/formatters/unicode.rb +2 -0
  260. data/lib/cucumber/languages.yml +437 -0
  261. data/lib/cucumber/parser.rb +38 -0
  262. data/lib/cucumber/parser/basic.rb +0 -0
  263. data/lib/cucumber/parser/feature.rb +1496 -0
  264. data/lib/cucumber/parser/feature.tt +194 -0
  265. data/lib/cucumber/parser/i18n.tt +35 -0
  266. data/lib/cucumber/parser/table.rb +402 -0
  267. data/lib/cucumber/parser/table.tt +59 -0
  268. data/lib/cucumber/parser/treetop_ext.rb +75 -0
  269. data/lib/cucumber/platform.rb +17 -0
  270. data/lib/cucumber/rails/rspec.rb +8 -0
  271. data/lib/cucumber/rails/world.rb +74 -0
  272. data/lib/cucumber/rake/task.rb +138 -0
  273. data/lib/cucumber/step_definition.rb +113 -0
  274. data/lib/cucumber/step_match.rb +57 -0
  275. data/lib/cucumber/step_mother.rb +223 -0
  276. data/lib/cucumber/version.rb +10 -0
  277. data/lib/cucumber/world.rb +53 -0
  278. data/rails_generators/cucumber/USAGE +11 -0
  279. data/rails_generators/cucumber/cucumber_generator.rb +50 -0
  280. data/rails_generators/cucumber/templates/cucumber +8 -0
  281. data/rails_generators/cucumber/templates/cucumber.rake +15 -0
  282. data/rails_generators/cucumber/templates/env.rb +19 -0
  283. data/rails_generators/cucumber/templates/paths.rb +20 -0
  284. data/rails_generators/cucumber/templates/webrat_steps.rb +123 -0
  285. data/rails_generators/feature/USAGE +12 -0
  286. data/rails_generators/feature/feature_generator.rb +40 -0
  287. data/rails_generators/feature/templates/feature.erb +31 -0
  288. data/rails_generators/feature/templates/steps.erb +20 -0
  289. data/specs/cucumber/ast/background_spec.rb +50 -0
  290. data/specs/cucumber/ast/feature_factory.rb +63 -0
  291. data/specs/cucumber/ast/feature_spec.rb +38 -0
  292. data/specs/cucumber/ast/py_string_spec.rb +47 -0
  293. data/specs/cucumber/ast/scenario_outline_spec.rb +67 -0
  294. data/specs/cucumber/ast/scenario_spec.rb +65 -0
  295. data/specs/cucumber/ast/step_collection_spec.rb +16 -0
  296. data/specs/cucumber/ast/step_spec.rb +66 -0
  297. data/specs/cucumber/ast/table_spec.rb +170 -0
  298. data/specs/cucumber/ast/tags_spec.rb +19 -0
  299. data/specs/cucumber/broadcaster_spec.rb +15 -0
  300. data/specs/cucumber/cli/configuration_spec.rb +287 -0
  301. data/specs/cucumber/cli/main_spec.rb +191 -0
  302. data/specs/cucumber/core_ext/proc_spec.rb +54 -0
  303. data/specs/cucumber/core_ext/string_spec.rb +42 -0
  304. data/specs/cucumber/formatter/ansicolor_spec.rb +35 -0
  305. data/specs/cucumber/formatter/color_io_spec.rb +26 -0
  306. data/specs/cucumber/formatter/html/cucumber.css +37 -0
  307. data/specs/cucumber/formatter/html/cucumber.js +13 -0
  308. data/specs/cucumber/formatter/html/index.html +45 -0
  309. data/specs/cucumber/formatter/html/jquery-1.3.min.js +19 -0
  310. data/specs/cucumber/formatter/html/jquery.uitableedit.js +100 -0
  311. data/specs/cucumber/formatters/profile_formatter_spec.rb +198 -0
  312. data/specs/cucumber/parser/feature_parser_spec.rb +282 -0
  313. data/specs/cucumber/parser/table_parser_spec.rb +48 -0
  314. data/specs/cucumber/rails/stubs/mini_rails.rb +18 -0
  315. data/specs/cucumber/rails/stubs/test_help.rb +1 -0
  316. data/specs/cucumber/rails/world_spec.rb +11 -0
  317. data/specs/cucumber/sell_cucumbers.feature +19 -0
  318. data/specs/cucumber/step_definition_spec.rb +101 -0
  319. data/specs/cucumber/step_mother_spec.rb +102 -0
  320. data/specs/cucumber/treetop_parser/empty_feature.feature +4 -0
  321. data/specs/cucumber/treetop_parser/empty_scenario.feature +9 -0
  322. data/specs/cucumber/treetop_parser/empty_scenario_outline.feature +3 -0
  323. data/specs/cucumber/treetop_parser/fit_scenario.feature +8 -0
  324. data/specs/cucumber/treetop_parser/given_scenario.feature +9 -0
  325. data/specs/cucumber/treetop_parser/invalid_scenario_outlines.feature +7 -0
  326. data/specs/cucumber/treetop_parser/multiline_steps.feature +17 -0
  327. data/specs/cucumber/treetop_parser/multiple_tables.feature +27 -0
  328. data/specs/cucumber/treetop_parser/scenario_outline.feature +16 -0
  329. data/specs/cucumber/treetop_parser/spaces.feature +12 -0
  330. data/specs/cucumber/treetop_parser/test_dos.feature +25 -0
  331. data/specs/cucumber/treetop_parser/with_comments.feature +10 -0
  332. data/specs/cucumber/treetop_parser/with_tags.feature +18 -0
  333. data/specs/cucumber/world/pending_spec.rb +47 -0
  334. data/specs/spec.opts +2 -0
  335. data/specs/spec_helper.rb +12 -0
  336. metadata +451 -0
@@ -0,0 +1,194 @@
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
+ bg:background?
21
+ feature_elements
22
+ comment? {
23
+ def build
24
+ background = bg.respond_to?(:build) ? bg.build : nil
25
+ Ast::Feature.new(
26
+ background,
27
+ comment.build,
28
+ tags.build,
29
+ header.text_value,
30
+ feature_elements.build(background)
31
+ )
32
+ end
33
+ }
34
+ end
35
+
36
+ rule tags
37
+ white ts:(tag (space/eol)+)* {
38
+ def build
39
+ tag_names = ts.elements.map{|e| e.tag.tag_name.text_value}
40
+ Ast::Tags.new(ts.line, tag_names)
41
+ end
42
+ }
43
+ end
44
+
45
+ rule tag
46
+ '@' tag_name:([^@\r\n\t ])+
47
+ end
48
+
49
+ rule comment
50
+ (comment_line white)* {
51
+ def build
52
+ Ast::Comment.new(text_value)
53
+ end
54
+ }
55
+ end
56
+
57
+ rule comment_line
58
+ '#' line_to_eol
59
+ end
60
+
61
+ rule background
62
+ comment white background_keyword space* name:line_to_eol? (eol+ / eof) steps {
63
+ def build
64
+ Ast::Background.new(
65
+ comment.build,
66
+ background_keyword.line,
67
+ background_keyword.text_value,
68
+ name.text_value,
69
+ steps.build
70
+ )
71
+ end
72
+ }
73
+ end
74
+
75
+ rule feature_elements
76
+ (scenario / scenario_outline)* {
77
+ def build(background)
78
+ elements.map{|s| s.build(background)}
79
+ end
80
+ }
81
+ end
82
+
83
+ rule scenario
84
+ comment tags white scenario_keyword space* name:line_to_eol white steps white {
85
+ def build(background)
86
+ Ast::Scenario.new(
87
+ background,
88
+ comment.build,
89
+ tags.build,
90
+ scenario_keyword.line,
91
+ scenario_keyword.text_value,
92
+ name.text_value,
93
+ steps.build
94
+ )
95
+ end
96
+ }
97
+ end
98
+
99
+ rule scenario_outline
100
+ comment tags white scenario_outline_keyword space* name:line_to_eol white steps examples_sections white {
101
+ def build(background)
102
+ Ast::ScenarioOutline.new(
103
+ background,
104
+ comment.build,
105
+ tags.build,
106
+ scenario_outline_keyword.line,
107
+ scenario_outline_keyword.text_value,
108
+ name.text_value,
109
+ steps.build,
110
+ examples_sections.build
111
+ )
112
+ end
113
+ }
114
+ end
115
+
116
+ rule steps
117
+ step* {
118
+ def build
119
+ elements.map{|e| e.build}
120
+ end
121
+ }
122
+ end
123
+
124
+ rule step
125
+ comment space* step_keyword keyword_space name:line_to_eol (eol+ / eof) multi:multiline_arg? white {
126
+ def build
127
+ if multi.respond_to?(:build)
128
+ Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value.strip, multi.build)
129
+ else
130
+ Ast::Step.new(step_keyword.line, step_keyword.text_value, name.text_value.strip)
131
+ end
132
+ end
133
+ }
134
+ end
135
+
136
+ rule examples_sections
137
+ examples* {
138
+ def build
139
+ elements.map{|e| e.build}
140
+ end
141
+ }
142
+ end
143
+
144
+ rule examples
145
+ space* examples_keyword space* name:line_to_eol? eol table white {
146
+ def build
147
+ [examples_keyword.line, examples_keyword.text_value, name.text_value, table.raw]
148
+ end
149
+ }
150
+ end
151
+
152
+ rule multiline_arg
153
+ table / py_string
154
+ end
155
+
156
+ rule line_to_eol
157
+ (!eol .)*
158
+ end
159
+
160
+ rule py_string
161
+ open_py_string s:(!close_py_string .)* close_py_string {
162
+ def build
163
+ Ast::PyString.new(open_py_string.line, close_py_string.line, s.text_value, open_py_string.indentation)
164
+ end
165
+ }
166
+ end
167
+
168
+ rule open_py_string
169
+ white '"""' space* eol {
170
+ def indentation
171
+ white.text_value.length
172
+ end
173
+
174
+ def line
175
+ white.line
176
+ end
177
+ }
178
+ end
179
+
180
+ rule close_py_string
181
+ eol space* quotes:'"""' white {
182
+ def line
183
+ quotes.line
184
+ end
185
+ }
186
+ end
187
+
188
+ rule white
189
+ (space / eol)*
190
+ end
191
+
192
+ end
193
+ end
194
+ end
@@ -0,0 +1,35 @@
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 keyword_space
26
+ <%= keywords('space_after_keyword', true) ? 'space+' : 'space*' %>
27
+ end
28
+
29
+ rule examples_keyword
30
+ (<%= keywords('examples') %>) ':'?
31
+ end
32
+
33
+ end
34
+ end
35
+ 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