BNFGen generates random text based on context-free grammar. You give it a file with your grammar, defined using BNF-like syntax, it gives you a string that follows that grammar. BNFGen is a CLI tool, an OCaml library. There are also official JS bindings available via NPM. Project goals are to make it easy to write and share grammar and give the user total control of and insight into the generation process. BNFGen provides a "DSL" for grammar definitions. It's a familiar BNF-like syntax with a few additions. One problem with using straight BNF for driving language generators is that you have no control over the process. BNFGen adds two features to fix that. The canonical way to express repetition in BNF is to use a self-referential recursive rule. In classic BNF, that can easily lead to the process terminating to early, since there's a 50% chance that it will take the non-recursive alternative.

Features

  • Deterministic repetition
  • You can specify a "weight" for a rule alternative
  • BNFGen allows you to influence the chances and make the recursive alternative more likely to produce longer sentences
  • BNFGen provides a "DSL" for grammar definitions
  • CLI tool and OCaml library
  • BNFGen generates random text based on context-free grammar

Project Samples

Project Activity

See All Activity >

License

MIT License

Follow BNFGen

BNFGen Web Site

Other Useful Business Software
$300 Free Credits for Your Google Cloud Projects Icon
$300 Free Credits for Your Google Cloud Projects

Start building on Google Cloud with $300 in free credits. No commitment, no credit card required until you're ready to scale.

Launch your next project with $300 in free Google Cloud credits—no strings attached. Test, build, and deploy without risk. Use your credits across the entire Google Cloud platform to find what works best for your needs. After your credits are used, continue with always-free tier services. Only pay when you're ready to scale. Sign up in minutes and start exploring.
Start Free Trial
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of BNFGen!

Additional Project Details

Programming Language

OCaml (Objective Caml)

Related Categories

OCaml (Objective Caml) AI Text Generators, OCaml (Objective Caml) Generative AI

Registered

2023-03-23