Top Description Fields Constructors Methods
org.antlr.tool

public Class RandomPhrase

extends Object
Class Inheritance
Imports
org.antlr.Tool, org.antlr.analysis.Label, .NFAState, .RuleClosureTransition, .Transition, org.antlr.misc.IntervalSet, .Utils, java.io.BufferedReader, .FileReader, java.util.ArrayList, .Collection, .List, .Random, .Stack

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

Modifier and TypeField and Description
public static final boolean
protected static Random

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected static Integer
public static void
main(String[] args)

Used to generate random strings

protected 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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

debugback to summary
public static final boolean debug
randomback to summary
protected static Random random

Constructor Detail

RandomPhraseback to summary
public RandomPhrase()

Method Detail

getTokenTypeback to summary
protected static Integer getTokenType(Label label)
mainback to summary
public static void main(String[] args)

Used to generate random strings

randomPhraseback to summary
protected 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. Return a list of token types.