From c82452e59b1547392c3e89d08d9173cc6dc79e23 Mon Sep 17 00:00:00 2001 From: bjculkin Date: Wed, 5 Apr 2017 15:35:13 -0400 Subject: Reorganize --- .../pratt/blocks/TriggeredParseBlock.java | 61 ---------------------- 1 file changed, 61 deletions(-) delete mode 100644 JPratt/src/main/java/bjc/utils/parserutils/pratt/blocks/TriggeredParseBlock.java (limited to 'JPratt/src/main/java/bjc/utils/parserutils/pratt/blocks/TriggeredParseBlock.java') diff --git a/JPratt/src/main/java/bjc/utils/parserutils/pratt/blocks/TriggeredParseBlock.java b/JPratt/src/main/java/bjc/utils/parserutils/pratt/blocks/TriggeredParseBlock.java deleted file mode 100644 index fbfc61b..0000000 --- a/JPratt/src/main/java/bjc/utils/parserutils/pratt/blocks/TriggeredParseBlock.java +++ /dev/null @@ -1,61 +0,0 @@ -package bjc.utils.parserutils.pratt.blocks; - -import java.util.function.UnaryOperator; - -import bjc.utils.data.ITree; -import bjc.utils.parserutils.ParserException; -import bjc.utils.parserutils.pratt.ParseBlock; -import bjc.utils.parserutils.pratt.ParserContext; -import bjc.utils.parserutils.pratt.Token; - -/** - * 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 UnaryOperator onEnter; - private UnaryOperator onExit; - - private ParseBlock source; - - /** - * 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(UnaryOperator onEnter, UnaryOperator onExit, ParseBlock source) { - super(); - this.onEnter = onEnter; - this.onExit = onExit; - this.source = source; - } - - @Override - public ITree> parse(ParserContext ctx) throws ParserException { - C newState = onEnter.apply(ctx.state); - - ParserContext newCtx = new ParserContext<>(ctx.tokens, ctx.parse, newState); - - ITree> res = source.parse(newCtx); - - ctx.state = onExit.apply(newState); - - return res; - } - -} -- cgit v1.2.3