summaryrefslogtreecommitdiff
path: root/JPratt/src/main/java/bjc/pratt/blocks
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2018-02-15 15:25:09 -0500
committerbjculkin <bjculkin@mix.wvu.edu>2018-02-15 15:25:09 -0500
commit5028ad9a1faad0e363d017f18363e8062ba59871 (patch)
tree80df30dc24a2cd79abf7533b98fcfcd28b1f4fee /JPratt/src/main/java/bjc/pratt/blocks
parent1112bb1b44bb3aabe439a2b9f88a51a9c1e435de (diff)
Formatting and things
Diffstat (limited to 'JPratt/src/main/java/bjc/pratt/blocks')
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java16
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java12
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/ParseBlock.java12
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java30
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java27
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java34
-rw-r--r--JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java12
7 files changed, 70 insertions, 73 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java
index 5c728d9..c7710dc 100644
--- a/JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java
+++ b/JPratt/src/main/java/bjc/pratt/blocks/ChainParseBlock.java
@@ -16,13 +16,13 @@ import bjc.utils.parserutils.ParserException;
* @author bjculkin
*
* @param <K>
- * The token key type.
+ * The token key type.
*
* @param <V>
- * The token value type.
+ * The token value type.
*
* @param <C>
- * The parser state type.
+ * The parser state type.
*
*/
public class ChainParseBlock<K, V, C> implements ParseBlock<K, V, C> {
@@ -36,13 +36,13 @@ public class ChainParseBlock<K, V, C> implements ParseBlock<K, V, C> {
* Create a new chain parser block.
*
* @param inner
- * The block for the chains interior.
+ * The block for the chains interior.
*
* @param chainIndicators
- * The set of markers that indicate continuing the chain
+ * The set of markers that indicate continuing the chain
*
* @param term
- * The node in the AST for the expression.
+ * The node in the AST for the expression.
*/
public ChainParseBlock(ParseBlock<K, V, C> inner, Set<K> chainIndicators, Token<K, V> term) {
iner = inner;
@@ -55,11 +55,11 @@ public class ChainParseBlock<K, V, C> implements ParseBlock<K, V, C> {
ITree<Token<K, V>> expression = iner.parse(ctx);
Token<K, V> currentToken = ctx.tokens.current();
- if (indicators.contains(currentToken.getKey())) {
+ if(indicators.contains(currentToken.getKey())) {
ITree<Token<K, V>> res = new Tree<>(trm);
res.addChild(expression);
- while (indicators.contains(currentToken.getKey())) {
+ while(indicators.contains(currentToken.getKey())) {
res.addChild(new Tree<>(currentToken));
ctx.tokens.next();
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java
index 6bf5582..dcc8a8e 100644
--- a/JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java
+++ b/JPratt/src/main/java/bjc/pratt/blocks/GrammarParseBlock.java
@@ -16,22 +16,22 @@ import bjc.utils.parserutils.ParserException;
* @author bjculkin
*
* @param <K>
- * The key type of the outer tokens.
+ * The key type of the outer tokens.
*
* @param <V>
- * The value type of the outer tokens.
+ * The value type of the outer tokens.
*
* @param <C>
- * The state type of the outer parser.
+ * The state type of the outer parser.
*
* @param <K2>
- * The key type of the inner tokens.
+ * The key type of the inner tokens.
*
* @param <V2>
- * The value type of the inner tokens.
+ * The value type of the inner tokens.
*
* @param <C2>
- * The state type of the outer parser.
+ * The state type of the outer parser.
*/
public class GrammarParseBlock<K, V, C, K2, V2, C2> implements ParseBlock<K, V, C> {
private final PrattParser<K2, V2, C2> innr;
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/ParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/ParseBlock.java
index 2fddac0..b12b391 100644
--- a/JPratt/src/main/java/bjc/pratt/blocks/ParseBlock.java
+++ b/JPratt/src/main/java/bjc/pratt/blocks/ParseBlock.java
@@ -11,13 +11,13 @@ import bjc.utils.parserutils.ParserException;
* @author bjculkin
*
* @param <K>
- * The key type of the token.
+ * The key type of the token.
*
* @param <V>
- * The value type of the token.
+ * The value type of the token.
*
* @param <C>
- * The state type of the parser.
+ * The state type of the parser.
*/
@FunctionalInterface
public interface ParseBlock<K, V, C> {
@@ -26,13 +26,13 @@ public interface ParseBlock<K, V, C> {
* Parse the block this represents.
*
* @param ctx
- * The context for parsing.
+ * The context for parsing.
*
* @return A AST for this block.
*
* @throws ParserException
- * If something goes wrong during parsing, or the block
- * fails validation.
+ * If something goes wrong during parsing, or the block fails
+ * validation.
*/
ITree<Token<K, V>> parse(ParserContext<K, V, C> ctx) throws ParserException;
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java b/JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java
index 21fa7e1..e2344ac 100644
--- a/JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java
+++ b/JPratt/src/main/java/bjc/pratt/blocks/ParseBlocks.java
@@ -21,20 +21,19 @@ public class ParseBlocks {
* Create a new repeating parse block.
*
* @param inner
- * The parse block to repeat.
+ * The parse block to repeat.
*
* @param delim
- * The token type that separates repetitions.
+ * The token type that separates repetitions.
*
* @param term
- * The token type that terminates repetitions.
+ * The token type that terminates repetitions.
*
* @param mark
- * The token to use as the node in the AST.
+ * The token to use as the node in the AST.
*
* @param action
- * The action to perform on the state after every
- * repetition.
+ * The action to perform on the state after every repetition.
*
* @return A configured repeating parse block.
*/
@@ -47,15 +46,14 @@ public class ParseBlocks {
* Create a new triggered parse block.
*
* @param source
- * The block to trigger around.
+ * The block to trigger around.
*
* @param onEnter
- * The action to perform upon the state before entering
- * the block.
+ * The action to perform upon the state before entering the
+ * block.
*
* @param onExit
- * The action to perform upon the state after exiting the
- * block.
+ * The action to perform upon the state after exiting the block.
*
* @return A configured trigger parse block.
*/
@@ -68,15 +66,15 @@ public class ParseBlocks {
* Create a new simple parse block.
*
* @param precedence
- * The precedence of the expression inside the block.
+ * The precedence of the expression inside the block.
*
* @param terminator
- * The key type of the token expected after this block,
- * or null if none is expected.
+ * The key type of the token expected after this block, or null
+ * if none is expected.
*
* @param validator
- * The predicate to use to validate parsed expressions,
- * or null if none is used.
+ * The predicate to use to validate parsed expressions, or null
+ * if none is used.
*
* @return A configured simple parse block.
*/
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java
index 4146648..3673f5f 100644
--- a/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java
+++ b/JPratt/src/main/java/bjc/pratt/blocks/RepeatingParseBlock.java
@@ -15,13 +15,13 @@ import bjc.utils.parserutils.ParserException;
* @author bjculkin
*
* @param <K>
- * The key type of the tokens.
+ * The key type of the tokens.
*
* @param <V>
- * The value type of the tokens.
+ * The value type of the tokens.
*
* @param <C>
- * The state type of the parser.
+ * The state type of the parser.
*/
public class RepeatingParseBlock<K, V, C> implements ParseBlock<K, V, C> {
private final ParseBlock<K, V, C> innerBlock;
@@ -37,30 +37,29 @@ public class RepeatingParseBlock<K, V, C> implements ParseBlock<K, V, C> {
* Create a new repeating block.
*
* @param inner
- * The inner block for elements.
+ * The inner block for elements.
*
* @param delimiter
- * The token that delimits elements in the sequence.
+ * The token that delimits elements in the sequence.
*
* @param terminator
- * The token that terminates the sequence.
+ * The token that terminates the sequence.
*
* @param marker
- * The token to use as the node in the AST.
+ * The token to use as the node in the AST.
*
* @param action
- * The action to apply to the state after every
- * delimiter.
+ * The action to apply to the state after every delimiter.
*/
public RepeatingParseBlock(final ParseBlock<K, V, C> inner, final K delimiter, final K terminator,
final Token<K, V> marker, final UnaryOperator<C> action) {
super();
- if (inner == null)
+ if(inner == null)
throw new NullPointerException("Inner block must not be null");
- else if (delimiter == null)
+ else if(delimiter == null)
throw new NullPointerException("Delimiter must not be null");
- else if (terminator == null) throw new NullPointerException("Terminator must not be null");
+ else if(terminator == null) throw new NullPointerException("Terminator must not be null");
innerBlock = inner;
@@ -78,7 +77,7 @@ public class RepeatingParseBlock<K, V, C> implements ParseBlock<K, V, C> {
Token<K, V> tok = ctx.tokens.current();
- while (!tok.getKey().equals(term)) {
+ while(!tok.getKey().equals(term)) {
final ITree<Token<K, V>> kid = innerBlock.parse(ctx);
ret.addChild(kid);
@@ -86,7 +85,7 @@ public class RepeatingParseBlock<K, V, C> implements ParseBlock<K, V, C> {
ctx.tokens.expect(delim, term);
- if (onDelim != null) {
+ if(onDelim != null) {
ctx.state = onDelim.apply(ctx.state);
}
}
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java
index 1ff561c..4148472 100644
--- a/JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java
+++ b/JPratt/src/main/java/bjc/pratt/blocks/SimpleParseBlock.java
@@ -13,13 +13,13 @@ import bjc.utils.parserutils.ParserException;
* @author bjculkin
*
* @param <K>
- * The key type of the tokens.
+ * The key type of the tokens.
*
* @param <V>
- * The value type of the tokens.
+ * The value type of the tokens.
*
* @param <C>
- * The state type of the parser.
+ * The state type of the parser.
*/
public class SimpleParseBlock<K, V, C> implements ParseBlock<K, V, C> {
private final int pow;
@@ -32,16 +32,16 @@ public class SimpleParseBlock<K, V, C> implements ParseBlock<K, V, C> {
* Create a new block.
*
* @param precedence
- * The precedence of this block.
+ * The precedence of this block.
* @param validator
- * The predicate to apply to blocks.
+ * The predicate to apply to blocks.
* @param terminator
- * The token type that terminates the block. If this is
- * null, don't check for a terminator.
+ * The token type that terminates the block. If this is null,
+ * don't check for a terminator.
*/
public SimpleParseBlock(final int precedence, final Predicate<ITree<Token<K, V>>> validator,
final K terminator) {
- if (precedence < 0) throw new IllegalArgumentException("Precedence must be non-negative");
+ if(precedence < 0) throw new IllegalArgumentException("Precedence must be non-negative");
pow = precedence;
term = terminator;
@@ -52,11 +52,11 @@ public class SimpleParseBlock<K, V, C> implements ParseBlock<K, V, C> {
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) {
+ 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");
}
@@ -75,17 +75,17 @@ public class SimpleParseBlock<K, V, C> implements ParseBlock<K, V, C> {
@Override
public boolean equals(final Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (!(obj instanceof SimpleParseBlock)) return false;
+ if(this == obj) return true;
+ if(obj == null) return false;
+ if(!(obj instanceof SimpleParseBlock)) return false;
final SimpleParseBlock<?, ?, ?> other = (SimpleParseBlock<?, ?, ?>) obj;
- if (pow != other.pow) return false;
+ if(pow != other.pow) return false;
- if (term == null) {
- if (other.term != null) return false;
- } else if (!term.equals(other.term)) return false;
+ if(term == null) {
+ if(other.term != null) return false;
+ } else if(!term.equals(other.term)) return false;
return true;
}
diff --git a/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java b/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
index 844a4f8..3acd602 100644
--- a/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
+++ b/JPratt/src/main/java/bjc/pratt/blocks/TriggeredParseBlock.java
@@ -13,11 +13,11 @@ import bjc.utils.parserutils.ParserException;
* @author bjculkin
*
* @param <K>
- * The key type of the tokens.
+ * The key type of the tokens.
* @param <V>
- * The value type of the tokens.
+ * The value type of the tokens.
* @param <C>
- * The state type of the parser.
+ * The state type of the parser.
*/
public class TriggeredParseBlock<K, V, C> implements ParseBlock<K, V, C> {
private final UnaryOperator<C> onEntr;
@@ -29,13 +29,13 @@ public class TriggeredParseBlock<K, V, C> implements ParseBlock<K, V, C> {
* Create a new triggered parse block.
*
* @param onEnter
- * The action to fire before parsing the block.
+ * The action to fire before parsing the block.
*
* @param onExit
- * The action to fire after parsing the block.
+ * The action to fire after parsing the block.
*
* @param source
- * The block to use for parsing.
+ * The block to use for parsing.
*/
public TriggeredParseBlock(final UnaryOperator<C> onEnter, final UnaryOperator<C> onExit,
final ParseBlock<K, V, C> source) {