summaryrefslogtreecommitdiff
path: root/JPratt/src/main/java/bjc/pratt/commands/CommandResult.java
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-06-03 17:33:53 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-06-03 17:33:53 -0400
commit15a2b29e48f134bc93cfd0a3d8512001e9242f3d (patch)
treeb3f5c4c5f0e474479cd47ad0ac0f35770fc44881 /JPratt/src/main/java/bjc/pratt/commands/CommandResult.java
parent39ba97edf49270715ec61bedb7d4a62ada819ba0 (diff)
Rename package to new domainHEADtrunk
Rename the package to the new domain
Diffstat (limited to 'JPratt/src/main/java/bjc/pratt/commands/CommandResult.java')
-rw-r--r--JPratt/src/main/java/bjc/pratt/commands/CommandResult.java112
1 files changed, 0 insertions, 112 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/commands/CommandResult.java b/JPratt/src/main/java/bjc/pratt/commands/CommandResult.java
deleted file mode 100644
index 38a55ae..0000000
--- a/JPratt/src/main/java/bjc/pratt/commands/CommandResult.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package bjc.pratt.commands;
-
-import bjc.data.Tree;
-import bjc.pratt.tokens.Token;
-
-/**
- * Represents the result of executing a command.
- *
- * @author bjcul
- *
- * @param <K> The key type of the tokens
- * @param <V> The value type of the tokens
- */
-public class CommandResult<K, V> {
- /**
- * Represents the status of a command execution
- *
- * @author bjcul
- *
- */
- public static enum Status {
- /**
- * The command successfully parsed.
- */
- SUCCESS,
- /**
- * The command failed, in a non-recoverable way
- */
- FAIL,
- /**
- * The command failed. Attempt recovery via backtracking
- */
- BACKTRACK
- }
-
- /**
- * The status of this command.
- */
- public final Status status;
-
- private Tree<Token<K, V>> success;
-
- private CommandResult(Status status) {
- this.status = status;
- }
-
- /**
- * Get the success value of this command, or null if it failed.
- *
- * @return The success value of the command
- */
- public Tree<Token<K, V>> success() {
- return success;
- }
-
- /**
- * Create a success result
- *
- * @param <K2> The key type of the token
- * @param <V2> The value type of the token
- *
- * @param succ The tree produced by the command
- *
- * @return A command result representing a success
- */
- public static <K2, V2> CommandResult<K2, V2> success(Tree<Token<K2, V2>> succ) {
- CommandResult<K2, V2> result = new CommandResult<>(Status.SUCCESS);
- result.success = succ;
- return result;
- }
-
- /**
- * Create a non-backtracking failure result.
- *
- * @param <K2> The key type of the token
- * @param <V2> The value type of the token
- *
- * @return A command result representing a non-backtracking fail
- */
- public static <K2, V2> CommandResult<K2, V2> fail() {
- CommandResult<K2, V2> result = new CommandResult<>(Status.FAIL);
- return result;
- }
-
- /**
- * Create a backtracking failure result.
- *
- * @param <K2> The key type of the token
- * @param <V2> The value type of the token
- *
- * @return A command result representing a backtracking fail
- */
- public static <K2, V2> CommandResult<K2, V2> backtrack() {
- CommandResult<K2, V2> result = new CommandResult<>(Status.BACKTRACK);
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append("CommandResult [status=");
- builder.append(status);
- if (status == Status.SUCCESS) {
- builder.append(", success=");
- builder.append(success);
- }
- builder.append("]");
- return builder.toString();
- }
-
-
-}