Skip to main content

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bnf_string_generator-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bnf_string_generator-0.1.0-py2.py3-none-any.whl (4.5 kB view details)

Uploaded Python 2Python 3

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

Hashes for bnf_string_generator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c3496b127acb00a49e50c6cce49a16a6787fc9db117426e3eee8fd8e2220b2d
MD5 673263d825b94614d91e03a8472b6847
BLAKE2b-256 f861d08cbae7900b92fdeb4fe257087f75d6f45b95955a5c3dbca97c3e75c4a8

See more details on using hashes here.

File details

Details for the file bnf_string_generator-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for bnf_string_generator-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8878f58bd44071afb63e7040abc863ad71902eddfdd057beeb9c885b9fc8059d
MD5 147cfca37535db484f53bd0e34b40622
BLAKE2b-256 fc7b8d8b14a870cd35e04dcf57f125bdcdc89cf871071a668e336e5c48248925

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page