A grammar-based random text generator, inspired by Perchance.
Dependencies:
To install Mayhap, run:
git clone https://github.com/Maugrift/mayhap.git
cd mayhap
pip install .
After installing mayhap, run:
mayhap grammar.mh [pattern]
grammar.mh
may be any Mayhap grammar file (see Grammars).
If a pattern
is given, it will be expanded and printed to standard output.
If no pattern
is given, patterns will be read line-by-line from standard input, and their expansions printed to standard output.
For detailed usage information, run:
mayhap --help
To run Mayhap from source, run the following within the repository directory:
python -m mayhap
Sample grammar files may be found in the samples
directory.
Mayhap grammars follow a syntax similar to those of Perchance.
Mayhap does not support the full range of features in Perchance grammars, nor does it plan to, but more features are planned to be supported soon nonetheless.
Note that Mayhap is not affiliated with nor endorsed by Perchance, and merely takes inspiration from its syntax.
If you want to submit a PR, please follow these guidelines:
- Run
python -m unittest
to run the unit test suite. - Run
test/test_samples.sh
to run Mayhap on all samples. - Run some Python linters such as Pylint, flake8, and/or mypy to help ensure consistent code style and quality.
- If you create any new Python source files, copy the license notice from
mayhap.py
into them.