summaryrefslogtreecommitdiff
path: root/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
diff options
context:
space:
mode:
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;
}