[antlr-interest] Random code generator

Terence Parr parrt at cs.usfca.edu
Tue May 31 23:52:53 PDT 2011


hi. Ralf Lämmel has done good work inthis area.
Ter

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



More information about the antlr-interest mailing list