P - the type of the parser usedpublic static final class GrappaSslrFactory.Builder<P extends SonarParserBase>
extends java.lang.Object
GrappaSslrFactory
This class is not directly instantiable; use GrappaSslrFactory.withParserClass(Class) to create a new instance.
| Modifier and Type | Method and Description |
|---|---|
GrappaSslrFactory.Builder<P> |
addListenerSupplier(ListenerSupplier supplier)
Add a
ListenerSupplier to the factory
Since a ListeningParseRunner is used, it means you can add
further parsing listeners when the file is parsed; for instance, you
may want to add a TracingListener to debug the parsing
process. |
GrappaSslrFactory |
build()
Build the factory
|
GrappaSslrFactory.Builder<P> |
withEntryPoint(org.sonar.sslr.grammar.GrammarRuleKey entryPoint)
Define the grammar entry point for the grammar
|
GrappaSslrFactory.Builder<P> |
withGrammarClass(java.lang.Class<? extends org.sonar.sslr.grammar.GrammarRuleKey> grammarClass)
Deprecated.
use
withGrammarInjector(GrammarInjector) instead |
GrappaSslrFactory.Builder<P> |
withGrammarInjector(GrammarInjector injector)
Sets the grammar injector for this factory
Since Java 8 is used, and a
GrammarInjector is a
functional interface, you can use method references here. |
GrappaSslrFactory.Builder<P> |
withMainRule(java.util.function.Function<P,com.github.fge.grappa.rules.Rule> ruleFunction)
Define the main rule for the parser as a
Function
Typically, if your parser class is MyParser and the rule
you want as a main rule is called myRule, the argument to
this method will be MyParser::myRule. |
@Deprecated public GrappaSslrFactory.Builder<P> withGrammarClass(java.lang.Class<? extends org.sonar.sslr.grammar.GrammarRuleKey> grammarClass)
withGrammarInjector(GrammarInjector) insteadThe grammar class, in this case, is expected to have a static
method named injectInto which takes a LexerfulGrammarBuilder as its sole argument.
grammarClass - the classpublic GrappaSslrFactory.Builder<P> withGrammarInjector(GrammarInjector injector)
Since Java 8 is used, and a GrammarInjector is a
functional interface, you can use method references here.
injector - the injectorpublic GrappaSslrFactory.Builder<P> withEntryPoint(org.sonar.sslr.grammar.GrammarRuleKey entryPoint)
entryPoint - the entry point, as a GrammarRuleKeyLexerfulGrammarBuilder.setRootRule(GrammarRuleKey)public GrappaSslrFactory.Builder<P> withMainRule(java.util.function.Function<P,com.github.fge.grappa.rules.Rule> ruleFunction)
Function
Typically, if your parser class is MyParser and the rule
you want as a main rule is called myRule, the argument to
this method will be MyParser::myRule.
ruleFunction - the function providing the rulepublic GrappaSslrFactory.Builder<P> addListenerSupplier(ListenerSupplier supplier)
ListenerSupplier to the factory
Since a ListeningParseRunner is used, it means you can add
further parsing listeners when the file is parsed; for instance, you
may want to add a TracingListener to debug the parsing
process.
supplier - the supplierpublic GrappaSslrFactory build()