summaryrefslogtreecommitdiff
path: root/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2022-08-16 23:03:27 -0400
committerBen Culkin <scorpress@gmail.com>2022-08-16 23:03:27 -0400
commitcea3e47938322b97c318dea38dc0d649e196dc1b (patch)
tree0ceef0bafbfed7aa5802e8fc526c0c98276f1fff /JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java
parent4869146748ed51eb212935d2b971388fb9e73d37 (diff)
Refactor to add backtracking support
This probably doesn't help w/ error messages, but it enables some cool ideas where syntax can be reused in cases where it would otherwise be invalid
Diffstat (limited to 'JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java')
-rw-r--r--JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java
index fbcd35c..4935c81 100644
--- a/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java
+++ b/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java
@@ -2,6 +2,8 @@ package bjc.pratt.commands.impls;
import bjc.pratt.ParserContext;
import bjc.pratt.commands.AbstractInitialCommand;
+import bjc.pratt.commands.CommandResult;
+import bjc.pratt.commands.CommandResult.Status;
import bjc.pratt.commands.InitialCommand;
import bjc.pratt.tokens.Token;
import bjc.data.Tree;
@@ -39,8 +41,10 @@ public class DenestingCommand<K, V, C> extends AbstractInitialCommand<K, V, C> {
}
@Override
- protected Tree<Token<K, V>> intNullDenotation(final Token<K, V> operator, final ParserContext<K, V, C> ctx)
+ protected CommandResult<K, V> intNullDenotation(final Token<K, V> operator, final ParserContext<K, V, C> ctx)
throws ParserException {
- return wrapped.denote(operator, ctx).getChild(0);
+ CommandResult<K, V> res = wrapped.denote(operator, ctx);
+ if (res.status != Status.SUCCESS) return res;
+ return CommandResult.success(res.success().getChild(0));
}
} \ No newline at end of file