Skip to main content

Module matcher

Module matcher 

Source
Expand description

The {name} step matcher: cucumber-expression-style patterns binding Gherkin prose to macros (TECH-SPEC §4.3).

A pattern is literal text with {name} captures (I search for {term}). Matching is anchored and leftmost: literals must appear in order (the whole text must be consumed), and each capture extends to the leftmost occurrence of the next literal. Captured values are trimmed; a value wrapped in symmetric double or single quotes sheds them (quotes preserve inner spaces and commas exactly).

Guard rails (pattern_problems, run at pack load — validation pass 1): a pattern must contain literal text to anchor on, adjacent captures are rejected (the single-pass matcher cannot split them), braces must be balanced, and every capture must name a declared param.

Enums§

PatternProblem
One problem found in a match: pattern (validation pass 1), typed so each maps to a stable diagnostic code.
Token
One token of a match: pattern.

Functions§

closest
The candidate closest to input by edit distance, within the shared “did you mean” threshold. None when nothing is close.
levenshtein
Levenshtein edit distance over chars (small inputs; O(a·b) rolling row).
literal_skeleton
The literal skeleton of a pattern (captures dropped) — the comparison basis for closest-pattern suggestions on unbound steps.
match_pattern
Match text against pattern, returning the captured args, or None when the pattern does not apply. Total: never panics, any inputs.
pattern_problems
The problems found in a match: pattern (validation pass 1); empty = sound.
tokenize
Split a pattern into Tokens. An unclosed { degrades the remainder into a literal — pattern_problems rejects it at load; the matcher stays total.