From 112a000e535ad26fe792655e5c0ad42d5cad78cc Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 29 Oct 2018 08:07:18 -0400 Subject: Partial implementation of directive sequences They can be created, but not evaluated --- src/main/java/bjc/inflexion/InflectionString.java | 41 ++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src') 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 } /** @@ -418,6 +422,11 @@ public class InflectionString { */ public NounOptions nounOpts = new NounOptions(); + /** + * The directives contained in a sequence. + */ + public List listDir; + /** * Create a new inflection directive. * @@ -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 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 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. * -- cgit v1.2.3