luc-tielen / lua-quickcheck

Property based testing in Lua, inspired by the original QuickCheck.
MIT License
39 stars 1 forks source link

Feature: create a generator of strings matching context-free grammar #31

Open ligurio opened 3 years ago

ligurio commented 3 years ago

There are type of programs that accept data matching context-free grammars: compilers, parsers etc. These programs can be easily tested using property-based approach with generator of strings matching context-free grammar accepted by program. There is such functionality exist in Hypothesis python module, see [1].

I found at least two Lua modules that generates parsers using PEG syntax, see [3] and [4].

It would be nice to create a generator that accepts grammar and produce a string matching this grammar.

  1. https://hypothesis.readthedocs.io/en/latest/extras.html#hypothesis-lark
  2. https://pypi.org/project/hypothesis-grammar/
  3. https://github.com/andremm/lua-parser
  4. https://github.com/vsbenas/parser-gen
ligurio commented 3 years ago

LGen - the Lua Language Generator (LGen) is a sentence (test data) generator based on syntax description and which uses coverage criteria to restrict the set of generated sentences. This generator takes as input a grammar described in a notation based on Extended BNF (EBNF) and returns a set of sentences of the language corresponding to this grammar.