22===============================
33
44[ ![ Documentation] ( https://docs.rs/cucumber-expressions/badge.svg )] ( https://docs.rs/cucumber-expressions )
5- [ ![ CI] ( https://github.com/cucumber-rs/cucumber-expressions/workflows/CI/badge.svg?branch=master " CI ")] ( https://github.com/cucumber-rs/cucumber-expressions/actions?query=workflow%3ACI+branch%3Amaster )
5+ [ ![ CI] ( https://github.com/cucumber-rs/cucumber-expressions/workflows/CI/badge.svg?branch=main " CI ")] ( https://github.com/cucumber-rs/cucumber-expressions/actions?query=workflow%3ACI+branch%3Amaster )
66[ ![ Rust 1.56+] ( https://img.shields.io/badge/rustc-1.56+-lightgray.svg " Rust 1.56+ ")] ( https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html )
77[ ![ Unsafe Forbidden] ( https://img.shields.io/badge/unsafe-forbidden-success.svg )] ( https://github.com/rust-secure-code/safety-dance )
88
99- [ Changelog] ( https://github.com/cucumber-rs/cucumber-expressions/blob/main/CHANGELOG.md )
1010
1111Rust implementation of [ Cucumber Expressions] .
1212
13- This crate provides [ AST] and parser of [ Cucumber Expressions] .
13+ This crate provides [ AST] parser, and [ ` Regex ` ] expansion of [ Cucumber Expressions] .
14+
15+ ``` rust
16+ use cucumber_expressions :: Expression ;
17+
18+ let re = Expression :: regex (" I have {int} cucumbers in my belly" ). unwrap ();
19+ let caps = re . captures (" I have 42 cucumbers in my belly" ). unwrap ();
20+
21+ assert_eq! (& caps [0 ], " I have 42 cucumbers in my belly" );
22+ assert_eq! (& caps [1 ], " 42" );
23+ ```
24+
25+
26+
27+
28+ ## Cargo features
29+
30+ - ` into-regex ` : Enables expansion into [ ` Regex ` ] .
1431
1532
1633
@@ -27,7 +44,7 @@ single-expression = alternation
2744 | optional
2845 | parameter
2946 | text-without-whitespace+
30- | whitespace
47+ | whitespace+
3148text-without-whitespace = (- (text-to-escape | whitespace))
3249 | ('\', text-to-escape)
3350text-to-escape = '(' | '{' | '/' | '\'
@@ -37,7 +54,8 @@ single-alternation = ((text-in-alternative+, optional*)
3754 | (optional+, text-in-alternative+))+
3855text-in-alternative = (- alternative-to-escape)
3956 | ('\', alternative-to-escape)
40- alternative-to-escape = ' ' | '(' | '{' | '/' | '\'
57+ alternative-to-escape = whitespace | '(' | '{' | '/' | '\'
58+ whitespace = ' '
4159
4260optional = '(' text-in-optional+ ')'
4361text-in-optional = (- optional-to-escape) | ('\', optional-to-escape)
@@ -51,6 +69,13 @@ name-to-escape = '{' | '}' | '(' | '/' | '\'
5169
5270
5371
72+ ## [ ` Regex ` ] Production Rules
73+
74+ Follows original [ production rules] .
75+
76+
77+
78+
5479## License
5580
5681This project is licensed under either of
@@ -63,8 +88,11 @@ at your option.
6388
6489
6590
91+ [ `Regex` ] : https://docs.rs/regex
92+
6693[ AST ] : https://en.wikipedia.org/wiki/Abstract_syntax_tree
6794[ Cucumber Expressions ] : https://github.com/cucumber/cucumber-expressions#readme
6895[ EBNF ] : https://en.wikipedia.org/wiki/Extended_Backus–Naur_form
6996
7097[ 1 ] : https://github.com/cucumber/cucumber-expressions/issues/41
98+ [ 2 ] : https://github.com/cucumber/cucumber-expressions/blob/main/ARCHITECTURE.md#production-rules
0 commit comments