summaryrefslogtreecommitdiff
path: root/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
diff options
context:
space:
mode:
authorStudent <student@Administrators-iMac-2.local>2017-04-12 11:05:57 -0400
committerStudent <student@Administrators-iMac-2.local>2017-04-12 11:05:57 -0400
commit22c356cd411cf0fcc18d548291af26bc7588a3aa (patch)
tree4f24fdda182b358ca96aed2249bb4e8a19994747 /JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
parent2dc1b5dd145ab0e2b3e3df67f967a9c07ed6d303 (diff)
parentf394306a4b65a3328551f9f6b8d4abff8bfd5b27 (diff)
Merge branch 'master' of https://github.com/bculkin2442/JPratt.git
Diffstat (limited to 'JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java')
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
index 5e561fc..844a4f8 100644
--- a/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
+++ b/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
@@ -2,15 +2,14 @@ package bjc.pratt.blocks;
import java.util.function.UnaryOperator;
-import bjc.pratt.ParseBlock;
import bjc.pratt.ParserContext;
-import bjc.pratt.Token;
+import bjc.pratt.tokens.Token;
import bjc.utils.data.ITree;
import bjc.utils.parserutils.ParserException;
/**
* A parse block that can adjust the state before handling its context.
- *
+ *
* @author bjculkin
*
* @param <K>
@@ -21,39 +20,39 @@ import bjc.utils.parserutils.ParserException;
* The state type of the parser.
*/
public class TriggeredParseBlock<K, V, C> implements ParseBlock<K, V, C> {
- private UnaryOperator<C> onEnter;
- private UnaryOperator<C> onExit;
+ private final UnaryOperator<C> onEntr;
+ private final UnaryOperator<C> onExt;
- private ParseBlock<K, V, C> source;
+ private final ParseBlock<K, V, C> 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(UnaryOperator<C> onEnter, UnaryOperator<C> onExit, ParseBlock<K, V, C> source) {
- super();
- this.onEnter = onEnter;
- this.onExit = onExit;
- this.source = source;
+ public TriggeredParseBlock(final UnaryOperator<C> onEnter, final UnaryOperator<C> onExit,
+ final ParseBlock<K, V, C> source) {
+ onEntr = onEnter;
+ onExt = onExit;
+ sourc = source;
}
@Override
- public ITree<Token<K, V>> parse(ParserContext<K, V, C> ctx) throws ParserException {
- C newState = onEnter.apply(ctx.state);
+ public ITree<Token<K, V>> parse(final ParserContext<K, V, C> ctx) throws ParserException {
+ final C newState = onEntr.apply(ctx.state);
- ParserContext<K, V, C> newCtx = new ParserContext<>(ctx.tokens, ctx.parse, newState);
+ final ParserContext<K, V, C> newCtx = new ParserContext<>(ctx.tokens, ctx.parse, newState);
- ITree<Token<K, V>> res = source.parse(newCtx);
+ final ITree<Token<K, V>> res = sourc.parse(newCtx);
- ctx.state = onExit.apply(newState);
+ ctx.state = onExt.apply(newState);
return res;
}