summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Culkin <bjculkin@mix.wvu.edu>2018-10-29 08:07:18 -0400
committerGitHub <noreply@github.com>2018-10-29 08:07:18 -0400
commit112a000e535ad26fe792655e5c0ad42d5cad78cc (patch)
treec418732c806f8ff6de869f21b593eab33c10022e
parent3e735031a713d52891e2504c5c1e9b52ad9e44af (diff)
Partial implementation of directive sequences
They can be created, but not evaluated
-rw-r--r--src/main/java/bjc/inflexion/InflectionString.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/main/java/bjc/inflexion/InflectionString.java b/src/main/java/bjc/inflexion/InflectionString.java
index 523e18d..8b47b8e 100644
--- a/src/main/java/bjc/inflexion/InflectionString.java
+++ b/src/main/java/bjc/inflexion/InflectionString.java
@@ -69,7 +69,11 @@ public class InflectionString {
/**
* Prints an inflected noun.
*/
- NOUN
+ NOUN,
+ /**
+ * Represents a sequence of directives.
+ */
+ SEQ
}
/**
@@ -419,6 +423,11 @@ public class InflectionString {
public NounOptions nounOpts = new NounOptions();
/**
+ * The directives contained in a sequence.
+ */
+ public List<InflectionDirective> listDir;
+
+ /**
* Create a new inflection directive.
*
* @param type
@@ -480,6 +489,28 @@ public class InflectionString {
}
}
+
+ /**
+ * Create a new inflection directive.
+ *
+ * @param type
+ * The type of the directive.
+ * @param num
+ * The number value for the directive.
+ */
+ public InflectionDirective(DirectiveType type, List<InflectionDirective> listDir) {
+ this.type = type;
+
+ switch (type) {
+ case SEQ:
+ this.listDir = listDir;
+ break;
+ default:
+ throw new IllegalArgumentException(
+ "Unhandled or wrong arguments (1 list of directives) for directive type " + type);
+
+ }
+ }
/**
* Create a new literal directive.
@@ -541,6 +572,14 @@ public class InflectionString {
return new InflectionDirective(DirectiveType.NOUN, strang);
}
+ public static InflectionDirective seq(List<InflectionDirective> list) {
+ return new InflectionDirective(DirectiveType.SEQ, list);
+ }
+
+ public static InflectionDirective seq(InflectionDirective arr) {
+ return new InflectionDirective(DirectiveType.SEQ, Arrays.asList(arr));
+ }
+
/**
* Set the numeric options for this directive.
*