From 15a2b29e48f134bc93cfd0a3d8512001e9242f3d Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 3 Jun 2024 17:33:53 -0400 Subject: Rename package to new domain Rename the package to the new domain --- .../java/bjc/pratt/blocks/TriggeredParseBlock.java | 62 ---------------------- 1 file changed, 62 deletions(-) delete mode 100644 JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java (limited to 'JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java') diff --git a/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java deleted file mode 100644 index d404eea..0000000 --- a/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java +++ /dev/null @@ -1,62 +0,0 @@ -package bjc.pratt.blocks; - -import java.util.function.UnaryOperator; - -import bjc.pratt.ParserContext; -import bjc.pratt.commands.CommandResult; -import bjc.pratt.commands.CommandResult.Status; -import bjc.utils.parserutils.ParserException; - -/** - * A parse block that can adjust the state before handling its context. - * - * @author bjculkin - * - * @param - * The key type of the tokens. - * @param - * The value type of the tokens. - * @param - * The state type of the parser. - */ -public class TriggeredParseBlock implements ParseBlock { - private final UnaryOperator onEntr; - private final UnaryOperator onExt; - - private final ParseBlock sourc; - - /** - * Create a new triggered parse block. - * - * @param onEnter - * The action to fire before parsing the block. - * - * @param onExit - * The action to fire after parsing the block. - * - * @param source - * The block to use for parsing. - */ - public TriggeredParseBlock(final UnaryOperator onEnter, final UnaryOperator onExit, - final ParseBlock source) { - onEntr = onEnter; - onExt = onExit; - sourc = source; - } - - @Override - public CommandResult parse(final ParserContext ctx) throws ParserException { - final C newState = onEntr.apply(ctx.state); - - final ParserContext newCtx = new ParserContext<>(ctx.tokens, ctx.parse, newState); - - final CommandResult res = sourc.parse(newCtx); - - if (res.status != Status.SUCCESS) return res; - - ctx.state = onExt.apply(newState); - - return res; - } - -} -- cgit v1.2.3