diff options
Diffstat (limited to 'RGens/src/main/java/bjc/rgens/newparser/RGrammarBuilder.java')
| -rw-r--r-- | RGens/src/main/java/bjc/rgens/newparser/RGrammarBuilder.java | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/RGens/src/main/java/bjc/rgens/newparser/RGrammarBuilder.java b/RGens/src/main/java/bjc/rgens/newparser/RGrammarBuilder.java index d71578b..b4f9f45 100644 --- a/RGens/src/main/java/bjc/rgens/newparser/RGrammarBuilder.java +++ b/RGens/src/main/java/bjc/rgens/newparser/RGrammarBuilder.java @@ -12,7 +12,7 @@ import static bjc.rgens.newparser.RuleCase.CaseType.*; /** * Construct randomized grammars piece by piece. - * + * * @author EVE * */ @@ -40,20 +40,20 @@ public class RGrammarBuilder { /** * Starts a rule with the provided name. - * + * * If the rule already exists, it will be opened for adding additional * cases instead. - * + * * @param rName * The name of the rule currently being built. - * + * * @throws IllegalArgumentException * If the rule name is the empty string. */ public void startRule(String rName) { - if(rName == null) { + if (rName == null) { throw new NullPointerException("Rule name must not be null"); - } else if(rName.equals("")) { + } else if (rName.equals("")) { throw new IllegalArgumentException("The empty string is not a valid rule name"); } @@ -62,7 +62,7 @@ public class RGrammarBuilder { /** * Convert this builder into a grammar. - * + * * @return The grammar built by this builder */ public RGrammar toRGrammar() { @@ -77,7 +77,7 @@ public class RGrammarBuilder { /** * Adds a case part to this rule. - * + * * <h2>Case part formatting</h2> * <dl> * <dt>Rule Reference</dt> @@ -86,7 +86,7 @@ public class RGrammarBuilder { * <dt>Literal Strings</dt> * <dd>Literal strings are the default case part type.</dd> * </dl> - * + * * @param csepart */ public void addCasePart(String csepart) { @@ -97,14 +97,14 @@ public class RGrammarBuilder { /** * Finalizes editing a rule. - * + * * Saves the rule to the rule map. - * + * * @throws IllegalStateException * Must be invoked while a rule is being edited. */ public void finishRule() { - if(currRule == null) { + if (currRule == null) { throw new IllegalStateException("Must start a rule before finishing one"); } @@ -113,12 +113,12 @@ public class RGrammarBuilder { /** * Finishes the current case being edited. - * + * * @throws IllegalStateException * Must be invoked while a rule is being edited. */ public void finishCase() { - if(currRule == null) { + if (currRule == null) { throw new IllegalStateException("Must start a rule before finishing a case"); } @@ -129,30 +129,30 @@ public class RGrammarBuilder { /** * Begins a case for the current rule. - * + * * @throws IllegalStateException * Must be invoked while a rule is being edited. */ public void beginCase() { - if(currRule == null) { + if (currRule == null) { throw new IllegalStateException("Must start a rule before adding cases"); } } /** * Set the initial rule of the grammar. - * + * * @param init * The initial rule of the grammar. - * + * * @throws IllegalArgumentException * If the rule is either not valid or not defined in the * grammar. */ public void setInitialRule(String init) { - if(init == null) { + if (init == null) { throw new NullPointerException("init must not be null"); - } else if(init.equals("")) { + } else if (init.equals("")) { throw new IllegalArgumentException("The empty string is not a valid rule name"); } @@ -161,18 +161,18 @@ public class RGrammarBuilder { /** * Add an exported rule to this grammar. - * + * * @param export * The name of the rule to export. - * + * * @throws IllegalArgumentException * If the rule is either not valid or not defined in the * grammar. */ public void addExport(String export) { - if(export == null) { + if (export == null) { throw new NullPointerException("Export name must not be null"); - } else if(export.equals("")) { + } else if (export.equals("")) { throw new NullPointerException("The empty string is not a valid rule name"); } @@ -181,54 +181,54 @@ public class RGrammarBuilder { /** * Suffix a given case element to every case of a specific rule. - * + * * @param ruleName * The rule to suffix. - * + * * @param suffix * The suffix to add. - * + * * @throws IllegalArgumentException * If the rule name is either invalid or not defined by * this grammar, or if the suffix is invalid. */ public void suffixWith(String ruleName, String suffix) { - if(ruleName == null) { + if (ruleName == null) { throw new NullPointerException("Rule name must not be null"); - } else if(ruleName.equals("")) { + } else if (ruleName.equals("")) { throw new IllegalArgumentException("The empty string is not a valid rule name"); } CaseElement element = CaseElement.createElement(suffix); - for(RuleCase ruleCase : rules.get(ruleName).getCases()) { + for (RuleCase ruleCase : rules.get(ruleName).getCases()) { ruleCase.getElements().add(element); } } /** * Prefix a given case element to every case of a specific rule. - * + * * @param ruleName * The rule to prefix. - * + * * @param prefix * The prefix to add. - * + * * @throws IllegalArgumentException * If the rule name is either invalid or not defined by * this grammar, or if the prefix is invalid. */ public void prefixWith(String ruleName, String prefix) { - if(ruleName == null) { + if (ruleName == null) { throw new NullPointerException("Rule name must not be null"); - } else if(ruleName.equals("")) { + } else if (ruleName.equals("")) { throw new IllegalArgumentException("The empty string is not a valid rule name"); } CaseElement element = CaseElement.createElement(prefix); - for(RuleCase ruleCase : rules.get(ruleName).getCases()) { + for (RuleCase ruleCase : rules.get(ruleName).getCases()) { ruleCase.getElements().add(element); } } |
