Skip to main content

Generation-based, context-free grammar fuzzer.

Project description


Generation-based, context-free grammar fuzzer.

Build Status IRC

Table of Contents


All roads lead to Rome but Python 3.x is the prefered vehicle.


pip install dharma
dharma --help


pipenv install --dev
pipenv run dharma --help


python -m dharma --help


docker build -t dharma .
docker run --rm -it dharma -grammars dharma/grammars/canvas2d.dg


Generate a single test-case and print it to stdout. Multiple grammars can be appended to the -grammars argument.

dharma -grammars dharma/grammars/canvas2d.dg

Generating multiple test-cases and save the result to disk.

dharma -grammars dharma/grammars/canvas2d.dg -storage . -count 5

Generate test-cases and serve them in a template via WebSocket. Launch dharma/grammars/var/index.html in the browser after Dharma launched.

dharma -grammars dharma/grammars/canvas2d.dg -server -template grammars/var/templates/html5/default.html

Benchmark the generator.

time dharma -grammars dharma/grammars/canvas2d.dg -count 10000 > /dev/null



In case you run PyLint 1.9.2 and Python 3.7 you need to upgrade PyLint.

pip3 install pylint astroid --pre -U

Dharma Grammar Cheatsheet


%%% comment


%const% name := value


%section% := value
%section% := variable
%section% := variance

Extension Methods

Refer to in dharma/core/ and to the xref_registry in the DharmaMachine class to add further extensions.


%repeat%(+variable+, ", ")



%choice%(foo, "bar", 1)

Assigning Values

digit :=

sign :=

value :=

Using Values


Assigning Variables

variable :=
    @variable@ = new Foo();

Using Variables

value :=

Referencing values from common.dg

value :=

Calling JavaScript library methods

foo :=

API Documentation

Dharma in the Public

Dharma mentionings in the news.

Project details

Download files

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

Source Distribution

dharma-1.2.0.tar.gz (34.4 kB view hashes)

Uploaded source

Built Distribution

dharma-1.2.0-py3-none-any.whl (42.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page