Package quickparse.grammar
Class Grammar.Builder
java.lang.Object
quickparse.grammar.Grammar.Builder
- Enclosing class:
- Grammar
public static class Grammar.Builder
extends java.lang.Object
Allows the construction of a
grammar, rule by rule-
Constructor Summary
Constructors Constructor Description Builder() -
Method Summary
Modifier and Type Method Description Grammar.BuilderaddRule(Rule rule)Adds a rule to thegrammar.Grammar.BuilderaddRule(Rule.Builder ruleBuilder)Adds a new rule to thegrammar, taking a rule builder as input.Grammarbuild()Builds thegrammar.Grammarbuild(java.lang.String axiom)Builds thegrammar, setting up the given construct symbol as axiom.Grammar.BuilderignorePatterns(java.lang.String... patterns)Adds the given patterns to the ignored ones of the grammar that is being built.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
addRule
Adds a new rule to thegrammar, taking a rule builder as input. This method invokes theRule.Builder.build()method on the given rule builder, first. Then, it adds the new rule to the grammar.- Parameters:
ruleBuilder- a rule builder- Returns:
- this same
builder
-
addRule
Adds a rule to thegrammar.- Parameters:
rule- the rule to add.- Returns:
- this same
builder
-
ignorePatterns
Adds the given patterns to the ignored ones of the grammar that is being built.- Parameters:
patterns- the patterns the grammar must ignore- Returns:
- this same
builder
-
build
Builds thegrammar. This method sets theaxiomof the grammar to be the head of the first rule added to the builder.- Returns:
- the new
grammar
-
build
Builds thegrammar, setting up the given construct symbol as axiom. This method is useful if and only if when the head of the fist rule added to the grammar is not the axiom.
-