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
Metadata
Release files for bnf-string-generator 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bnf_string_generator-0.1.0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bnf_string_generator-0.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 8.2 kB
Release files / bnf_string_generator-0.1.0.tar.gz
| Download URL | bnf_string_generator-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c3496b127acb00a49e50c6cce49a16a6787fc9db117426e3eee8fd8e2220b2d
|
|
BLAKE2b-256 checksum How to use checksums |
f861d08cbae7900b92fdeb4fe257087f75d6f45b95955a5c3dbca97c3e75c4a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.6
|
Release files / bnf_string_generator-0.1.0-py2.py3-none-any.whl
| Download URL | bnf_string_generator-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8878f58bd44071afb63e7040abc863ad71902eddfdd057beeb9c885b9fc8059d
|
|
BLAKE2b-256 checksum How to use checksums |
fc7b8d8b14a870cd35e04dcf57f125bdcdc89cf871071a668e336e5c48248925
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.6
|