A look at cucumber/gherkin: 392 stars on GitHub, written primarily in C, tracked under the Backend category. A parser and compiler for the Gherkin language.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Gherkin is a parser and compiler for the Gherkin language.
.NET -
Java -
JavaScript -
Ruby -
Go -
Python -
C -
Perl -
PHP -
Dart -
C++ -
The CI will run using the linked workflow when that specific language implementation is changed
The CI will also run for any/all linked workflows when any test data is modified
(For example modifying one of the good or bad features / ndjson outputs)
Contributing Translations (i18n)
In order to allow Gherkin to be written in a number of languages, the keywords
have been translated into multiple languages. To improve readability and flow,
some languages may have more than one translation for any given keyword.
If you are looking to add, update or improve these translations please see
CONTRIBUTING.md.
Contributing a Parser Implementation
See CONTRIBUTING.md if you want to contribute a parser
for a new programming language. Our wish-list is (in no particular order):
Rust
Usage
Gherkin can be used either through its command line interface (CLI) or as a
library.
It is designed to be used in conjunction with other tools such as Cucumber
which consumes the output from the CLI or library as Cucumber Messages.
Library
Using the library is the preferred way to use Gherkin since it produces easily
consumable AST and Pickle objects in-process without having to fork a CLI process
or parse JSON.
The library itself provides a stream API, which is what the CLI is based on.
This is the recommended way to use the library as it provides a high level API
that is easy to use. See the CLI implementations to get an idea of how to use it.
Alternatively, you can use the lower level parser and compiler. Some usage examples are below:
use Gherkin::Parser;
use Gherkin::Pickles::Compiler;
my $parser = Gherkin::Parser->new();
my $gherkin_document = $parser->parse("Feature: ...");
my $pickles = Gherkin::Pickles::Compiler->compile($gherkin_document);
PHP
use Cucumber\Gherkin\GherkinParser;
$path = '/path/to/my.feature';
$parser = new GherkinParser();
$pickles = $parser->parseString(uri: $path, data: file_get_contents($path));
CLI
The Gherkin CLI gherkin reads Gherkin source files (.feature files) and outputs
ASTs and Pickles.
The gherkin program takes any number of files as arguments and prints the results
to STDOUT as Newline Delimited JSON.
Each line is a JSON document that conforms to the Cucumber Event Protocol.
To try it out, just install Gherkin for your favourite language, and run it over the
files in this repository:
gherkin testdata/**/*.feature
Ndjson is easy to read for programs, but hard for people. To pretty print each JSON
document you can pipe it to the jq program:
gherkin testdata/**/*.feature | jq
Table cell escaping
If you want to use a newline character in a table cell, you can write this
as \n. If you need a | as part of the cell, you can escape it as \|. And
finally, if you need a \, you can escape that with \\.
Architecture
The following diagram outlines the architecture:
graph LR
A[Feature file] -->|Scanner| B[Tokens]
B -->|Parser| D[AST]
The scanner reads a gherkin doc (typically read from a .feature file) and creates
a token for each line. The tokens are passed to the parser, which outputs an AST
(Abstract Syntax Tree).
If the scanner sees a #language header, it will reconfigure itself dynamically
to look for Gherkin keywords for the associated language. The keywords are defined in
gherkin-languages.json.
The scanner is hand-written, but the parser is generated by the Berp
parser generator as part of the build process.
Berp takes a grammar file (gherkin.berp) and a template file (gherkin-X.razor) as input
and outputs a parser in language X:
graph TD
A[gherkin.berp] --> B[berp.exe]
C[gherkin-X.razor] --> B
B --> D[Parser.x]
Abstract Syntax Tree (AST)
The AST produced by the parser can be described with the following class diagram:
classDiagram
ScenarioOutline --|> ScenarioDefinition
GherkinDocument "1" *-- "0..1" Comment: comment
GherkinDocument "1" *-- "0..1" Feature: feature
Feature "1" *-- "0..*" ScenarioDefinition: scenarioDefinitions
Feature "1" *-- "0..*" Rule: rules
Rule "1" *-- "0..*" ScenarioDefinition: scenarioDefinitions
Background "0..1" --* "1" Rule: background
Feature "1" *-- "0..1" Background: background
Scenario --|> ScenarioDefinition
Tag "0..*" --* "1" Feature: tags
Tag "0..*" --* "1" Rule: tags
Tag "0..*" --* "1" Scenario: tags
Tag "0..*" --* "1" ScenarioOutline: tags
Tag "0..*" --* "1" Examples: tags
Examples "0..*" --* "1" ScenarioOutline: examples
TableRow "1" --* "1" Examples: header
TableRow "0..*" --* "1" Examples: rows
Background "1" *-- "0..*" Step: steps
Step "0..*" --* "1" ScenarioDefinition: steps
DataTable "0..1" --* "1" Step: dataTable
DocString "0..1" --* "1" Step: docString
TableRow "0..*" --* "1" DataTable: rows
TableRow "1" *-- "0..*" TableCell: cells
class ScenarioDefinition {
keyword
name
description
}
class Step {
keyword
text
}
class Examples {
keyword
name
description
}
class Feature {
language
keyword
name
description
}
class Background {
keyword
name
description
}
class Rule {
keyword
name
description
}
class DocString {
content
contentType
}
class Comment {
text
}
class TableCell {
value
}
class Tag {
name
}
class Location {
line: int
column: int
}
Every class represents a node in the AST. Every node has a Location that describes
the line number and column number in the input file. These numbers are 1-indexed.
All fields on nodes are strings (except for Location.line and Location.column).
A step may have at most one DataTable and at most one DocString.
The implementation is simple objects without behaviour, only data. It's up to
the implementation to decide whether to use classes or just basic collections,
but the AST must have a JSON representation (this is used for testing).
Each node in the JSON representation also has a type property with the name
of the node type.
You can see some examples in the
testdata/good
directory.
Pickles
The AST isn't suitable for execution by Cucumber. It needs further processing
into a simpler form called Pickles.
The compiler compiles the AST produced by the parser into pickles:
graph LR
A[AST] -->|Compiler| B[Pickles]
The rationale is to decouple Gherkin from Cucumber so that Cucumber is open to
support alternative formats to Gherkin (for example Markdown).
The simpler Pickles data structure also simplifies the internals of Cucumber.
With the compilation logic maintained in the Gherkin library
we can easily use the same test suite for all implementations to verify that
compilation is behaving consistently between implementations.
Each Scenario will be compiled into a Pickle. A Pickle has a list of
PickleStep, derived from the steps in a Scenario.
Each Examples row under Scenario Outline will also be compiled into a Pickle.
Any Background steps will also be compiled into a Pickle.
Every tag, like @a, will be compiled into a Pickle as well (inheriting tags from parent elements
in the Gherkin AST).
Example:
@a
Feature:
@b @c
Scenario Outline:
Given <x>
Examples:
| x |
| y |
@d @e
Scenario Outline:
Given <m>
@f
Examples:
| m |
| n |
Using the CLI we can compile this into several pickle objects:
Each Pickle event also contains the path to the original source. This is useful for
generating reports and stack traces when a Scenario fails.
Cucumber will further transform this list of Pickle objects to a list of TestCase
objects. TestCase objects link to user code such as Hooks and Step Definitions.
The most recent commit recorded on cucumber/gherkin was 5 days ago, based on the GitHub push timestamp. The repository has 98 forks — one of the better signals of community interest.
How many stars does cucumber/gherkin have?
cucumber/gherkin has 392 GitHub stars — refresh the page for the live number, or check github.com/cucumber/gherkin. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is cucumber/gherkin open source?
Yes — cucumber/gherkin ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/cucumber/gherkin.
What else is in the Backend space?
cucumber/gherkin is tracked by TopGit under the Backend category, alongside 17 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is cucumber/gherkin?
cucumber/gherkin (cucumber/gherkin) is a C project on GitHub. From the project's own README: A parser and compiler for the Gherkin language.
What language is cucumber/gherkin written in?
cucumber/gherkin is written primarily in C. GitHub's language field is based on the largest share of bytes in the default branch.
What license does cucumber/gherkin use?
cucumber/gherkin is released under the MIT license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where do I read more about cucumber/gherkin?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/cucumber/gherkin is the definitive source.
Read full README in the tab above.
Want a second opinion on gherkin?
Ask an AI that can read this page — one click and you get its take on gherkin.