程序包 org.antlr.tool

类 RandomPhrase


  • public class RandomPhrase
    extends java.lang.Object
    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.
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      static boolean debug  
      protected static java.util.Random random  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      protected static java.lang.Integer getTokenType​(Label label)  
      static void main​(java.lang.String[] args)
      Used to generate random strings
      protected static void randomPhrase​(Grammar g, java.util.List<java.lang.Integer> tokenTypes, java.lang.String startRule)
      an experimental method to generate random phrases for a given grammar given a start rule.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • random

        protected static java.util.Random random
    • 构造器详细资料

      • RandomPhrase

        public RandomPhrase()
    • 方法详细资料

      • randomPhrase

        protected static void randomPhrase​(Grammar g,
                                           java.util.List<java.lang.Integer> tokenTypes,
                                           java.lang.String startRule)
        an experimental method to generate random phrases for a given grammar given a start rule. Return a list of token types.
      • getTokenType

        protected static java.lang.Integer getTokenType​(Label label)
      • main

        public static void main​(java.lang.String[] args)
        Used to generate random strings