From 56f07e9a3aaa873fe385d224f088f048dbafa8f7 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 10 Apr 2017 16:49:54 -0400 Subject: Cleanup --- .../java/bjc/pratt/blocks/RepeatingParseBlock.java | 40 ++++++++++++---------- 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java') diff --git a/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java index 1c82b36..7791ea9 100644 --- a/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java +++ b/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java @@ -12,49 +12,49 @@ import bjc.utils.parserutils.ParserException; /** * A parse block that can parse a sequnce of zero or more occurances of another * block. - * + * * @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 RepeatingParseBlock implements ParseBlock { - private ParseBlock innerBlock; + private final ParseBlock innerBlock; - private K delim; - private K term; + private final K delim; + private final K term; - private UnaryOperator onDelim; + private final UnaryOperator onDelim; - private Token mark; + private final Token mark; /** * Create a new repeating block. - * + * * @param inner * The inner block for elements. - * + * * @param delimiter * The token that delimits elements in the sequence. - * + * * @param terminator * The token that terminates the sequence. - * + * * @param marker * The token to use as the node in the AST. - * + * * @param action * The action to apply to the state after every * delimiter. */ - public RepeatingParseBlock(ParseBlock inner, K delimiter, K terminator, Token marker, - UnaryOperator action) { + public RepeatingParseBlock(final ParseBlock inner, final K delimiter, final K terminator, + final Token marker, final UnaryOperator action) { super(); if (inner == null) @@ -74,20 +74,22 @@ public class RepeatingParseBlock implements ParseBlock { } @Override - public ITree> parse(ParserContext ctx) throws ParserException { - ITree> ret = new Tree<>(mark); + public ITree> parse(final ParserContext ctx) throws ParserException { + final ITree> ret = new Tree<>(mark); Token tok = ctx.tokens.current(); while (!tok.getKey().equals(term)) { - ITree> kid = innerBlock.parse(ctx); + final ITree> kid = innerBlock.parse(ctx); ret.addChild(kid); tok = ctx.tokens.current(); ctx.tokens.expect(delim, term); - if (onDelim != null) ctx.state = onDelim.apply(ctx.state); + if (onDelim != null) { + ctx.state = onDelim.apply(ctx.state); + } } return ret; -- cgit v1.2.3 From f394306a4b65a3328551f9f6b8d4abff8bfd5b27 Mon Sep 17 00:00:00 2001 From: bjculkin Date: Wed, 12 Apr 2017 10:46:51 -0400 Subject: Package reorganization --- JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java') diff --git a/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java index 7791ea9..4146648 100644 --- a/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java +++ b/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java @@ -2,9 +2,8 @@ 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.data.Tree; import bjc.utils.parserutils.ParserException; -- cgit v1.2.3