public class Parboiled
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
Parboiled() |
Modifier and Type | Method and Description |
---|---|
static <P extends BaseParser<V>,V> |
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. |
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.
parserClass
- the type of the parser to createconstructorArgs
- optional arguments to the parser class constructor