Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.

Commit 5cdb307

Browse files
committed
Implement Rule for C#,Java,JavaScript,Ruby and partially Go
1 parent 239c4cf commit 5cdb307

9 files changed

+272
-46
lines changed

gherkin-languages.json

Lines changed: 222 additions & 0 deletions
Large diffs are not rendered by default.

gherkin.berp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
[
2-
Tokens -> #Empty,#Comment,#TagLine,#FeatureLine,#BackgroundLine,#ScenarioLine,#ExamplesLine,#StepLine,#DocStringSeparator,#TableRow,#Language
2+
Tokens -> #Empty,#Comment,#TagLine,#FeatureLine,#RuleLine,#BackgroundLine,#ScenarioLine,#ExamplesLine,#StepLine,#DocStringSeparator,#TableRow,#Language
33
IgnoredTokens -> #Comment,#Empty
44
ClassName -> Parser
55
Namespace -> Gherkin
66
]
77

88
GherkinDocument! := Feature?
9-
Feature! := FeatureHeader Background? ScenarioDefinition*
9+
Feature! := FeatureHeader Background? ScenarioDefinition* Rule*
1010
FeatureHeader! := #Language? Tags? #FeatureLine DescriptionHelper
1111

12+
Rule! := RuleHeader Background? ScenarioDefinition*
13+
RuleHeader! := #RuleLine DescriptionHelper
14+
1215
Background! := #BackgroundLine DescriptionHelper Step*
1316

1417
// we could avoid defining ScenarioDefinition, but that would require regular look-aheads, so worse performance
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
{"data":"(2:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'invalid line here'","media":{"encoding":"utf-8","type":"text/x.cucumber.stacktrace+plain"},"source":{"start":{"column":1,"line":2},"uri":"testdata/bad/multiple_parser_errors.feature"},"type":"attachment"}
2-
{"data":"(9:1): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #Comment, #Empty, got 'another invalid line here'","media":{"encoding":"utf-8","type":"text/x.cucumber.stacktrace+plain"},"source":{"start":{"column":1,"line":9},"uri":"testdata/bad/multiple_parser_errors.feature"},"type":"attachment"}
2+
{"data":"(9:1): expected: #EOF, #TableRow, #DocStringSeparator, #StepLine, #TagLine, #ExamplesLine, #ScenarioLine, #RuleLine, #Comment, #Empty, got 'another invalid line here'","media":{"encoding":"utf-8","type":"text/x.cucumber.stacktrace+plain"},"source":{"start":{"column":1,"line":9},"uri":"testdata/bad/multiple_parser_errors.feature"},"type":"attachment"}
Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1 @@
1-
{
2-
"document": {
3-
"comments": [],
4-
"feature": {
5-
"children": [
6-
{
7-
"examples": [],
8-
"keyword": "Example",
9-
"location": {
10-
"column": 3,
11-
"line": 3
12-
},
13-
"name": "minimalistic",
14-
"steps": [
15-
{
16-
"keyword": "Given ",
17-
"location": {
18-
"column": 5,
19-
"line": 4
20-
},
21-
"text": "the minimalism",
22-
"type": "Step"
23-
}
24-
],
25-
"tags": [],
26-
"type": "Scenario"
27-
}
28-
],
29-
"keyword": "Feature",
30-
"language": "en",
31-
"location": {
32-
"column": 1,
33-
"line": 1
34-
},
35-
"name": "Minimal",
36-
"tags": [],
37-
"type": "Feature"
38-
},
39-
"type": "GherkinDocument"
40-
},
41-
"type": "gherkin-document",
42-
"uri": "testdata/good/minimal-example.feature"
43-
}
1+
{"document":{"comments":[],"feature":{"children":[{"examples":[],"keyword":"Example","location":{"column":3,"line":3},"name":"minimalistic","steps":[{"keyword":"Given ","location":{"column":5,"line":4},"text":"the minimalism","type":"Step"}],"tags":[],"type":"Scenario"}],"keyword":"Feature","language":"en","location":{"column":1,"line":1},"name":"Minimal","tags":[],"type":"Feature"},"type":"GherkinDocument"},"type":"gherkin-document","uri":"testdata/good/minimal-example.feature"}

