[antlr-interest] Syntax based testing for ANTLR grammars?

Eric researcher0x00 at gmail.com
Thu Sep 20 05:21:56 PDT 2012


Hi Mike,

If you are talking about phrase generation then Ter did an initial take on
it with

http://www.antlr.org/wiki/display/ANTLR3/Random+phrase+generation+using+an+ANTLR+grammar


I did some work on my own on this a year ago and the problem you get into
is a huge explosion in output. Just to manage the problem of the explosion
I had to create methods just to count the possibilities given a grammar and
the easiest way for me to relate to the size was as a power. So for one
grammar the set could have 10**15 results and others could have 10**30
results. This is not even something that can be reasonably tested.

To tackle this you then need to learn to put in constraints into the
grammar to control the generation of sets. Now the sets you get will be
valid syntax but not semantically valid, so if you are testing with input
to a compiler, most of the cases will be invalid. So then you have to
modify the input grammar to the phrase generator again to only let valid
productions through. At this point even the generation of the input to the
phrase generator is so complicated you find that creating a GUI to manage
it is a good solution.

It can be done but it takes work.


Eric
On Wed, Sep 19, 2012 at 7:35 PM, Michael Barry <msb5014 at gmail.com> wrote:

> Hello,
>
> Is anyone aware of any projects out there for doing syntax-based
> testing using ANTLR grammars?  The simplest form would be a tool for
> generating valid language productions from an ANTLR grammar, but more
> complex might introduce mutations.
>
>
> Thanks
> Mike Barry
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>


More information about the antlr-interest mailing list