Package org.antlr.tool
Class RandomPhrase
java.lang.Object
org.antlr.tool.RandomPhrase
Generate a random phrase given a grammar.
Usage:
java org.antlr.tool.RandomPhrase grammarFile.g startRule [seed]
For example:
java org.antlr.tool.RandomPhrase simple.g program 342
The seed acts like a unique identifier so you can get the same random
phrase back during unit testing, for example.
If you do not specify a seed then the current time in milliseconds is used
guaranteeing that you'll never see that seed again.
NOTE: this does not work well for large grammars...it tends to recurse
too much and build really long strings. I need throttle control; later.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static Integer
getTokenType
(Label label) static void
Used to generate random stringsprotected static void
randomPhrase
(Grammar g, List<Integer> tokenTypes, String startRule) an experimental method to generate random phrases for a given grammar given a start rule.
-
Field Details
-
debug
public static final boolean debug- See Also:
-
random
-
-
Constructor Details
-
RandomPhrase
public RandomPhrase()
-
-
Method Details
-
randomPhrase
an experimental method to generate random phrases for a given grammar given a start rule. Return a list of token types. -
getTokenType
-
main
Used to generate random strings
-