diff options
| author | bjculkin <bjculkin@mix.wvu.edu> | 2018-02-15 15:25:09 -0500 |
|---|---|---|
| committer | bjculkin <bjculkin@mix.wvu.edu> | 2018-02-15 15:25:09 -0500 |
| commit | 5028ad9a1faad0e363d017f18363e8062ba59871 (patch) | |
| tree | 80df30dc24a2cd79abf7533b98fcfcd28b1f4fee /JPratt/src/main | |
| parent | 1112bb1b44bb3aabe439a2b9f88a51a9c1e435de (diff) | |
Formatting and things
Diffstat (limited to 'JPratt/src/main')
38 files changed, 310 insertions, 320 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/ParserContext.java b/JPratt/src/main/java/bjc/pratt/ParserContext.java index 1e0b054..76cdf22 100644 --- a/JPratt/src/main/java/bjc/pratt/ParserContext.java +++ b/JPratt/src/main/java/bjc/pratt/ParserContext.java @@ -8,12 +8,12 @@ import bjc.pratt.tokens.TokenStream; * @author EVE * * @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 ParserContext<K, V, C> { /** @@ -40,13 +40,13 @@ public class ParserContext<K, V, C> { * Create a new parser context. * * @param tokns - * The source of tokens. + * The source of tokens. * * @param prse - * The parser to call for sub expressions. + * The parser to call for sub expressions. * * @param stte - * Any state needing to be kept during parsing. + * Any state needing to be kept during parsing. */ public ParserContext(final TokenStream<K, V> tokns, final PrattParser<K, V, C> prse, final C stte) { tokens = tokns; diff --git a/JPratt/src/main/java/bjc/pratt/PrattParser.java b/JPratt/src/main/java/bjc/pratt/PrattParser.java index 7783736..1611ef3 100644 --- a/JPratt/src/main/java/bjc/pratt/PrattParser.java +++ b/JPratt/src/main/java/bjc/pratt/PrattParser.java @@ -21,13 +21,13 @@ import bjc.utils.parserutils.ParserException; * @author EVE * * @param <K> - * The key type for the tokens. + * The key type for the tokens. * * @param <V> - * The value type for the tokens. + * The value type for the tokens. * * @param <C> - * The state type of the parser. + * The state type of the parser. * * */ @@ -83,26 +83,25 @@ public class PrattParser<K, V, C> { * Parse an expression. * * @param precedence - * The initial precedence for the expression. + * The initial precedence for the expression. * * @param tokens - * The tokens for the expression. + * The tokens for the expression. * * @param state - * The state of the parser. + * The state of the parser. * * @param isStatement - * Whether or not to parse statements. + * Whether or not to parse statements. * * @return The expression as an AST. * * @throws ParserException - * If something goes wrong during parsing. + * If something goes wrong during parsing. */ public ITree<Token<K, V>> parseExpression(final int precedence, final TokenStream<K, V> tokens, final C state, final boolean isStatement) throws ParserException { - if (precedence < 0) - throw new IllegalArgumentException("Precedence must be greater than zero"); + if(precedence < 0) throw new IllegalArgumentException("Precedence must be greater than zero"); ParserContext<K, V, C> parserContext = new ParserContext<>(tokens, this, state); @@ -118,7 +117,7 @@ public class PrattParser<K, V, C> { int rightPrec = Integer.MAX_VALUE; - while (true) { + while(true) { final Token<K, V> tok = tokens.current(); final K key = tok.getKey(); @@ -127,7 +126,7 @@ public class PrattParser<K, V, C> { final int leftBind = leftCommand.leftBinding(); - if (NumberUtils.between(precedence, rightPrec, leftBind)) { + if(NumberUtils.between(precedence, rightPrec, leftBind)) { tokens.next(); ast = leftCommand.denote(ast, tok, parserContext); @@ -144,10 +143,10 @@ public class PrattParser<K, V, C> { * Add a non-initial command to this parser. * * @param marker - * The key that marks the command. + * The key that marks the command. * * @param comm - * The command. + * The command. */ public void addNonInitialCommand(final K marker, final NonInitialCommand<K, V, C> comm) { leftCommands.put(marker, comm); @@ -157,10 +156,10 @@ public class PrattParser<K, V, C> { * Add a initial command to this parser. * * @param marker - * The key that marks the command. + * The key that marks the command. * * @param comm - * The command. + * The command. */ public void addInitialCommand(final K marker, final InitialCommand<K, V, C> comm) { nullCommands.put(marker, comm); @@ -173,10 +172,10 @@ public class PrattParser<K, V, C> { * statements can only appear at the start of the expression. * * @param marker - * The key that marks the command. + * The key that marks the command. * * @param comm - * The command. + * The command. */ public void addStatementCommand(final K marker, final InitialCommand<K, V, C> comm) { statementCommands.put(marker, comm); @@ -186,13 +185,13 @@ public class PrattParser<K, V, C> { * Add a dependent non-initial command to this parser. * * @param dependant - * The dependent that precedes the command. + * The dependent that precedes the command. * * @param marker - * The token key that marks the command. + * The token key that marks the command. * * @param comm - * The command. + * The command. */ public void addDependantCommand(final K dependant, final K marker, final NonInitialCommand<K, V, C> comm) { Map<K, NonInitialCommand<K, V, C>> dependantMap = dependantLeftCommands.getOrDefault(dependant, @@ -205,62 +204,63 @@ public class PrattParser<K, V, C> { * Lookup an initial command. * * @param isStatement - * Whether to look for statement commands or not. + * Whether to look for statement commands or not. * * @param key - * The key of the command. + * The key of the command. * * @param ctx - * The context for meta-commands. + * The context for meta-commands. * * @return A command attached to that key, or a default implementation. */ public InitialCommand<K, V, C> getInitialCommand(boolean isStatement, K key, ParserContext<K, V, C> ctx) { - if (isStatement) { - if (metaStatementCommands.containsKey(key)) + if(isStatement) { + if(metaStatementCommands.containsKey(key)) return metaStatementCommands.get(key).getCommand(ctx); - else if (statementCommands.containsKey(key)) - return statementCommands.get(key); + else if(statementCommands.containsKey(key)) return statementCommands.get(key); } - if (metaNullCommands.containsKey(key)) + if(metaNullCommands.containsKey(key)) { return metaNullCommands.get(key).getCommand(ctx); - else - return nullCommands.getOrDefault(key, DEFAULT_NULL_COMMAND); + } + + return nullCommands.getOrDefault(key, DEFAULT_NULL_COMMAND); } /** * Lookup a non-initial command. * * @param key - * The key of the command. + * The key of the command. * * @param ctx - * The context for meta-commands. + * The context for meta-commands. * * @return A command attached to that key, or a default implementation. */ public NonInitialCommand<K, V, C> getNonInitialCommand(K key, ParserContext<K, V, C> ctx) { - if (dependantMetaLeftCommands.containsKey(ctx.initial)) { + if(dependantMetaLeftCommands.containsKey(ctx.initial)) { Map<K, MetaNonInitialCommand<K, V, C>> dependantCommands = dependantMetaLeftCommands .get(ctx.initial); - if (dependantCommands.containsKey(key)) { + if(dependantCommands.containsKey(key)) { return dependantCommands.get(key).getCommand(ctx); } } - if (dependantLeftCommands.containsKey(ctx.initial)) { + if(dependantLeftCommands.containsKey(ctx.initial)) { Map<K, NonInitialCommand<K, V, C>> dependantCommands = dependantLeftCommands.get(ctx.initial); - if (dependantCommands.containsKey(key)) { + if(dependantCommands.containsKey(key)) { return dependantCommands.getOrDefault(key, DEFAULT_LEFT_COMMAND); } } - if (metaLeftCommands.containsKey(key)) { + if(metaLeftCommands.containsKey(key)) { return metaLeftCommands.get(key).getCommand(ctx); - } else - return leftCommands.getOrDefault(key, DEFAULT_LEFT_COMMAND); + } + + return leftCommands.getOrDefault(key, DEFAULT_LEFT_COMMAND); } }
\ No newline at end of file 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) { diff --git a/JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java index c1f9f6b..9d24723 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java @@ -11,13 +11,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 abstract class AbstractInitialCommand<K, V, C> implements InitialCommand<K, V, C> { @Override diff --git a/JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java b/JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java index 06b26aa..118447e 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java @@ -12,20 +12,20 @@ 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 abstract class BinaryCommand<K, V, C> extends BinaryPostCommand<K, V, C> { /** * Create a new binary operator with the specified precedence. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. */ public BinaryCommand(final int precedence) { super(precedence); diff --git a/JPratt/src/main/java/bjc/pratt/commands/BinaryPostCommand.java b/JPratt/src/main/java/bjc/pratt/commands/BinaryPostCommand.java index 943554c..1fa1ba3 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/BinaryPostCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/BinaryPostCommand.java @@ -6,13 +6,13 @@ package bjc.pratt.commands; * @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 abstract class BinaryPostCommand<K, V, C> extends NonInitialCommand<K, V, C> { private final int leftPower; @@ -21,10 +21,10 @@ public abstract class BinaryPostCommand<K, V, C> extends NonInitialCommand<K, V, * Create a new operator with fixed precedence. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. */ public BinaryPostCommand(final int precedence) { - if (precedence < 0) throw new IllegalArgumentException("Precedence must be non-negative"); + if(precedence < 0) throw new IllegalArgumentException("Precedence must be non-negative"); leftPower = precedence; } diff --git a/JPratt/src/main/java/bjc/pratt/commands/InitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/InitialCommand.java index 57dc2d1..d0a210a 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/InitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/InitialCommand.java @@ -11,13 +11,13 @@ import bjc.utils.parserutils.ParserException; * @author EVE * * @param <K> - * The key type for the tokens. + * The key type for the tokens. * * @param <V> - * The value type for the tokens. + * The value type for the tokens. * * @param <C> - * The state type of the parser. + * The state type of the parser. * * */ @@ -27,14 +27,14 @@ public interface InitialCommand<K, V, C> { * Construct the null denotation of this command. * * @param operator - * The operator for this command. + * The operator for this command. * @param ctx - * The context for the command. + * The context for the command. * * @return The tree for this command. * * @throws ParserException - * If something goes wrong during parsing. + * If something goes wrong during parsing. */ ITree<Token<K, V>> denote(Token<K, V> operator, ParserContext<K, V, C> ctx) throws ParserException; } diff --git a/JPratt/src/main/java/bjc/pratt/commands/MetaNonInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/MetaNonInitialCommand.java index 3a5cba4..9d09eef 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/MetaNonInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/MetaNonInitialCommand.java @@ -1,21 +1,21 @@ -package bjc.pratt.commands;
-
-import bjc.pratt.ParserContext;
-
-/**
- * A 'meta-command' for non-initial commands.
- *
- * @author bjculkin
- *
- * @param <K>
- * The token key type.
- *
- * @param <V>
- * The token value type.
- *
- * @param <C>
- * The parser state type.
- */
-public interface MetaNonInitialCommand<K, V, C> {
- NonInitialCommand<K, V, C> getCommand(ParserContext<K, V, C> ctx);
-}
+package bjc.pratt.commands; + +import bjc.pratt.ParserContext; + +/** + * A 'meta-command' for non-initial commands. + * + * @author bjculkin + * + * @param <K> + * The token key type. + * + * @param <V> + * The token value type. + * + * @param <C> + * The parser state type. + */ +public interface MetaNonInitialCommand<K, V, C> { + NonInitialCommand<K, V, C> getCommand(ParserContext<K, V, C> ctx); +} diff --git a/JPratt/src/main/java/bjc/pratt/commands/NonInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/NonInitialCommand.java index d06e336..35b0825 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/NonInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/NonInitialCommand.java @@ -11,13 +11,13 @@ import bjc.utils.parserutils.ParserException; * @author EVE * * @param <K> - * The key type for the tokens. + * The key type for the tokens. * * @param <V> - * The value type for the tokens. + * The value type for the tokens. * * @param <C> - * The state type of the parser. + * The state type of the parser. * */ public abstract class NonInitialCommand<K, V, C> { @@ -25,17 +25,17 @@ public abstract class NonInitialCommand<K, V, C> { * Construct the left denotation of this command. * * @param operand - * The left-hand operand of this command. + * The left-hand operand of this command. * @param operator - * The operator for this command. + * The operator for this command. * * @param ctx - * The state needed for commands. + * The state needed for commands. * * @return The tree this command forms. * * @throws ParserException - * If something went wrong during parsing. + * If something went wrong during parsing. */ public abstract ITree<Token<K, V>> denote(ITree<Token<K, V>> operand, Token<K, V> operator, ParserContext<K, V, C> ctx) throws ParserException; diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/BlockInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/BlockInitialCommand.java index 3e8c8c2..1135ba0 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/BlockInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/BlockInitialCommand.java @@ -12,13 +12,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 BlockInitialCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { @@ -28,7 +28,7 @@ public class BlockInitialCommand<K, V, C> extends AbstractInitialCommand<K, V, C * Create a new block initial command. * * @param block - * The block to delegate to. + * The block to delegate to. */ public BlockInitialCommand(final ParseBlock<K, V, C> block) { blck = block; diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/ChainCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/ChainCommand.java index 2a9bf35..e971586 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/ChainCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/ChainCommand.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 ChainCommand<K, V, C> extends BinaryPostCommand<K, V, C> { private final Set<K> chainWith; @@ -32,13 +32,13 @@ public class ChainCommand<K, V, C> extends BinaryPostCommand<K, V, C> { * Create a new chained operator. * * @param precedence - * The precedence of this operator. + * The precedence of this operator. * * @param chainSet - * The operators to chain with. + * The operators to chain with. * * @param chainMarker - * The token to use as the node in the AST. + * The token to use as the node in the AST. */ public ChainCommand(final int precedence, final Set<K> chainSet, final Token<K, V> chainMarker) { super(precedence); @@ -55,7 +55,7 @@ public class ChainCommand<K, V, C> extends BinaryPostCommand<K, V, C> { final ITree<Token<K, V>> res = new Tree<>(operator, operand, tree); - if (chainWith.contains(ctx.tokens.current().getKey())) { + if(chainWith.contains(ctx.tokens.current().getKey())) { final Token<K, V> tok = ctx.tokens.current(); ctx.tokens.next(); diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/ConstantCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/ConstantCommand.java index 16af5aa..a3a8526 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/ConstantCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/ConstantCommand.java @@ -12,13 +12,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 ConstantCommand<K, V, C> implements InitialCommand<K, V, C> { private final ITree<Token<K, V>> val; @@ -27,7 +27,7 @@ public class ConstantCommand<K, V, C> implements InitialCommand<K, V, C> { * Create a new constant. * * @param con - * The tree this constant represents. + * The tree this constant represents. */ public ConstantCommand(final ITree<Token<K, V>> con) { val = con; diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/DefaultInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/DefaultInitialCommand.java index 16d2e59..bc00887 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/DefaultInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/DefaultInitialCommand.java @@ -12,13 +12,13 @@ import bjc.utils.parserutils.ParserException; * @author EVE * * @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. */ public class DefaultInitialCommand<K, V, C> implements InitialCommand<K, V, C> { @Override diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/DefaultNonInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/DefaultNonInitialCommand.java index 48aab29..542c8cc 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/DefaultNonInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/DefaultNonInitialCommand.java @@ -11,13 +11,13 @@ import bjc.utils.data.ITree; * @author EVE * * @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 DefaultNonInitialCommand<K, V, C> extends NonInitialCommand<K, V, C> { @Override diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java index 220e4cc..b01c413 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/DenestingCommand.java @@ -16,13 +16,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 DenestingCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { @@ -32,7 +32,7 @@ public class DenestingCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { * Create a new transforming initial command. * * @param internal - * The initial command to delegate to. + * The initial command to delegate to. */ public DenestingCommand(final InitialCommand<K, V, C> internal) { wrapped = internal; diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/GroupingCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/GroupingCommand.java index 28f1299..868260c 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/GroupingCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/GroupingCommand.java @@ -14,13 +14,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 GroupingCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { private final ParseBlock<K, V, C> innerBlock; @@ -31,10 +31,10 @@ public class GroupingCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { * Create a new grouping command. * * @param inner - * The inner block. + * The inner block. * * @param marker - * The token to use as the node in the AST. + * The token to use as the node in the AST. */ public GroupingCommand(final ParseBlock<K, V, C> inner, final Token<K, V> marker) { innerBlock = inner; diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java b/JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java index 8da758a..8967527 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/InitialCommands.java @@ -23,7 +23,7 @@ public class InitialCommands { * Create a new unary operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. * * @return A command implementing that operator. */ @@ -35,13 +35,13 @@ public class InitialCommands { * Create a new grouping operator. * * @param precedence - * The precedence of the expression in the operator. + * The precedence of the expression in the operator. * * @param term - * The type that closes the group. + * The type that closes the group. * * @param mark - * The token for the AST node of the group. + * The token for the AST node of the group. * * @return A command implementing the operator. */ @@ -65,22 +65,22 @@ public class InitialCommands { * Create a new pre-ternary operator, like an if-then-else statement. * * @param cond1 - * The priority of the first block. + * The priority of the first block. * * @param block1 - * The priority of the second block. + * The priority of the second block. * * @param block2 - * The priority of the third block. + * The priority of the third block. * * @param mark1 - * The marker that ends the first block. + * The marker that ends the first block. * * @param mark2 - * The marker that ends the second block. + * The marker that ends the second block. * * @param term - * The token for the AST node of the group. + * The token for the AST node of the group. * * @return A command implementing the operator. */ @@ -97,7 +97,7 @@ public class InitialCommands { * Create a new named constant. * * @param val - * The value of the constant. + * The value of the constant. * * @return A command implementing the constant. */ @@ -109,32 +109,28 @@ public class InitialCommands { * Create a new delimited command. This is for block-like constructs. * * @param inner - * The precedence of the inner blocks. + * The precedence of the inner blocks. * * @param delim - * The marker between sub-blocks. + * The marker between sub-blocks. * * @param mark - * The block terminator. + * The block terminator. * * @param term - * The token for the AST node of the group. + * The token for the AST node of the group. * * @param onEnter - * The function to apply to the state on entering the - * block. + * The function to apply to the state on entering the block. * * @param onDelim - * The function to apply to the state on finishing a - * sub-block. + * The function to apply to the state on finishing a sub-block. * * @param onExit - * The function to apply to the state on exiting the - * block. + * The function to apply to the state on exiting the block. * * @param statement - * Whether or not the sub-blocks are statements or - * expressions. + * Whether or not the sub-blocks are statements or expressions. * * @return A command implementing the operator. */ @@ -161,7 +157,7 @@ public class InitialCommands { * parse blocks with commands. * * @param comm - * The command to denest. + * The command to denest. * * @return A command that denests the result of the provided command. */ diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/LeafCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/LeafCommand.java index bb999f6..f0f1b55 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/LeafCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/LeafCommand.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 LeafCommand<K, V, C> implements InitialCommand<K, V, C> { @Override diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/LeftBinaryCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/LeftBinaryCommand.java index 9727dcb..9a72859 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/LeftBinaryCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/LeftBinaryCommand.java @@ -8,20 +8,20 @@ import bjc.pratt.commands.BinaryCommand; * @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 LeftBinaryCommand<K, V, C> extends BinaryCommand<K, V, C> { /** * Create a new left-associative operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. */ public LeftBinaryCommand(final int precedence) { super(precedence); diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/NonBinaryCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/NonBinaryCommand.java index 2d92780..d303663 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/NonBinaryCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/NonBinaryCommand.java @@ -8,20 +8,20 @@ import bjc.pratt.commands.BinaryCommand; * @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 NonBinaryCommand<K, V, C> extends BinaryCommand<K, V, C> { /** * Create a new non-associative operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. */ public NonBinaryCommand(final int precedence) { super(precedence); diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/NonInitialCommands.java b/JPratt/src/main/java/bjc/pratt/commands/impls/NonInitialCommands.java index a2c158c..82110b2 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/NonInitialCommands.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/NonInitialCommands.java @@ -19,7 +19,7 @@ public class NonInitialCommands { * Create a left-associative infix operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. * * @return A command implementing that operator. */ @@ -31,7 +31,7 @@ public class NonInitialCommands { * Create a right-associative infix operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. * * @return A command implementing that operator. */ @@ -43,7 +43,7 @@ public class NonInitialCommands { * Create a non-associative infix operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. * * @return A command implementing that operator. */ @@ -55,14 +55,13 @@ public class NonInitialCommands { * Create a chained operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. * * @param chainSet - * The operators it forms a chain with. + * The operators it forms a chain with. * * @param marker - * The token to use as the AST node for the chained - * operators. + * The token to use as the AST node for the chained operators. * * @return A command implementing that operator. */ @@ -75,7 +74,7 @@ public class NonInitialCommands { * Create a postfix operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. * * @return A command implementing that operator. */ @@ -89,16 +88,16 @@ public class NonInitialCommands { * This is an operator in form similar to array indexing. * * @param precedence - * The precedence of this operator + * The precedence of this operator * * @param insidePrecedence - * The precedence of the expression inside the operator + * The precedence of the expression inside the operator * * @param closer - * The token that closes the circumfix. + * The token that closes the circumfix. * * @param marker - * The token to use as the AST node for the operator. + * The token to use as the AST node for the operator. * * @return A command implementing that operator. */ @@ -115,20 +114,19 @@ public class NonInitialCommands { * This is like C's ?: operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. * * @param insidePrecedence - * The precedence of the inner section of the operator. + * The precedence of the inner section of the operator. * * @param closer - * The token that marks the end of the inner section. + * The token that marks the end of the inner section. * * @param marker - * The token to use as the AST node for the operator. + * The token to use as the AST node for the operator. * * @param nonassoc - * True if the command is non-associative, false - * otherwise. + * True if the command is non-associative, false otherwise. * * @return A command implementing this operator. */ diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/PostCircumfixCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/PostCircumfixCommand.java index c1d70b8..c6ccd2d 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/PostCircumfixCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/PostCircumfixCommand.java @@ -14,13 +14,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 PostCircumfixCommand<K, V, C> extends BinaryPostCommand<K, V, C> { private final ParseBlock<K, V, C> innerBlock; @@ -31,18 +31,18 @@ public class PostCircumfixCommand<K, V, C> extends BinaryPostCommand<K, V, C> { * Create a new post-circumfix operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. * * @param inner - * The block inside the expression. + * The block inside the expression. * * @param marker - * The token to use as the node for the AST. + * The token to use as the node for the AST. */ public PostCircumfixCommand(final int precedence, final ParseBlock<K, V, C> inner, final Token<K, V> marker) { super(precedence); - if (inner == null) throw new NullPointerException("Inner block must not be null"); + if(inner == null) throw new NullPointerException("Inner block must not be null"); innerBlock = inner; diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/PostfixCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/PostfixCommand.java index 00c7ad2..30ad9b4 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/PostfixCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/PostfixCommand.java @@ -13,20 +13,20 @@ 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 PostfixCommand<K, V, C> extends BinaryPostCommand<K, V, C> { /** * Create a new postfix operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. */ public PostfixCommand(final int precedence) { super(precedence); diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/PreTernaryCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/PreTernaryCommand.java index fa63c9c..7b33c84 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/PreTernaryCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/PreTernaryCommand.java @@ -14,13 +14,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 PreTernaryCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { private final Token<K, V> trm; @@ -34,26 +34,26 @@ public class PreTernaryCommand<K, V, C> extends AbstractInitialCommand<K, V, C> * Create a new ternary statement. * * @param cond - * The block for handling the condition. + * The block for handling the condition. * * @param op1 - * The block for handling the first operator. + * The block for handling the first operator. * * @param op2 - * The block for handling the second operator. + * The block for handling the second operator. * * @param term - * The token to use as the node for the AST. + * The token to use as the node for the AST. */ public PreTernaryCommand(final ParseBlock<K, V, C> cond, final ParseBlock<K, V, C> op1, final ParseBlock<K, V, C> op2, final Token<K, V> term) { super(); - if (cond == null) + if(cond == null) throw new NullPointerException("Cond block must not be null"); - else if (op1 == null) + else if(op1 == null) throw new NullPointerException("Op block #1 must not be null"); - else if (op2 == null) throw new NullPointerException("Op block #2 must not be null"); + else if(op2 == null) throw new NullPointerException("Op block #2 must not be null"); condBlock = cond; opblock1 = op1; diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/RightBinaryCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/RightBinaryCommand.java index c3887ee..4439930 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/RightBinaryCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/RightBinaryCommand.java @@ -8,18 +8,18 @@ import bjc.pratt.commands.BinaryCommand; * @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 RightBinaryCommand<K, V, C> extends BinaryCommand<K, V, C> { /** * Create a new right-associative operator. * * @param precedence - * The precedence of the operator. + * The precedence of the operator. */ public RightBinaryCommand(final int precedence) { super(precedence); diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/TernaryCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/TernaryCommand.java index 92355c0..988869e 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/TernaryCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/TernaryCommand.java @@ -14,13 +14,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 TernaryCommand<K, V, C> extends BinaryPostCommand<K, V, C> { private final ParseBlock<K, V, C> innerBlck; @@ -33,25 +33,24 @@ public class TernaryCommand<K, V, C> extends BinaryPostCommand<K, V, C> { * Create a new ternary command. * * @param precedence - * The precedence of this operator. + * The precedence of this operator. * * @param innerBlock - * The representation of the inner block of the - * expression. + * The representation of the inner block of the expression. * * @param marker - * The token to use as the root of the AST node. + * The token to use as the root of the AST node. * * @param isNonassoc - * Whether or not the conditional is associative. + * Whether or not the conditional is associative. */ public TernaryCommand(final int precedence, final ParseBlock<K, V, C> innerBlock, final Token<K, V> marker, final boolean isNonassoc) { super(precedence); - if (innerBlock == null) + if(innerBlock == null) throw new NullPointerException("Inner block must not be null"); - else if (marker == null) throw new NullPointerException("Marker must not be null"); + else if(marker == null) throw new NullPointerException("Marker must not be null"); innerBlck = innerBlock; mark = marker; @@ -71,7 +70,7 @@ public class TernaryCommand<K, V, C> extends BinaryPostCommand<K, V, C> { @Override public int nextBinding() { - if (nonassoc) return leftBinding() - 1; + if(nonassoc) return leftBinding() - 1; return leftBinding(); } diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/TransformingInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/TransformingInitialCommand.java index e6c509c..f09658e 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/TransformingInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/TransformingInitialCommand.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 TransformingInitialCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { private final InitialCommand<K, V, C> internl; @@ -32,10 +32,10 @@ public class TransformingInitialCommand<K, V, C> extends AbstractInitialCommand< * Create a new transforming initial command. * * @param internal - * The initial command to delegate to. + * The initial command to delegate to. * * @param transform - * The transform to apply to the returned tree. + * The transform to apply to the returned tree. */ public TransformingInitialCommand(final InitialCommand<K, V, C> internal, final UnaryOperator<ITree<Token<K, V>>> transform) { diff --git a/JPratt/src/main/java/bjc/pratt/commands/impls/UnaryCommand.java b/JPratt/src/main/java/bjc/pratt/commands/impls/UnaryCommand.java index 156dee0..15d246d 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/impls/UnaryCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/impls/UnaryCommand.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 UnaryCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { private final int nullPwer; @@ -28,10 +28,10 @@ public class UnaryCommand<K, V, C> extends AbstractInitialCommand<K, V, C> { * Create a new unary command. * * @param precedence - * The precedence of this operator. + * The precedence of this operator. */ public UnaryCommand(final int precedence) { - if (precedence < 0) throw new IllegalArgumentException("Precedence must be non-negative"); + if(precedence < 0) throw new IllegalArgumentException("Precedence must be non-negative"); nullPwer = precedence; } diff --git a/JPratt/src/main/java/bjc/pratt/tokens/StringToken.java b/JPratt/src/main/java/bjc/pratt/tokens/StringToken.java index ff47667..4f9b73a 100644 --- a/JPratt/src/main/java/bjc/pratt/tokens/StringToken.java +++ b/JPratt/src/main/java/bjc/pratt/tokens/StringToken.java @@ -14,10 +14,10 @@ public class StringToken implements Token<String, String> { * Create a new string token. * * @param ky - * The key for the token. + * The key for the token. * * @param vl - * The value for the token. + * The value for the token. */ public StringToken(final String ky, final String vl) { key = ky; @@ -47,19 +47,19 @@ public class StringToken implements Token<String, String> { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (!(obj instanceof StringToken)) return false; + if(this == obj) return true; + if(obj == null) return false; + if(!(obj instanceof StringToken)) return false; final StringToken other = (StringToken) obj; - if (key == null) { - if (other.key != null) return false; - } else if (!key.equals(other.key)) return false; + if(key == null) { + if(other.key != null) return false; + } else if(!key.equals(other.key)) return false; - if (val == null) { - if (other.val != null) return false; - } else if (!val.equals(other.val)) return false; + if(val == null) { + if(other.val != null) return false; + } else if(!val.equals(other.val)) return false; return true; } @@ -73,7 +73,7 @@ public class StringToken implements Token<String, String> { * Create a new literal token (has same key/value). * * @param val - * The value for the literal token. + * The value for the literal token. * * @return A literal token with that key. */ diff --git a/JPratt/src/main/java/bjc/pratt/tokens/StringTokenStream.java b/JPratt/src/main/java/bjc/pratt/tokens/StringTokenStream.java index 07e1827..044d19a 100644 --- a/JPratt/src/main/java/bjc/pratt/tokens/StringTokenStream.java +++ b/JPratt/src/main/java/bjc/pratt/tokens/StringTokenStream.java @@ -22,7 +22,7 @@ public class StringTokenStream extends TokenStream<String, String> { * Create a new token stream from a iterator. * * @param itr - * The iterator to use. + * The iterator to use. * */ public StringTokenStream(final Iterator<Token<String, String>> itr) { @@ -37,7 +37,7 @@ public class StringTokenStream extends TokenStream<String, String> { @Override public Token<String, String> next() { - if (iter.hasNext()) { + if(iter.hasNext()) { curr = iter.next(); } else { curr = litToken("(end)"); diff --git a/JPratt/src/main/java/bjc/pratt/tokens/Token.java b/JPratt/src/main/java/bjc/pratt/tokens/Token.java index b07d2e1..7de4ada 100644 --- a/JPratt/src/main/java/bjc/pratt/tokens/Token.java +++ b/JPratt/src/main/java/bjc/pratt/tokens/Token.java @@ -6,11 +6,11 @@ package bjc.pratt.tokens; * @author EVE * * @param <K> - * The key type of this token. Represents the type of the token. + * The key type of this token. Represents the type of the token. * * @param <V> - * The value type of this token. Represents any additional data - * for the token. + * The value type of this token. Represents any additional data for the + * token. * */ public interface Token<K, V> { diff --git a/JPratt/src/main/java/bjc/pratt/tokens/TokenStream.java b/JPratt/src/main/java/bjc/pratt/tokens/TokenStream.java index a5febcc..1c550de 100644 --- a/JPratt/src/main/java/bjc/pratt/tokens/TokenStream.java +++ b/JPratt/src/main/java/bjc/pratt/tokens/TokenStream.java @@ -14,10 +14,10 @@ import bjc.utils.parserutils.ParserException; * @author EVE * * @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. */ public abstract class TokenStream<K, V> implements Iterator<Token<K, V>> { /** @@ -33,7 +33,7 @@ public abstract class TokenStream<K, V> implements Iterator<Token<K, V>> { * Create a new exception with the specified message. * * @param msg - * The message of the exception. + * The message of the exception. */ public ExpectationException(final String msg) { super(msg); @@ -58,15 +58,15 @@ public abstract class TokenStream<K, V> implements Iterator<Token<K, V>> { * set of types, and then consuming it. * * @param expectedKeys - * The expected values + * The expected values * * @throws ExpectationException - * If the token is not one of the expected types. + * If the token is not one of the expected types. */ public void expect(final Set<K> expectedKeys) throws ExpectationException { final K curKey = current().getKey(); - if (!expectedKeys.contains(curKey)) { + if(!expectedKeys.contains(curKey)) { final String expectedList = StringUtils.toEnglishList(expectedKeys.toArray(), false); throw new ExpectationException("One of '" + expectedList + "' was expected, not " + curKey); @@ -80,10 +80,10 @@ public abstract class TokenStream<K, V> implements Iterator<Token<K, V>> { * set of types, and then consuming it. * * @param expectedKeys - * The expected values + * The expected values * * @throws ExpectationException - * If the token is not one of the expected types. + * If the token is not one of the expected types. */ @SafeVarargs public final void expect(final K... expectedKeys) throws ExpectationException { @@ -94,7 +94,7 @@ public abstract class TokenStream<K, V> implements Iterator<Token<K, V>> { * Check whether the head token is a certain type. * * @param val - * The type to check for. + * The type to check for. * * @return Whether or not the head token is of that type. */ |
