A tool for generating random strings based on Backus-Naur Form (BNF) grammar.
Project description
BNF String Generator
Description
This is a tool for generating random strings from grammars defined in Backus-Naur Form (BNF). It operates by iteratively expanding non-terminal symbols into their corresponding production rules until only terminal symbols remain.
Install from PyPI:
pip install bnf-string-generator
Install from Source:
Clone the repository and install:
git clone https://github.com/yourusername/bnf-string-generator.git
cd bnf-string-generator
pip install .
Usage
You can generate random strings by providing a BNF grammar. Here’s an example:
Example:
from bnf_string_generator import bnf_string_generator
bnf_grammar = """
<greeting> ::= <salutation> | <salutation> <intro> <EOL> <reply>
<reply> ::= <salutation>
<salutation> ::= "Hello" | "Hi" | "Hey" | "Greetings"
<intro> ::= ", I'm " <name>
<name> ::= "Alice" | "Bob" | "Charlie" | "Sam" | "Emma" | "John"
"""
random_string = bnf_string_generator(bnf_grammar)
print(random_string)
This will generate a random greeting like:
Hello, I'm Bob
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bnf_string_generator-0.1.0.tar.gz.
File metadata
- Download URL: bnf_string_generator-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c3496b127acb00a49e50c6cce49a16a6787fc9db117426e3eee8fd8e2220b2d
|
|
| MD5 |
673263d825b94614d91e03a8472b6847
|
|
| BLAKE2b-256 |
f861d08cbae7900b92fdeb4fe257087f75d6f45b95955a5c3dbca97c3e75c4a8
|
File details
Details for the file bnf_string_generator-0.1.0-py2.py3-none-any.whl.
File metadata
- Download URL: bnf_string_generator-0.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8878f58bd44071afb63e7040abc863ad71902eddfdd057beeb9c885b9fc8059d
|
|
| MD5 |
147cfca37535db484f53bd0e34b40622
|
|
| BLAKE2b-256 |
fc7b8d8b14a870cd35e04dcf57f125bdcdc89cf871071a668e336e5c48248925
|