diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-10 16:49:54 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-04-10 16:49:54 -0400 |
| commit | 56f07e9a3aaa873fe385d224f088f048dbafa8f7 (patch) | |
| tree | 64fae78f95fd1c233689ecf3dda2e2b645bb8d33 /JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java | |
| parent | 251419e1f0ab8eb04d21287b708b06a552f4c58a (diff) | |
Cleanup
Diffstat (limited to 'JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java')
| -rw-r--r-- | JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java index acddd3b..db94034 100644 --- a/JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java +++ b/JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java @@ -10,39 +10,40 @@ import bjc.utils.parserutils.ParserException; /** * Simple implementation of {@link ParseBlock} - * + * * @author bjculkin * * @param <K> * The key type of the tokens. - * + * * @param <V> * The value type of the tokens. - * + * * @param <C> * The state type of the parser. */ public class SimpleParseBlock<K, V, C> implements ParseBlock<K, V, C> { - private int pow; + private final int pow; - private K term; + private final K term; - private Predicate<ITree<Token<K, V>>> validatr; + private final Predicate<ITree<Token<K, V>>> validatr; /** * Create a new block. - * + * * @param precedence * The precedence of this block. - * + * * @param terminator * The token type that terminates the block. If this is * null, don't check for a terminator. - * + * * @param validator * The predicate to apply to blocks. */ - public SimpleParseBlock(int precedence, K terminator, Predicate<ITree<Token<K, V>>> validator) { + public SimpleParseBlock(final int precedence, final K terminator, + final Predicate<ITree<Token<K, V>>> validator) { if (precedence < 0) throw new IllegalArgumentException("Precedence must be non-negative"); pow = precedence; @@ -51,16 +52,14 @@ public class SimpleParseBlock<K, V, C> implements ParseBlock<K, V, C> { } @Override - public ITree<Token<K, V>> parse(ParserContext<K, V, C> ctx) throws ParserException { - ITree<Token<K, V>> res = ctx.parse.parseExpression(pow, ctx.tokens, ctx.state, false); + public ITree<Token<K, V>> parse(final ParserContext<K, V, C> ctx) throws ParserException { + final ITree<Token<K, V>> res = ctx.parse.parseExpression(pow, ctx.tokens, ctx.state, false); if (term != null) { ctx.tokens.expect(term); } - if (validatr == null || validatr.test(res)) { - return res; - } + if (validatr == null || validatr.test(res)) return res; throw new ParserException("Block failed validation"); } @@ -72,18 +71,18 @@ public class SimpleParseBlock<K, V, C> implements ParseBlock<K, V, C> { int result = 1; result = prime * result + pow; - result = prime * result + ((term == null) ? 0 : term.hashCode()); + result = prime * result + (term == null ? 0 : term.hashCode()); return result; } @Override - public boolean equals(Object obj) { + public boolean equals(final Object obj) { if (this == obj) return true; if (obj == null) return false; if (!(obj instanceof SimpleParseBlock)) return false; - SimpleParseBlock<?, ?, ?> other = (SimpleParseBlock<?, ?, ?>) obj; + final SimpleParseBlock<?, ?, ?> other = (SimpleParseBlock<?, ?, ?>) obj; if (pow != other.pow) return false; |
