From cea3e47938322b97c318dea38dc0d649e196dc1b Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Tue, 16 Aug 2022 23:03:27 -0400 Subject: 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 --- .../src/main/java/bjc/pratt/commands/impls/DenestingCommand.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java') 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 extends AbstractInitialCommand { } @Override - protected Tree> intNullDenotation(final Token operator, final ParserContext ctx) + protected CommandResult intNullDenotation(final Token operator, final ParserContext ctx) throws ParserException { - return wrapped.denote(operator, ctx).getChild(0); + CommandResult 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 -- cgit v1.2.3