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/commands/ChainCommand.java | |
| parent | 251419e1f0ab8eb04d21287b708b06a552f4c58a (diff) | |
Cleanup
Diffstat (limited to 'JPratt/src/main/java/bjc/pratt/commands/ChainCommand.java')
| -rw-r--r-- | JPratt/src/main/java/bjc/pratt/commands/ChainCommand.java | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/commands/ChainCommand.java b/JPratt/src/main/java/bjc/pratt/commands/ChainCommand.java index 6ab126a..4e471d0 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/ChainCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/ChainCommand.java @@ -1,45 +1,45 @@ package bjc.pratt.commands; +import java.util.Set; + import bjc.pratt.ParserContext; import bjc.pratt.Token; import bjc.utils.data.ITree; import bjc.utils.data.Tree; import bjc.utils.parserutils.ParserException; -import java.util.Set; - /** * Create a new chained operator. - * + * * @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 ChainCommand<K, V, C> extends BinaryPostCommand<K, V, C> { - private Set<K> chainWith; + private final Set<K> chainWith; - private Token<K, V> chain; + private final Token<K, V> chain; /** * Create a new chained operator. - * + * * @param precedence * The precedence of this operator. - * + * * @param chainSet * The operators to chain with. - * + * * @param chainMarker * The token to use as the node in the AST. */ - public ChainCommand(int precedence, Set<K> chainSet, Token<K, V> chainMarker) { + public ChainCommand(final int precedence, final Set<K> chainSet, final Token<K, V> chainMarker) { super(precedence); chainWith = chainSet; @@ -47,17 +47,18 @@ public class ChainCommand<K, V, C> extends BinaryPostCommand<K, V, C> { } @Override - public ITree<Token<K, V>> denote(ITree<Token<K, V>> operand, Token<K, V> operator, ParserContext<K, V, C> ctx) - throws ParserException { - ITree<Token<K, V>> tree = ctx.parse.parseExpression(1 + leftBinding(), ctx.tokens, ctx.state, false); + public ITree<Token<K, V>> denote(final ITree<Token<K, V>> operand, final Token<K, V> operator, + final ParserContext<K, V, C> ctx) throws ParserException { + final ITree<Token<K, V>> tree = ctx.parse.parseExpression(1 + leftBinding(), ctx.tokens, ctx.state, + false); - ITree<Token<K, V>> res = new Tree<>(operator, operand, tree); + final ITree<Token<K, V>> res = new Tree<>(operator, operand, tree); if (chainWith.contains(ctx.tokens.current().getKey())) { - Token<K, V> tok = ctx.tokens.current(); + final Token<K, V> tok = ctx.tokens.current(); ctx.tokens.next(); - ITree<Token<K, V>> other = denote(tree, tok, + final ITree<Token<K, V>> other = denote(tree, tok, new ParserContext<>(ctx.tokens, ctx.parse, ctx.state)); return new Tree<>(chain, res, other); |
