From 5028ad9a1faad0e363d017f18363e8062ba59871 Mon Sep 17 00:00:00 2001 From: bjculkin Date: Thu, 15 Feb 2018 15:25:09 -0500 Subject: Formatting and things --- .../java/bjc/pratt/blocks/ChainParseBlock.java | 16 +++++----- .../java/bjc/pratt/blocks/GrammarParseBlock.java | 12 ++++---- .../src/main/java/bjc/pratt/blocks/ParseBlock.java | 12 ++++---- .../main/java/bjc/pratt/blocks/ParseBlocks.java | 30 +++++++++---------- .../java/bjc/pratt/blocks/RepeatingParseBlock.java | 27 +++++++++-------- .../java/bjc/pratt/blocks/SimpleParseBlock.java | 34 +++++++++++----------- .../java/bjc/pratt/blocks/TriggeredParseBlock.java | 12 ++++---- 7 files changed, 70 insertions(+), 73 deletions(-) (limited to 'JPratt/src/main/java/bjc/pratt/blocks') 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 - * The token key type. + * The token key type. * * @param - * The token value type. + * The token value type. * * @param - * The parser state type. + * The parser state type. * */ public class ChainParseBlock implements ParseBlock { @@ -36,13 +36,13 @@ public class ChainParseBlock implements ParseBlock { * 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 inner, Set chainIndicators, Token term) { iner = inner; @@ -55,11 +55,11 @@ public class ChainParseBlock implements ParseBlock { ITree> expression = iner.parse(ctx); Token currentToken = ctx.tokens.current(); - if (indicators.contains(currentToken.getKey())) { + if(indicators.contains(currentToken.getKey())) { ITree> 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 - * The key type of the outer tokens. + * The key type of the outer tokens. * * @param - * The value type of the outer tokens. + * The value type of the outer tokens. * * @param - * The state type of the outer parser. + * The state type of the outer parser. * * @param - * The key type of the inner tokens. + * The key type of the inner tokens. * * @param - * The value type of the inner tokens. + * The value type of the inner tokens. * * @param - * The state type of the outer parser. + * The state type of the outer parser. */ public class GrammarParseBlock implements ParseBlock { private final PrattParser 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 - * The key type of the token. + * The key type of the token. * * @param - * The value type of the token. + * The value type of the token. * * @param - * The state type of the parser. + * The state type of the parser. */ @FunctionalInterface public interface ParseBlock { @@ -26,13 +26,13 @@ public interface ParseBlock { * 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> parse(ParserContext 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 - * The key type of the tokens. + * The key type of the tokens. * * @param - * The value type of the tokens. + * The value type of the tokens. * * @param - * The state type of the parser. + * The state type of the parser. */ public class RepeatingParseBlock implements ParseBlock { private final ParseBlock innerBlock; @@ -37,30 +37,29 @@ public class RepeatingParseBlock implements ParseBlock { * 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 inner, final K delimiter, final K terminator, final Token marker, final UnaryOperator 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 implements ParseBlock { Token tok = ctx.tokens.current(); - while (!tok.getKey().equals(term)) { + while(!tok.getKey().equals(term)) { final ITree> kid = innerBlock.parse(ctx); ret.addChild(kid); @@ -86,7 +85,7 @@ public class RepeatingParseBlock implements ParseBlock { 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 - * The key type of the tokens. + * The key type of the tokens. * * @param - * The value type of the tokens. + * The value type of the tokens. * * @param - * The state type of the parser. + * The state type of the parser. */ public class SimpleParseBlock implements ParseBlock { private final int pow; @@ -32,16 +32,16 @@ public class SimpleParseBlock implements ParseBlock { * 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>> 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 implements ParseBlock { public ITree> parse(final ParserContext ctx) throws ParserException { final ITree> 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 implements ParseBlock { @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 - * The key type of the tokens. + * The key type of the tokens. * @param - * The value type of the tokens. + * The value type of the tokens. * @param - * The state type of the parser. + * The state type of the parser. */ public class TriggeredParseBlock implements ParseBlock { private final UnaryOperator onEntr; @@ -29,13 +29,13 @@ public class TriggeredParseBlock implements ParseBlock { * 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 onEnter, final UnaryOperator onExit, final ParseBlock source) { -- cgit v1.2.3