summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/rgens/parser/RGrammarBuilder.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2018-09-05 17:19:41 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2018-09-05 17:19:41 -0300
commit1116d8450c0115ebb8a4201d130d2de6d5b1a107 (patch)
treed0f6a770cc7c8beda1d9cb1ce862750c9f0895b0 /src/main/java/bjc/rgens/parser/RGrammarBuilder.java
parente26cdec45a32c2fc3069dea7cddceab5e40a4a8b (diff)
Simplify affix application
This simplifies the internal way affixes are applied, as well as adding a new circumfix-with pragma
Diffstat (limited to 'src/main/java/bjc/rgens/parser/RGrammarBuilder.java')
-rwxr-xr-xsrc/main/java/bjc/rgens/parser/RGrammarBuilder.java26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/main/java/bjc/rgens/parser/RGrammarBuilder.java b/src/main/java/bjc/rgens/parser/RGrammarBuilder.java
index f1d0938..1bc849b 100755
--- a/src/main/java/bjc/rgens/parser/RGrammarBuilder.java
+++ b/src/main/java/bjc/rgens/parser/RGrammarBuilder.java
@@ -179,20 +179,38 @@ public class RGrammarBuilder {
affixWith(ruleName, prefixes, AffixType.PREFIX);
}
- private static enum AffixType {
+ /**
+ * Prefix and suffix a given case element to every case of a specific rule.
+ *
+ * @param ruleName
+ * The rule to prefix and suffix.
+ *
+ * @param prefix
+ * The prefix/suffix to add.
+ *
+ * @throws IllegalArgumentException
+ * If the rule name is either invalid or not defined by this
+ * grammar, or if the prefix/suffix is invalid.
+ */
+ public void circumfixWith(String ruleName, IList<CaseElement> prefixes) {
+ affixWith(ruleName, prefixes, AffixType.CIRCUMFIX);
+ }
+
+ public static enum AffixType {
+ CIRCUMFIX,
SUFFIX,
PREFIX;
public boolean isSuffix() {
- return this == SUFFIX;
+ return this != PREFIX;
}
public boolean isPrefix() {
- return this == PREFIX;
+ return this != SUFFIX;
}
}
- private void affixWith(String ruleName, IList<CaseElement> affixes, AffixType type) {
+ public void affixWith(String ruleName, IList<CaseElement> affixes, AffixType type) {
if (ruleName == null) {
throw new NullPointerException("Rule name must not be null");
} else if (ruleName.equals("")) {