[antlr-interest] Random code generator
arthernan at hotmail.com
Wed Jun 1 14:21:57 PDT 2011
Thank you both,
I did take a dive in the RandomPhrase.java
It looked like it relies on randomly falling into terminating rules to exit. If I read the code correctly. Makes sense that complex grammars would
Before I read your response I found Peter Maurer DGL. And it implements the features I mentioned and more. But I am not sure I want to dilute my learning at this point. I am learning ANTLR just so I can isolate my code from soo many language/framework/IDE options.
Before I read about Ralf's work. I wanted to mention a couple of ideas.
I thought some extra actions inside of a given ANTLR grammar could introduce bias. The actions sideffects could be picked up in the RandomPhrase.java code.
Also some high level constructs (patterns) could be added as rules, and an alternative head could be introduced for pseudorandom generation. Thanks again.
> From: parrt at cs.usfca.edu
> To: antlr-interest at antlr.org
> Date: Wed, 1 Jun 2011 08:52:53 +0200
> Subject: Re: [antlr-interest] Random code generator
> hi. Ralf Lämmel has done good work inthis area.
> On Jun 1, 2011, at 2:50 AM, The Researcher wrote:
> > Hi Arturo,
> > If you are referening to generating test phrases for input to your
> > parser,
> > then
> > Ter did a quick take on this.
> > http://www.antlr.org/wiki/display/ANTLR3/Random+phrase+generation+using+an+ANTLR+grammar
> > which will lead you to the RandomPhrase.java in the distribution
> > with the
> > following note.
> > NOTE: this does not work well for large grammars...it tends to
> > recurse too
> > much and build really long strings.
> > I did a quick search on the Internet with the requirements that it
> > be open
> > source, free, documented and produced valid code for a compiler; I
> > found
> > nothing. That doesn' t mean it doesn't exist, I just didn't find it..
> > I am currently writing my own, but it is not based on any random
> > seed or
> > statistics. It is designed to generate fully valid phrases for the
> > grammar.
> > As a specific example, if I want to test method phrases in a class,
> > the
> > methods will be wrapped in a class and be capable of being compiled,
> > it
> > won't be a list of methods that need special code to test. One big
> > caveat
> > with my program is that the grammar must be converted to BNF, which
> > means
> > only two operators ab or a | b, no ?, + or *.
> > Eric
> > List: http://www.antlr.org/mailman/listinfo/antlr-interest
> > Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 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