alexandru-dinu / synx

Generate random strings given a BNF grammar.
MIT License
0 stars 0 forks source link

Add support for regex patterns in terminals #5

Closed alexandru-dinu closed 1 year ago

alexandru-dinu commented 1 year ago

E.g. instead of

<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"

we can write

<digit> ::= "[0-9]+"

At a first glance (apart from some escaping issues), this should be immediately possible, as any literal is a pattern itself (i.e. matching that exact literal).

The tricky part, however, lies in generating a random string from the pattern. Specifically, distinguishing between the plus sign in: [0-9]+: (meta-character) and + (literal).

alexandru-dinu commented 1 year ago

Done for now. Using r" to denote a regex terminal. May be non-standard, but works for now.