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/ChainParseBlock.java | 85 ---------------------- 1 file changed, 85 deletions(-) delete mode 100644 JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java (limited to 'JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java') diff --git a/JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java deleted file mode 100644 index 2717e42..0000000 --- a/JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java +++ /dev/null @@ -1,85 +0,0 @@ -package bjc.pratt.blocks; - -import java.util.Set; - -import bjc.pratt.ParserContext; -import bjc.pratt.commands.CommandResult; -import bjc.pratt.commands.CommandResult.Status; -import bjc.pratt.tokens.Token; -import bjc.data.Tree; -import bjc.data.SimpleTree; -import bjc.utils.parserutils.ParserException; - -/** - * A {@link ParseBlock} for a series of parse blocks, linked by a set of tokens. - * - * Roughly analogous to Perl 6s list associative operators. - * - * @author bjculkin - * - * @param - * The token key type. - * - * @param - * The token value type. - * - * @param - * The parser state type. - * - */ -public class ChainParseBlock implements ParseBlock { - private ParseBlock iner; - - private Set indicators; - - private Token trm; - - /** - * Create a new chain parser block. - * - * @param inner - * The block for the chains interior. - * - * @param chainIndicators - * The set of markers that indicate continuing the chain - * - * @param term - * The node in the AST for the expression. - */ - public ChainParseBlock(ParseBlock inner, Set chainIndicators, Token term) { - iner = inner; - indicators = chainIndicators; - trm = term; - } - - @Override - public CommandResult parse(ParserContext ctx) throws ParserException { - CommandResult resOuter = iner.parse(ctx); - if (resOuter.status != Status.SUCCESS) return resOuter; - - Tree> expression = resOuter.success(); - Token currentToken = ctx.tokens.current(); - if(indicators.contains(currentToken.getKey())) { - Tree> res = new SimpleTree<>(trm); - res.addChild(expression); - - while(indicators.contains(currentToken.getKey())) { - res.addChild(new SimpleTree<>(currentToken)); - ctx.tokens.next(); - - CommandResult resInner = iner.parse(ctx); - if (resInner.status != Status.SUCCESS) return resInner; - - Tree> innerExpression = resInner.success(); - res.addChild(innerExpression); - - currentToken = ctx.tokens.current(); - } - - return CommandResult.success(res); - } - - return resOuter; - } - -} -- cgit v1.2.3