gherkin 2.12.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (333) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -15
  3. data/CONTRIBUTING.md +23 -0
  4. data/Gemfile +0 -3
  5. data/LICENSE +18 -17
  6. data/Makefile +65 -0
  7. data/README.md +9 -268
  8. data/Rakefile +17 -19
  9. data/bin/gherkin-generate-ast +21 -0
  10. data/bin/gherkin-generate-pickles +25 -0
  11. data/bin/gherkin-generate-tokens +12 -0
  12. data/gherkin-ruby.razor +218 -0
  13. data/gherkin.gemspec +22 -76
  14. data/lib/gherkin/ast_builder.rb +243 -0
  15. data/lib/gherkin/ast_node.rb +30 -0
  16. data/lib/gherkin/dialect.rb +58 -0
  17. data/lib/gherkin/errors.rb +45 -0
  18. data/lib/gherkin/gherkin-languages.json +2968 -0
  19. data/lib/gherkin/gherkin_line.rb +95 -0
  20. data/lib/gherkin/parser.rb +1910 -0
  21. data/lib/gherkin/pickles/compiler.rb +164 -0
  22. data/lib/gherkin/token.rb +18 -0
  23. data/lib/gherkin/token_formatter_builder.rb +39 -0
  24. data/lib/gherkin/token_matcher.rb +169 -0
  25. data/lib/gherkin/token_scanner.rb +40 -0
  26. data/spec/capture_warnings.rb +68 -0
  27. data/spec/coverage.rb +10 -0
  28. data/spec/gherkin/parser_spec.rb +146 -0
  29. metadata +60 -567
  30. data/.gitattributes +0 -2
  31. data/.mailmap +0 -2
  32. data/.rbenv-gemsets +0 -1
  33. data/.rspec +0 -1
  34. data/.ruby-gemset +0 -1
  35. data/.ruby-version +0 -1
  36. data/.yardopts +0 -5
  37. data/History.md +0 -881
  38. data/build_native_gems.sh +0 -7
  39. data/cucumber.yml +0 -5
  40. data/examples/parse_and_output_json.rb +0 -19
  41. data/ext/gherkin_lexer_ar/extconf.rb +0 -6
  42. data/ext/gherkin_lexer_ar/gherkin_lexer_ar.c +0 -1432
  43. data/ext/gherkin_lexer_bg/extconf.rb +0 -6
  44. data/ext/gherkin_lexer_bg/gherkin_lexer_bg.c +0 -1655
  45. data/ext/gherkin_lexer_bm/extconf.rb +0 -6
  46. data/ext/gherkin_lexer_bm/gherkin_lexer_bm.c +0 -1516
  47. data/ext/gherkin_lexer_ca/extconf.rb +0 -6
  48. data/ext/gherkin_lexer_ca/gherkin_lexer_ca.c +0 -1581
  49. data/ext/gherkin_lexer_cs/extconf.rb +0 -6
  50. data/ext/gherkin_lexer_cs/gherkin_lexer_cs.c +0 -1515
  51. data/ext/gherkin_lexer_cy_gb/extconf.rb +0 -6
  52. data/ext/gherkin_lexer_cy_gb/gherkin_lexer_cy_gb.c +0 -1282
  53. data/ext/gherkin_lexer_da/extconf.rb +0 -6
  54. data/ext/gherkin_lexer_da/gherkin_lexer_da.c +0 -1298
  55. data/ext/gherkin_lexer_de/extconf.rb +0 -6
  56. data/ext/gherkin_lexer_de/gherkin_lexer_de.c +0 -1425
  57. data/ext/gherkin_lexer_el/extconf.rb +0 -6
  58. data/ext/gherkin_lexer_el/gherkin_lexer_el.c +0 -1919
  59. data/ext/gherkin_lexer_en/extconf.rb +0 -6
  60. data/ext/gherkin_lexer_en/gherkin_lexer_en.c +0 -1418
  61. data/ext/gherkin_lexer_en_au/extconf.rb +0 -6
  62. data/ext/gherkin_lexer_en_au/gherkin_lexer_en_au.c +0 -1765
  63. data/ext/gherkin_lexer_en_lol/extconf.rb +0 -6
  64. data/ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.c +0 -1177
  65. data/ext/gherkin_lexer_en_old/extconf.rb +0 -6
  66. data/ext/gherkin_lexer_en_old/gherkin_lexer_en_old.c +0 -1309
  67. data/ext/gherkin_lexer_en_pirate/extconf.rb +0 -6
  68. data/ext/gherkin_lexer_en_pirate/gherkin_lexer_en_pirate.c +0 -1471
  69. data/ext/gherkin_lexer_en_scouse/extconf.rb +0 -6
  70. data/ext/gherkin_lexer_en_scouse/gherkin_lexer_en_scouse.c +0 -1634
  71. data/ext/gherkin_lexer_en_tx/extconf.rb +0 -6
  72. data/ext/gherkin_lexer_en_tx/gherkin_lexer_en_tx.c +0 -1265
  73. data/ext/gherkin_lexer_eo/extconf.rb +0 -6
  74. data/ext/gherkin_lexer_eo/gherkin_lexer_eo.c +0 -1241
  75. data/ext/gherkin_lexer_es/extconf.rb +0 -6
  76. data/ext/gherkin_lexer_es/gherkin_lexer_es.c +0 -1399
  77. data/ext/gherkin_lexer_et/extconf.rb +0 -6
  78. data/ext/gherkin_lexer_et/gherkin_lexer_et.c +0 -1236
  79. data/ext/gherkin_lexer_fa/extconf.rb +0 -6
  80. data/ext/gherkin_lexer_fa/gherkin_lexer_fa.c +0 -1475
  81. data/ext/gherkin_lexer_fi/extconf.rb +0 -6
  82. data/ext/gherkin_lexer_fi/gherkin_lexer_fi.c +0 -1215
  83. data/ext/gherkin_lexer_fr/extconf.rb +0 -6
  84. data/ext/gherkin_lexer_fr/gherkin_lexer_fr.c +0 -1493
  85. data/ext/gherkin_lexer_gl/extconf.rb +0 -6
  86. data/ext/gherkin_lexer_gl/gherkin_lexer_gl.c +0 -1374
  87. data/ext/gherkin_lexer_he/extconf.rb +0 -6
  88. data/ext/gherkin_lexer_he/gherkin_lexer_he.c +0 -1374
  89. data/ext/gherkin_lexer_hi/extconf.rb +0 -6
  90. data/ext/gherkin_lexer_hi/gherkin_lexer_hi.c +0 -1848
  91. data/ext/gherkin_lexer_hr/extconf.rb +0 -6
  92. data/ext/gherkin_lexer_hr/gherkin_lexer_hr.c +0 -1323
  93. data/ext/gherkin_lexer_hu/extconf.rb +0 -6
  94. data/ext/gherkin_lexer_hu/gherkin_lexer_hu.c +0 -1376
  95. data/ext/gherkin_lexer_id/extconf.rb +0 -6
  96. data/ext/gherkin_lexer_id/gherkin_lexer_id.c +0 -1208
  97. data/ext/gherkin_lexer_is/extconf.rb +0 -6
  98. data/ext/gherkin_lexer_is/gherkin_lexer_is.c +0 -1376
  99. data/ext/gherkin_lexer_it/extconf.rb +0 -6
  100. data/ext/gherkin_lexer_it/gherkin_lexer_it.c +0 -1340
  101. data/ext/gherkin_lexer_ja/extconf.rb +0 -6
  102. data/ext/gherkin_lexer_ja/gherkin_lexer_ja.c +0 -1699
  103. data/ext/gherkin_lexer_kn/extconf.rb +0 -6
  104. data/ext/gherkin_lexer_kn/gherkin_lexer_kn.c +0 -1965
  105. data/ext/gherkin_lexer_ko/extconf.rb +0 -6
  106. data/ext/gherkin_lexer_ko/gherkin_lexer_ko.c +0 -1360
  107. data/ext/gherkin_lexer_lt/extconf.rb +0 -6
  108. data/ext/gherkin_lexer_lt/gherkin_lexer_lt.c +0 -1296
  109. data/ext/gherkin_lexer_lu/extconf.rb +0 -6
  110. data/ext/gherkin_lexer_lu/gherkin_lexer_lu.c +0 -1389
  111. data/ext/gherkin_lexer_lv/extconf.rb +0 -6
  112. data/ext/gherkin_lexer_lv/gherkin_lexer_lv.c +0 -1425
  113. data/ext/gherkin_lexer_nl/extconf.rb +0 -6
  114. data/ext/gherkin_lexer_nl/gherkin_lexer_nl.c +0 -1368
  115. data/ext/gherkin_lexer_no/extconf.rb +0 -6
  116. data/ext/gherkin_lexer_no/gherkin_lexer_no.c +0 -1311
  117. data/ext/gherkin_lexer_pa/extconf.rb +0 -6
  118. data/ext/gherkin_lexer_pa/gherkin_lexer_pa.c +0 -2160
  119. data/ext/gherkin_lexer_pl/extconf.rb +0 -6
  120. data/ext/gherkin_lexer_pl/gherkin_lexer_pl.c +0 -1738
  121. data/ext/gherkin_lexer_pt/extconf.rb +0 -6
  122. data/ext/gherkin_lexer_pt/gherkin_lexer_pt.c +0 -1711
  123. data/ext/gherkin_lexer_ro/extconf.rb +0 -6
  124. data/ext/gherkin_lexer_ro/gherkin_lexer_ro.c +0 -1427
  125. data/ext/gherkin_lexer_ru/extconf.rb +0 -6
  126. data/ext/gherkin_lexer_ru/gherkin_lexer_ru.c +0 -2071
  127. data/ext/gherkin_lexer_sk/extconf.rb +0 -6
  128. data/ext/gherkin_lexer_sk/gherkin_lexer_sk.c +0 -1739
  129. data/ext/gherkin_lexer_sr_cyrl/extconf.rb +0 -6
  130. data/ext/gherkin_lexer_sr_cyrl/gherkin_lexer_sr_cyrl.c +0 -2112
  131. data/ext/gherkin_lexer_sr_latn/extconf.rb +0 -6
  132. data/ext/gherkin_lexer_sr_latn/gherkin_lexer_sr_latn.c +0 -1567
  133. data/ext/gherkin_lexer_sv/extconf.rb +0 -6
  134. data/ext/gherkin_lexer_sv/gherkin_lexer_sv.c +0 -1324
  135. data/ext/gherkin_lexer_th/extconf.rb +0 -6
  136. data/ext/gherkin_lexer_th/gherkin_lexer_th.c +0 -2840
  137. data/ext/gherkin_lexer_tl/extconf.rb +0 -6
  138. data/ext/gherkin_lexer_tl/gherkin_lexer_tl.c +0 -2021
  139. data/ext/gherkin_lexer_tr/extconf.rb +0 -6
  140. data/ext/gherkin_lexer_tr/gherkin_lexer_tr.c +0 -1347
  141. data/ext/gherkin_lexer_tt/extconf.rb +0 -6
  142. data/ext/gherkin_lexer_tt/gherkin_lexer_tt.c +0 -1936
  143. data/ext/gherkin_lexer_uk/extconf.rb +0 -6
  144. data/ext/gherkin_lexer_uk/gherkin_lexer_uk.c +0 -1941
  145. data/ext/gherkin_lexer_uz/extconf.rb +0 -6
  146. data/ext/gherkin_lexer_uz/gherkin_lexer_uz.c +0 -1651
  147. data/ext/gherkin_lexer_vi/extconf.rb +0 -6
  148. data/ext/gherkin_lexer_vi/gherkin_lexer_vi.c +0 -1458
  149. data/ext/gherkin_lexer_zh_cn/extconf.rb +0 -6
  150. data/ext/gherkin_lexer_zh_cn/gherkin_lexer_zh_cn.c +0 -1314
  151. data/ext/gherkin_lexer_zh_tw/extconf.rb +0 -6
  152. data/ext/gherkin_lexer_zh_tw/gherkin_lexer_zh_tw.c +0 -1307
  153. data/features/.cucumber/stepdefs.json +0 -244
  154. data/features/escaped_pipes.feature +0 -8
  155. data/features/feature_parser.feature +0 -237
  156. data/features/json_formatter.feature +0 -498
  157. data/features/json_parser.feature +0 -331
  158. data/features/native_lexer.feature +0 -19
  159. data/features/parser_with_native_lexer.feature +0 -205
  160. data/features/pretty_formatter.feature +0 -17
  161. data/features/step_definitions/eyeball_steps.rb +0 -3
  162. data/features/step_definitions/gherkin_steps.rb +0 -29
  163. data/features/step_definitions/json_formatter_steps.rb +0 -30
  164. data/features/step_definitions/json_parser_steps.rb +0 -21
  165. data/features/step_definitions/pretty_formatter_steps.rb +0 -85
  166. data/features/steps_parser.feature +0 -46
  167. data/features/support/env.rb +0 -41
  168. data/install_mingw_os_x.sh +0 -5
  169. data/js/.npmignore +0 -1
  170. data/js/lib/gherkin/lexer/.npmignore +0 -0
  171. data/lib/gherkin.rb +0 -2
  172. data/lib/gherkin/README.md +0 -7
  173. data/lib/gherkin/c_lexer.rb +0 -17
  174. data/lib/gherkin/formatter/ansi_escapes.rb +0 -97
  175. data/lib/gherkin/formatter/argument.rb +0 -16
  176. data/lib/gherkin/formatter/escaping.rb +0 -15
  177. data/lib/gherkin/formatter/filter_formatter.rb +0 -150
  178. data/lib/gherkin/formatter/hashable.rb +0 -25
  179. data/lib/gherkin/formatter/json_formatter.rb +0 -133
  180. data/lib/gherkin/formatter/line_filter.rb +0 -26
  181. data/lib/gherkin/formatter/model.rb +0 -281
  182. data/lib/gherkin/formatter/pretty_formatter.rb +0 -245
  183. data/lib/gherkin/formatter/regexp_filter.rb +0 -21
  184. data/lib/gherkin/formatter/step_printer.rb +0 -21
  185. data/lib/gherkin/formatter/tag_count_formatter.rb +0 -47
  186. data/lib/gherkin/formatter/tag_filter.rb +0 -19
  187. data/lib/gherkin/i18n.json +0 -786
  188. data/lib/gherkin/i18n.rb +0 -176
  189. data/lib/gherkin/json_parser.rb +0 -177
  190. data/lib/gherkin/lexer/ar.rb +0 -1170
  191. data/lib/gherkin/lexer/bg.rb +0 -1382
  192. data/lib/gherkin/lexer/bm.rb +0 -1250
  193. data/lib/gherkin/lexer/ca.rb +0 -1310
  194. data/lib/gherkin/lexer/cs.rb +0 -1246
  195. data/lib/gherkin/lexer/cy_gb.rb +0 -1032
  196. data/lib/gherkin/lexer/da.rb +0 -1048
  197. data/lib/gherkin/lexer/de.rb +0 -1166
  198. data/lib/gherkin/lexer/el.rb +0 -1628
  199. data/lib/gherkin/lexer/en.rb +0 -1156
  200. data/lib/gherkin/lexer/en_au.rb +0 -1486
  201. data/lib/gherkin/lexer/en_lol.rb +0 -934
  202. data/lib/gherkin/lexer/en_old.rb +0 -1037
  203. data/lib/gherkin/lexer/en_pirate.rb +0 -1210
  204. data/lib/gherkin/lexer/en_scouse.rb +0 -1362
  205. data/lib/gherkin/lexer/en_tx.rb +0 -1016
  206. data/lib/gherkin/lexer/encoding.rb +0 -41
  207. data/lib/gherkin/lexer/eo.rb +0 -995
  208. data/lib/gherkin/lexer/es.rb +0 -1140
  209. data/lib/gherkin/lexer/et.rb +0 -990
  210. data/lib/gherkin/lexer/fa.rb +0 -1214
  211. data/lib/gherkin/lexer/fi.rb +0 -969
  212. data/lib/gherkin/lexer/fr.rb +0 -1228
  213. data/lib/gherkin/lexer/gl.rb +0 -1117
  214. data/lib/gherkin/lexer/he.rb +0 -1118
  215. data/lib/gherkin/lexer/hi.rb +0 -1559
  216. data/lib/gherkin/lexer/hr.rb +0 -1066
  217. data/lib/gherkin/lexer/hu.rb +0 -1118
  218. data/lib/gherkin/lexer/i18n_lexer.rb +0 -48
  219. data/lib/gherkin/lexer/id.rb +0 -963
  220. data/lib/gherkin/lexer/is.rb +0 -1120
  221. data/lib/gherkin/lexer/it.rb +0 -1086
  222. data/lib/gherkin/lexer/ja.rb +0 -1418
  223. data/lib/gherkin/lexer/kn.rb +0 -1672
  224. data/lib/gherkin/lexer/ko.rb +0 -1102
  225. data/lib/gherkin/lexer/lt.rb +0 -1045
  226. data/lib/gherkin/lexer/lu.rb +0 -1132
  227. data/lib/gherkin/lexer/lv.rb +0 -1166
  228. data/lib/gherkin/lexer/nl.rb +0 -1115
  229. data/lib/gherkin/lexer/no.rb +0 -1060
  230. data/lib/gherkin/lexer/pa.rb +0 -1852
  231. data/lib/gherkin/lexer/pl.rb +0 -1457
  232. data/lib/gherkin/lexer/pt.rb +0 -1430
  233. data/lib/gherkin/lexer/ro.rb +0 -1164
  234. data/lib/gherkin/lexer/ru.rb +0 -1766
  235. data/lib/gherkin/lexer/sk.rb +0 -1452
  236. data/lib/gherkin/lexer/sr_cyrl.rb +0 -1803
  237. data/lib/gherkin/lexer/sr_latn.rb +0 -1294
  238. data/lib/gherkin/lexer/sv.rb +0 -1070
  239. data/lib/gherkin/lexer/th.rb +0 -2492
  240. data/lib/gherkin/lexer/tl.rb +0 -1726
  241. data/lib/gherkin/lexer/tr.rb +0 -1092
  242. data/lib/gherkin/lexer/tt.rb +0 -1643
  243. data/lib/gherkin/lexer/uk.rb +0 -1646
  244. data/lib/gherkin/lexer/uz.rb +0 -1376
  245. data/lib/gherkin/lexer/vi.rb +0 -1198
  246. data/lib/gherkin/lexer/zh_cn.rb +0 -1058
  247. data/lib/gherkin/lexer/zh_tw.rb +0 -1052
  248. data/lib/gherkin/listener/event.rb +0 -45
  249. data/lib/gherkin/listener/formatter_listener.rb +0 -150
  250. data/lib/gherkin/native.rb +0 -7
  251. data/lib/gherkin/native/java.rb +0 -72
  252. data/lib/gherkin/native/null.rb +0 -5
  253. data/lib/gherkin/native/therubyracer.rb +0 -41
  254. data/lib/gherkin/parser/meta.txt +0 -5
  255. data/lib/gherkin/parser/parser.rb +0 -166
  256. data/lib/gherkin/parser/root.txt +0 -11
  257. data/lib/gherkin/parser/steps.txt +0 -4
  258. data/lib/gherkin/platform.rb +0 -13
  259. data/lib/gherkin/rubify.rb +0 -31
  260. data/lib/gherkin/tag_expression.rb +0 -63
  261. data/ragel/lexer.c.rl.erb +0 -454
  262. data/ragel/lexer.java.rl.erb +0 -219
  263. data/ragel/lexer.js.rl.erb +0 -322
  264. data/ragel/lexer.rb.rl.erb +0 -179
  265. data/ragel/lexer_common.rl.erb +0 -50
  266. data/spec/gherkin/c_lexer_spec.rb +0 -22
  267. data/spec/gherkin/fixtures/1.feature +0 -8
  268. data/spec/gherkin/fixtures/comments_in_table.feature +0 -9
  269. data/spec/gherkin/fixtures/complex.feature +0 -45
  270. data/spec/gherkin/fixtures/complex.json +0 -139
  271. data/spec/gherkin/fixtures/complex_for_filtering.feature +0 -60
  272. data/spec/gherkin/fixtures/complex_with_tags.feature +0 -61
  273. data/spec/gherkin/fixtures/dos_line_endings.feature +0 -45
  274. data/spec/gherkin/fixtures/examples_with_only_header.feature +0 -14
  275. data/spec/gherkin/fixtures/hantu_pisang.feature +0 -35
  276. data/spec/gherkin/fixtures/i18n_fr.feature +0 -14
  277. data/spec/gherkin/fixtures/i18n_fr2.feature +0 -8
  278. data/spec/gherkin/fixtures/i18n_no.feature +0 -7
  279. data/spec/gherkin/fixtures/i18n_pt1.feature +0 -44
  280. data/spec/gherkin/fixtures/i18n_pt2.feature +0 -4
  281. data/spec/gherkin/fixtures/i18n_pt3.feature +0 -4
  282. data/spec/gherkin/fixtures/i18n_pt4.feature +0 -4
  283. data/spec/gherkin/fixtures/i18n_zh-CN.feature +0 -9
  284. data/spec/gherkin/fixtures/iso-8859-1.feature +0 -6
  285. data/spec/gherkin/fixtures/issue_145.feature +0 -22
  286. data/spec/gherkin/fixtures/scenario_outline_with_tags.feature +0 -13
  287. data/spec/gherkin/fixtures/scenario_without_steps.feature +0 -5
  288. data/spec/gherkin/fixtures/simple_with_comments.feature +0 -7
  289. data/spec/gherkin/fixtures/simple_with_tags.feature +0 -11
  290. data/spec/gherkin/fixtures/with_bom.feature +0 -3
  291. data/spec/gherkin/fixtures/with_bom_and_language_spec.feature +0 -4
  292. data/spec/gherkin/formatter/ansi_escapes_spec.rb +0 -32
  293. data/spec/gherkin/formatter/filter_formatter_spec.rb +0 -204
  294. data/spec/gherkin/formatter/json_formatter_spec.rb +0 -179
  295. data/spec/gherkin/formatter/model_spec.rb +0 -28
  296. data/spec/gherkin/formatter/pretty_formatter_spec.rb +0 -184
  297. data/spec/gherkin/formatter/spaces.feature +0 -9
  298. data/spec/gherkin/formatter/step_printer_spec.rb +0 -55
  299. data/spec/gherkin/formatter/tabs.feature +0 -9
  300. data/spec/gherkin/formatter/tag_count_formatter_spec.rb +0 -30
  301. data/spec/gherkin/i18n_spec.rb +0 -256
  302. data/spec/gherkin/java_lexer_spec.rb +0 -20
  303. data/spec/gherkin/json_parser_spec.rb +0 -165
  304. data/spec/gherkin/lexer/i18n_lexer_spec.rb +0 -65
  305. data/spec/gherkin/native_lexer_spec.rb +0 -29
  306. data/spec/gherkin/parser/parser_spec.rb +0 -16
  307. data/spec/gherkin/rubify_spec.rb +0 -23
  308. data/spec/gherkin/sexp_recorder.rb +0 -59
  309. data/spec/gherkin/shared/doc_string_group.rb +0 -161
  310. data/spec/gherkin/shared/encoding_group.rb +0 -48
  311. data/spec/gherkin/shared/lexer_group.rb +0 -589
  312. data/spec/gherkin/shared/row_group.rb +0 -123
  313. data/spec/gherkin/shared/tags_group.rb +0 -52
  314. data/spec/gherkin/tag_expression_spec.rb +0 -146
  315. data/spec/spec_helper.rb +0 -94
  316. data/tasks/apidoc.rake +0 -32
  317. data/tasks/bench.rake +0 -184
  318. data/tasks/bench/feature_builder.rb +0 -49
  319. data/tasks/bench/null_listener.rb +0 -4
  320. data/tasks/compile.rake +0 -83
  321. data/tasks/cucumber.rake +0 -23
  322. data/tasks/gems.rake +0 -46
  323. data/tasks/ikvm.rake +0 -126
  324. data/tasks/ragel_task.rb +0 -124
  325. data/tasks/release.rake +0 -34
  326. data/tasks/rspec.rake +0 -6
  327. data/tasks/yard/default/layout/html/bubble_32x32.png +0 -0
  328. data/tasks/yard/default/layout/html/bubble_48x48.png +0 -0
  329. data/tasks/yard/default/layout/html/footer.erb +0 -5
  330. data/tasks/yard/default/layout/html/index.erb +0 -1
  331. data/tasks/yard/default/layout/html/layout.erb +0 -25
  332. data/tasks/yard/default/layout/html/logo.erb +0 -1
  333. data/tasks/yard/default/layout/html/setup.rb +0 -4
