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

Commit 3b9cf17

Browse files
committed
Merge with master
2 parents b5b8de5 + 8ed4535 commit 3b9cf17

File tree

56 files changed

+152
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+152
-97
lines changed

.gitrepo

Lines changed: 0 additions & 11 deletions
This file was deleted.

.subrepo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cucumber/gherkin-c.git

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ libs_so: ./include/rule_type.h src/parser.c src/dialect.c $(SRC_FILES) src/Makef
6767
# have mono, so we'll allow this line to fail.
6868
-mono berp/berp.exe -g gherkin.berp -t gherkin-c-rule-type.razor -o $@
6969
# Remove BOM
70-
sed '1s/^\xEF\xBB\xBF//' < $@ > $@.nobom
70+
awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' < $@ > $@.nobom
7171
mv $@.nobom $@
7272

7373
src/parser.c: gherkin.berp gherkin-c-parser.razor
@@ -77,7 +77,7 @@ src/parser.c: gherkin.berp gherkin-c-parser.razor
7777
# have mono, so we'll allow this line to fail.
7878
-mono berp/berp.exe -g gherkin.berp -t gherkin-c-parser.razor -o $@
7979
# Remove BOM
80-
sed '1s/^\xEF\xBB\xBF//' < $@ > $@.nobom
80+
awk 'NR==1{sub(/^\xef\xbb\xbf/,"")}{print}' < $@ > $@.nobom
8181
mv $@.nobom $@
8282

8383
src/dialect.c: gherkin-languages.json dialect.c.jq

