summaryrefslogtreecommitdiff
path: root/JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-06-03 17:33:53 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-06-03 17:33:53 -0400
commit15a2b29e48f134bc93cfd0a3d8512001e9242f3d (patch)
treeb3f5c4c5f0e474479cd47ad0ac0f35770fc44881 /JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java
parent39ba97edf49270715ec61bedb7d4a62ada819ba0 (diff)
Rename package to new domainHEADtrunk
Rename the package to the new domain
Diffstat (limited to 'JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java')
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java85
1 files changed, 0 insertions, 85 deletions
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 <K>
- * The token key type.
- *
- * @param <V>
- * The token value type.
- *
- * @param <C>
- * The parser state type.
- *
- */
-public class ChainParseBlock<K, V, C> implements ParseBlock<K, V, C> {
- private ParseBlock<K, V, C> iner;
-
- private Set<K> indicators;
-
- private Token<K, V> 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<K, V, C> inner, Set<K> chainIndicators, Token<K, V> term) {
- iner = inner;
- indicators = chainIndicators;
- trm = term;
- }
-
- @Override
- public CommandResult<K, V> parse(ParserContext<K, V, C> ctx) throws ParserException {
- CommandResult<K,V> resOuter = iner.parse(ctx);
- if (resOuter.status != Status.SUCCESS) return resOuter;
-
- Tree<Token<K, V>> expression = resOuter.success();
- Token<K, V> currentToken = ctx.tokens.current();
- if(indicators.contains(currentToken.getKey())) {
- Tree<Token<K, V>> res = new SimpleTree<>(trm);
- res.addChild(expression);
-
- while(indicators.contains(currentToken.getKey())) {
- res.addChild(new SimpleTree<>(currentToken));
- ctx.tokens.next();
-
- CommandResult<K,V> resInner = iner.parse(ctx);
- if (resInner.status != Status.SUCCESS) return resInner;
-
- Tree<Token<K, V>> innerExpression = resInner.success();
- res.addChild(innerExpression);
-
- currentToken = ctx.tokens.current();
- }
-
- return CommandResult.success(res);
- }
-
- return resOuter;
- }
-
-}