@@ -1,179 +0,0 @@
1
- require 'gherkin/native'
2
-
3
- module Gherkin
4
- module Lexer
5
- class <%= @i18n.underscored_iso_code.capitalize %> #:nodoc:
6
- native_impl('gherkin')
7
-
8
- %%{
9
- machine lexer;
10
-
11
- action begin_content {
12
- @content_start = p
13
- @current_line = @line_number
14
- @start_col = p - @last_newline - "#{@keyword}:".length
15
- }
16
-
17
- action start_docstring {
18
- @current_line = @line_number
19
- @start_col = p - @last_newline
20
- }
21
-
22
- action begin_docstring_content {
23
- @content_start = p
24
- }
25
-
26
- action start_docstring_content_type {
27
- @docstring_content_type_start = p
28
- }
29
- action end_docstring_content_type {
30
- @docstring_content_type_end = p
31
- }
32
-
33
- action store_docstring_content {
34
- con = unindent(@start_col, utf8_pack(data[@content_start...@next_keyword_start-1]).sub(/(\r?\n)?([\t ])*\Z/, '').gsub(/\\"\\"\\"/, '"""'))
35
- con_type = utf8_pack(data[@docstring_content_type_start...@docstring_content_type_end]).strip
36
- @listener.doc_string(con_type, con, @current_line)
37
- }
38
- action store_feature_content {
39
- p = store_keyword_content(:feature, data, p, eof)
40
- }
41
-
42
- action store_background_content {
43
- p = store_keyword_content(:background, data, p, eof)
44
- }
45
-
46
- action store_scenario_content {
47
- p = store_keyword_content(:scenario, data, p, eof)
48
- }
49
-
50
- action store_scenario_outline_content {
51
- p = store_keyword_content(:scenario_outline, data, p, eof)
52
- }
53
-
54
- action store_examples_content {
55
- p = store_keyword_content(:examples, data, p, eof)
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(/\\n/, "\n").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/cucumber/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
-
130
- # Initialize ivars to avoid warnings
131
- @keyword = nil
132
- %% write data;
133
- end
134
-
135
- def scan(data)
136
- data = (data + "\n%_FEATURE_END_%").unpack("c*") # Explicit EOF simplifies things considerably
137
- eof = pe = data.length
138
-
139
- @line_number = 1
140
- @last_newline = 0
141
-
142
- %% write init;
143
- %% write exec;
144
- end
145
-
146
- def unindent(startcol, text)
147
- text.gsub(/^[\t ]{0,#{startcol}}/, "")
148
- end
149
-
150
- def store_keyword_content(event, data, p, eof)
151
- end_point = (!@next_keyword_start or (p == eof)) ? p : @next_keyword_start
152
- content = unindent(@start_col + 2, utf8_pack(data[@content_start...end_point])).rstrip
153
- content_lines = content.split("\n")
154
- name = content_lines.shift || ""
155
- name.strip!
156
- description = content_lines.join("\n")
157
- @listener.__send__(event, @keyword, name, description, @current_line)
158
- @next_keyword_start ? @next_keyword_start - 1 : p
159
- ensure
160
- @next_keyword_start = nil
161
- end
162
-
163
- def current_line_content(data, p)
164
- rest = data[@last_newline..-1]
165
- utf8_pack(rest[0..rest.index(10)||-1]).strip # 10 is \n
166
- end
167
-
168
- if (RUBY_VERSION =~ /^1\.9|2\.0/)
169
- def utf8_pack(array)
170
- array.pack("c*").force_encoding("UTF-8")
171
- end
172
- else
173
- def utf8_pack(array)
174
- array.pack("c*")
175
- end
176
- end
177
- end
178
- end
179
- end
@@ -1,50 +0,0 @@
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
- StartDocString = '"""' >start_docstring ^EOL* >start_docstring_content_type %end_docstring_content_type :>> EOL;
44
- EndDocString = (space* '"""') >next_keyword_start;
45
- DocString = space* StartDocString %begin_docstring_content (^EOL | EOL)* :>> EndDocString %store_docstring_content space* EOL+;
46
-
47
- Tokens = BOM? (space | EOL)* (Tags | Comment | FeatureHeading | BackgroundHeading | ScenarioHeading | ScenarioOutlineHeading | ExamplesHeading | Step | Row | DocString )* (space | EOL)* EOF;
48
-
49
- main := Tokens %end_feature @!end_feature;
50
- }%%
@@ -1,22 +0,0 @@
1
- #encoding: utf-8
2
- unless defined?(JRUBY_VERSION)
3
- require 'spec_helper'
4
- require 'gherkin_lexer_en'
5
-
6
- module Gherkin
7
- module Lexer
8
- describe "C Lexer" do
9
- before do
10
- @listener = Gherkin::SexpRecorder.new
11
- @lexer = Gherkin::CLexer::En.new(@listener)
12
- end
13
-
14
- it_should_behave_like "a Gherkin lexer"
15
- it_should_behave_like "a Gherkin lexer lexing tags"
16
- it_should_behave_like "a Gherkin lexer lexing doc_strings"
17
- it_should_behave_like "a Gherkin lexer lexing rows"
18
- it_should_behave_like "encoding"
19
- end
20
- end
21
- end
22
- end
@@ -1,8 +0,0 @@
1
- Feature: Logging in
2
- So that I can be myself
3
- # Comment
4
- Scenario: Anonymous user can get a login form.
5
- Scenery here
6
-
7
- @tag
8
- Scenario: Another one
@@ -1,9 +0,0 @@
1
- Feature: x
2
-
3
- Scenario Outline: x
4
- Then x is <state>
5
-
6
- Examples:
7
- | state |
8
- # comment
9
- | 1 |
@@ -1,45 +0,0 @@
1
- #Comment on line 1
2
- #Comment on line 2
3
- @tag1 @tag2
4
- Feature: Feature Text
5
- In order to test multiline forms
6
- As a ragel writer
7
- I need to check for complex combinations
8
-
9
- #Comment on line 9
10
-
11
- #Comment on line 11
12
-
13
- Background:
14
- Given this is a background step
15
- And this is another one
16
-
17
- @tag3 @tag4
18
- Scenario: Reading a Scenario
19
- Given there is a step
20
- But not another step
21
-
22
- @tag3
23
- Scenario: Reading a second scenario
24
- With two lines of text
25
- #Comment on line 24
26
- Given a third step with a table
27
- |a|b|
28
- |c|d|
29
- |e|f|
30
- And I am still testing things
31
- |g|h|
32
- |e|r|
33
- |k|i|
34
- |n||
35
- And I am done testing these tables
36
- #Comment on line 29
37
- Then I am happy
38
-
39
- Scenario: Hammerzeit
40
- Given All work and no play
41
- """
42
- Makes Homer something something
43
- And something else
44
- """
45
- Then crazy
@@ -1,139 +0,0 @@
1
- {
2
- "id": "feature-text",
3
- "uri": "some/nice.feature",
4
- "name": "Feature Text",
5
- "keyword": "Feature",
6
- "description": "In order to test multiline forms",
7
- "tags": [
8
- {"name": "@tag1"},
9
- {"name": "@tag2"}
10
- ],
11
- "elements": [
12
- { "type": "background",
13
- "description": "",
14
- "name": "",
15
- "keyword": "Background",
16
- "steps": [
17
- { "name": "this is a background step",
18
- "keyword": "Given " },
19
- { "name": "this is another one",
20
- "keyword": "When ",
21
- "line": 412 }
22
- ]
23
- },
24
- { "type": "scenario_outline",
25
- "id": "feature-text/a-scenario-outline",
26
- "keyword": "Scenario Outline",
27
- "name": "An Scenario Outline",
28
- "description": "",
29
- "tags": [
30
- {"name": "@foo"}
31
- ],
32
- "steps": [
33
- { "name": "A step with a table",
34
- "keyword": "Given ",
35
- "rows" : [
36
- {"cells": [ "a","row","for","a","step" ]}
37
- ]
38
- }
39
- ],
40
- "examples": [
41
- {
42
- "id": "feature-text/a-scenario-outline/sweet-example",
43
- "name": "Sweet Example",
44
- "keyword": "Examples",
45
- "description": "",
46
- "rows" : [
47
- {"cells" :
48
- [ "Fill","In" ]
49
- },
50
- {"cells" :
51
- [ "The","Blanks" ]
52
- }
53
- ],
54
- "tags" : [ {"name": "@exampletag"} ]
55
- }
56
- ]
57
- },
58
- { "type" : "scenario",
59
- "id": "feature-text/reading-a-scenario",
60
- "keyword": "Scenario",
61
- "name" : "Reading a Scenario",
62
- "description": "",
63
- "tags" : [
64
- {"name": "@tag3"},
65
- {"name": "@tag4"}
66
- ],
67
- "steps" : [
68
- { "name" : "there is a step",
69
- "keyword": "Given "},
70
- { "name" : "not another step",
71
- "keyword": "But " }
72
- ]
73
- },
74
- { "type" : "scenario",
75
- "id": "feature-text/reading-a-second-scenario",
76
- "keyword": "Scenario",
77
- "name" : "Reading a second scenario",
78
- "description": "With two lines of text",
79
- "tags" : [ {"name": "@tag3"} ],
80
- "steps" : [
81
- { "name" : "a third step with a table",
82
- "keyword": "Given ",
83
- "rows": [
84
- {
85
- "cells" : [ "a","b" ],
86
- "line" : 987
87
- },
88
- { "cells" :
89
- [ "c","d" ]
90
- },
91
- { "cells" :
92
- [ "e", "f" ]
93
- }
94
- ]
95
- },
96
- { "name" : "I am still testing things",
97
- "keyword": "Given ",
98
- "rows": [
99
- { "cells" :
100
- [ "g","h" ]
101
- },
102
- { "cells" :
103
- [ "e","r" ]
104
- },
105
- { "cells" :
106
- [ "k", "i" ]
107
- },
108
- { "cells" :
109
- [ "n", "" ]
110
- }
111
- ]
112
- },
113
- { "name" : "I am done testing these tables",
114
- "keyword": "Given " },
115
- { "name" : "I am happy",
116
- "keyword": "Given " }
117
- ]
118
- },
119
- { "type" : "scenario",
120
- "id": "feature-text/hammerzeit",
121
- "keyword": "Scenario",
122
- "name" : "Hammerzeit",
123
- "description": "",
124
- "steps" : [
125
- { "name" : "All work and no play",
126
- "keyword": "Given ",
127
- "doc_string": {
128
- "content_type": "text",
129
- "value": "Makes Homer something something\nAnd something else",
130
- "line": 777
131
- }
132
- },
133
- { "name" : "crazy",
134
- "keyword": "Given " }
135
- ]
136
- }
137
- ]
138
- }
139
-