gherkin-languages.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,7 @@
574574
"Und "
575575
],
576576
"background": [
577-
"Grundlage",
578-
"Hintergrund"
577+
"Grundlage"
579578
],
580579
"but": [
581580
"* ",
@@ -600,10 +599,8 @@
600599
"Szenario"
601600
],
602601
"scenarioOutline": [
603-
"Beispielvorlage",
604-
"Szenariovorlage",
605-
"Beispielgrundlage",
606-
"Szenariogrundlage"
602+
"Beispielrundriss",
603+
"Szenariogrundriss"
607604
],
608605
"then": [
609606
"* ",
@@ -2516,8 +2513,7 @@
25162513
"* ",
25172514
"Допустим ",
25182515
"Дано ",
2519-
"Пусть ",
2520-
"Если "
2516+
"Пусть "
25212517
],
25222518
"name": "Russian",
25232519
"native": "русский",
@@ -2536,7 +2532,8 @@
25362532
],
25372533
"when": [
25382534
"* ",
2539-
"Когда "
2535+
"Когда ",
2536+
"Если "
25402537
]
25412538
},
25422539
"sk": {

gherkin.berp

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

88
GherkinDocument! := Feature?
9-
Feature! := Feature_Header Background? Scenario_Definition*
10-
Feature_Header! := #Language? Tags? #FeatureLine Description_Helper
9+
Feature! := FeatureHeader Background? ScenarioDefinition*
10+
FeatureHeader! := #Language? Tags? #FeatureLine DescriptionHelper
1111

12-
Background! := #BackgroundLine Description_Helper Step*
12+
Background! := #BackgroundLine DescriptionHelper Step*
1313

14-
// we could avoid defining Scenario_Definition, but that would require regular look-aheads, so worse performance
15-
Scenario_Definition! := Tags? (Scenario | ScenarioOutline)
14+
// we could avoid defining ScenarioDefinition, but that would require regular look-aheads, so worse performance
15+
ScenarioDefinition! := Tags? Scenario
1616

17-
Scenario! := #ScenarioLine Description_Helper Step*
18-
19-
ScenarioOutline! := #ScenarioOutlineLine Description_Helper Step* Examples_Definition*
20-
// after the first "Examples" block, interpreting a tag line is ambiguous (tagline of next examples or of next scenario)
17+
Scenario! := #ScenarioLine DescriptionHelper Step* ExamplesDefinition*
18+
// after the first "Data" block, interpreting a tag line is ambiguous (tagline of next examples or of next scenario)
2119
// because of this, we need a lookahead hint, that connects the tag line to the next examples, if there is an examples block ahead
22-
Examples_Definition! [#Empty|#Comment|#TagLine->#ExamplesLine]:= Tags? Examples
23-
Examples! := #ExamplesLine Description_Helper Examples_Table?
24-
Examples_Table! := #TableRow #TableRow*
20+
ExamplesDefinition! [#Empty|#Comment|#TagLine->#ExamplesLine]:= Tags? Examples
21+
Examples! := #ExamplesLine DescriptionHelper ExamplesTable?
22+
ExamplesTable! := #TableRow #TableRow*
2523

26-
Step! := #StepLine Step_Arg?
27-
Step_Arg := (DataTable | DocString)
24+
Step! := #StepLine StepArg?
25+
StepArg := (DataTable | DocString)
2826

2927
DataTable! := #TableRow+
3028
DocString! := #DocStringSeparator #Other* #DocStringSeparator
@@ -33,5 +31,5 @@ Tags! := #TagLine+
3331

3432
// we need to explicitly mention comment, to avoid merging it into the description line's #Other token
3533
// we also eat the leading empty lines, the tailing lines are not removed by the parser to avoid lookahead, this has to be done by the AST builder
36-
Description_Helper := #Empty* Description? #Comment*
34+
DescriptionHelper := #Empty* Description? #Comment*
3735
Description! := #Other+

src/dialect.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,8 +2423,8 @@ static const Keywords ru_examples_keywords = { 1, ru_examples_KEYWORDS };
24232423
static const wchar_t* const ru_feature_KEYWORDS[] = { L"Функция", L"Функциональность", L"Функционал", L"Свойство" };
24242424
static const Keywords ru_feature_keywords = { 4, ru_feature_KEYWORDS };
24252425

2426-
static const wchar_t* const ru_given_KEYWORDS[] = { L"* ", L"Допустим ", L"Дано ", L"Пусть ", L"Если " };
2427-
static const Keywords ru_given_keywords = { 5, ru_given_KEYWORDS };
2426+
static const wchar_t* const ru_given_KEYWORDS[] = { L"* ", L"Допустим ", L"Дано ", L"Пусть " };
2427+
static const Keywords ru_given_keywords = { 4, ru_given_KEYWORDS };
24282428

24292429
static const wchar_t* const ru_scenario_KEYWORDS[] = { L"Пример", L"Сценарий" };
24302430
static const Keywords ru_scenario_keywords = { 2, ru_scenario_KEYWORDS };
@@ -2435,8 +2435,8 @@ static const Keywords ru_scenarioOutline_keywords = { 1, ru_scenarioOutline_KEYW
24352435
static const wchar_t* const ru_then_KEYWORDS[] = { L"* ", L"То ", L"Затем ", L"Тогда " };
24362436
static const Keywords ru_then_keywords = { 4, ru_then_KEYWORDS };
24372437

2438-
static const wchar_t* const ru_when_KEYWORDS[] = { L"* ", L"Когда " };
2439-
static const Keywords ru_when_keywords = { 2, ru_when_KEYWORDS };
2438+
static const wchar_t* const ru_when_KEYWORDS[] = { L"* ", L"Когда ", L"Если " };
2439+
static const Keywords ru_when_keywords = { 3, ru_when_KEYWORDS };
24402440

24412441
static const Dialect ru_dialect = {
24422442
L"ru",

src/file_reader.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,14 @@ const wchar_t* FileReader_read(FileReader* file_reader) {
2121
int pos = 0;
2222
long code_point;
2323
FILE* file = fopen(file_reader->file_name, "rb");
24+
25+
if(file == NULL) {
26+
swprintf(buffer, sizeof(wchar_t), L"%c", ' ');
27+
return buffer;
28+
}
29+
2430
Utf8Source* utf8_source = FileUtf8Source_new(file);
31+
2532
do {
2633
code_point = UnicodeUtilities_read_code_point_from_utf8_source(utf8_source);
2734
if (code_point != WEOF) {
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, #ScenarioLine, #ScenarioOutlineLine, #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, #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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"data":"(7:0): unexpected end of file, expected: #TagLine, #ScenarioLine, #ScenarioOutlineLine, #Comment, #Empty","media":{"encoding":"utf-8","type":"text/x.cucumber.stacktrace+plain"},"source":{"start":{"column":0,"line":7},"uri":"testdata/bad/unexpected_eof.feature"},"type":"attachment"}
1+
{"data":"(7:0): unexpected end of file, expected: #TagLine, #ScenarioLine, #Comment, #Empty","media":{"encoding":"utf-8","type":"text/x.cucumber.stacktrace+plain"},"source":{"start":{"column":0,"line":7},"uri":"testdata/bad/unexpected_eof.feature"},"type":"attachment"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"document":{"comments":[],"feature":{"children":[{"keyword":"Background","location":{"column":3,"line":3},"name":"a simple background","steps":[{"keyword":"Given ","location":{"column":5,"line":4},"text":"the minimalism inside a background","type":"Step"}],"type":"Background"},{"keyword":"Scenario","location":{"column":3,"line":7},"name":"minimalistic","steps":[{"keyword":"Given ","location":{"column":5,"line":8},"text":"the minimalism","type":"Step"}],"tags":[],"type":"Scenario"}],"keyword":"Feature","language":"en","location":{"column":1,"line":1},"name":"Background","tags":[],"type":"Feature"},"type":"GherkinDocument"},"type":"gherkin-document","uri":"testdata/good/background.feature"}
1+
{"document":{"comments":[],"feature":{"children":[{"keyword":"Background","location":{"column":3,"line":3},"name":"a simple background","steps":[{"keyword":"Given ","location":{"column":5,"line":4},"text":"the minimalism inside a background","type":"Step"}],"type":"Background"},{"examples":[],"keyword":"Scenario","location":{"column":3,"line":7},"name":"minimalistic","steps":[{"keyword":"Given ","location":{"column":5,"line":8},"text":"the minimalism","type":"Step"}],"tags":[],"type":"Scenario"}],"keyword":"Feature","language":"en","location":{"column":1,"line":1},"name":"Background","tags":[],"type":"Feature"},"type":"GherkinDocument"},"type":"gherkin-document","uri":"testdata/good/background.feature"}

0 commit comments

Comments
 (0)