Package org.parboiled

Class Parboiled


  • public class Parboiled
    extends java.lang.Object
    Main class providing the high-level entry point into the parboiled library.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Parboiled()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <P extends BaseParser<V>,​V>
      P
      createParser​(java.lang.Class<P> parserClass, java.lang.Object... constructorArgs)
      Creates a parser object whose rule creation methods can then be used with one of the ParseRunner implementations.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Parboiled

        protected Parboiled()
    • Method Detail

      • createParser

        public static <P extends BaseParser<V>,​V> P createParser​(java.lang.Class<P> parserClass,
                                                                       java.lang.Object... constructorArgs)

        Creates a parser object whose rule creation methods can then be used with one of the ParseRunner implementations.

        Since parboiled needs to extend your parser with certain extra logic (e.g. to prevent infinite recursions in recursive rule definitions) you cannot create your parser object yourself, but have to go through this method. Also your parser class has to be derived from BaseParser. If you want to use a non-default constructor you can provide its arguments to this method. Make sure your non-default constructor does not use primitive type parameters (like "int") but rather their boxed counterparts (like "Integer"), otherwise the constructor will not be found.

        Performing the rule analysis and extending the parser class is an expensive process (time-wise) and can take up to several hundred milliseconds for large grammars. However, this cost is only incurred once per parser class and class loader. Subsequent calls to this method are therefore fast once the initial extension has been performed.

        Parameters:
        parserClass - the type of the parser to create
        constructorArgs - optional arguments to the parser class constructor
        Returns:
        the ready to use parser instance