# `Gherkin.Parser`
[🔗](https://github.com/huddlz-hq/cucumber/blob/main/lib/gherkin.ex#L216)

Gherkin parser using NimbleParsec.

This module parses Gherkin feature files into Elixir structs, supporting:
- Feature with name, description, and tags
- Background with steps
- Scenarios with steps and tags
- Scenario Outlines with Examples
- Steps with keywords, text, docstrings, and datatables

It implements a subset of the Gherkin language focused on core BDD concepts.

# `parse`

```elixir
@spec parse(String.t()) :: Gherkin.Feature.t()
```

Parses a Gherkin feature file from a string into structured data.

This function takes a string containing Gherkin syntax and parses it into a
structured `Gherkin.Feature` struct with its associated components.

## Parameters

* `gherkin_string` - A string containing Gherkin syntax

## Returns

Returns a `%Gherkin.Feature{}` struct containing:
* `name` - The feature name
* `description` - The feature description
* `tags` - List of feature-level tags
* `background` - Background steps (if present)
* `scenarios` - List of scenarios

## Examples

    # Parse a string containing Gherkin syntax
    Gherkin.Parser.parse("Feature: Shopping Cart\nScenario: Adding an item")
    # Returns %Gherkin.Feature{} struct with parsed data

# `parse`

```elixir
@spec parse(String.t(), String.t()) :: Gherkin.Feature.t()
```

Parses feature file content, choosing the parser by the file's path.

`.feature.md` files parse as Markdown with Gherkin (see
`Gherkin.Markdown`); everything else parses as plain Gherkin, exactly
like `parse/1`. A `Gherkin.ParseError` raised from either parser carries
`path` in its `file` field, and its message leads with `path:line:column`.

## Examples

    Gherkin.Parser.parse("# Feature: Cheese", "cheese.feature.md")
    # Returns %Gherkin.Feature{} struct with parsed data

---

*Consult [api-reference.md](api-reference.md) for complete listing*