testdata/good/rule.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Feature: Some rules
2+
3+
Background:
4+
Given fb
5+
6+
Rule: A
7+
The rule A description
8+
9+
Background:
10+
Given ab
11+
12+
Example: Example A
13+
Given a
14+
15+
Rule: B
16+
The rule B description
17+
18+
Example: Example B
19+
Given b
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"document":{"comments":[],"feature":{"children":[{"keyword":"Background","location":{"column":3,"line":3},"name":"","steps":[{"keyword":"Given ","location":{"column":5,"line":4},"text":"fb","type":"Step"}],"type":"Background"},{"children":[{"keyword":"Background","location":{"column":5,"line":9},"name":"","steps":[{"keyword":"Given ","location":{"column":7,"line":10},"text":"ab","type":"Step"}],"type":"Background"},{"examples":[],"keyword":"Example","location":{"column":5,"line":12},"name":"Example A","steps":[{"keyword":"Given ","location":{"column":7,"line":13},"text":"a","type":"Step"}],"tags":[],"type":"Scenario"}],"description":" The rule A description","keyword":"Rule","location":{"column":3,"line":6},"name":"A","type":"Rule"},{"children":[{"examples":[],"keyword":"Example","location":{"column":5,"line":18},"name":"Example B","steps":[{"keyword":"Given ","location":{"column":7,"line":19},"text":"b","type":"Step"}],"tags":[],"type":"Scenario"}],"description":" The rule B description","keyword":"Rule","location":{"column":3,"line":15},"name":"B","type":"Rule"}],"keyword":"Feature","language":"en","location":{"column":1,"line":1},"name":"Some rules","tags":[],"type":"Feature"},"type":"GherkinDocument"},"type":"gherkin-document","uri":"testdata/good/rule.feature"}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{"pickle":{"language":"en","locations":[{"column":5,"line":12}],"name":"Example A","steps":[{"arguments":[],"locations":[{"column":11,"line":4}],"text":"fb"},{"arguments":[],"locations":[{"column":13,"line":10}],"text":"ab"},{"arguments":[],"locations":[{"column":13,"line":13}],"text":"a"}],"tags":[]},"type":"pickle","uri":"testdata/good/rule.feature"}
2+
{"pickle":{"language":"en","locations":[{"column":5,"line":18}],"name":"Example B","steps":[{"arguments":[],"locations":[{"column":11,"line":4}],"text":"fb"},{"arguments":[],"locations":[{"column":13,"line":19}],"text":"b"}],"tags":[]},"type":"pickle","uri":"testdata/good/rule.feature"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"data":"Feature: Some rules\n\n Background:\n Given fb\n\n Rule: A\n The rule A description\n\n Background:\n Given ab\n\n Example: Example A\n Given a\n\n Rule: B\n The rule B description\n\n Example: Example B\n Given b","media":{"encoding":"utf-8","type":"text/x.cucumber.gherkin+plain"},"type":"source","uri":"testdata/good/rule.feature"}

testdata/good/rule.feature.tokens

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(1:1)FeatureLine:Feature/Some rules/
2+
(2:1)Empty://
3+
(3:3)BackgroundLine:Background//
4+
(4:5)StepLine:Given /fb/
5+
(5:1)Empty://
6+
(6:3)RuleLine:Rule/A/
7+
(7:1)Other:/ The rule A description/
8+
(8:1)Other://
9+
(9:5)BackgroundLine:Background//
10+
(10:7)StepLine:Given /ab/
11+
(11:1)Empty://
12+
(12:5)ScenarioLine:Example/Example A/
13+
(13:7)StepLine:Given /a/
14+
(14:1)Empty://
15+
(15:3)RuleLine:Rule/B/
16+
(16:1)Other:/ The rule B description/
17+
(17:1)Other://
18+
(18:5)ScenarioLine:Example/Example B/
19+
(19:7)StepLine:Given /b/
20+
EOF

0 commit comments

Comments
 (0)