diff options
Diffstat (limited to 'JPratt/src')
| -rw-r--r-- | JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java | 27 | ||||
| -rw-r--r-- | JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java | 21 |
2 files changed, 34 insertions, 14 deletions
diff --git a/JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java b/JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java index d8fd6b9..43abd96 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/AbstractInitialCommand.java @@ -11,22 +11,35 @@ 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 - public ITree<Token<K, V>> denote(final Token<K, V> operator, final ParserContext<K, V, C> ctx) - throws ParserException { + public ITree<Token<K, V>> denote(final Token<K, V> operator, + final ParserContext<K, V, C> ctx) throws ParserException { return intNullDenotation(operator, ctx); } - protected abstract ITree<Token<K, V>> intNullDenotation(Token<K, V> operator, ParserContext<K, V, C> ctx) - throws ParserException; + /** + * Internal null denotation method. + * + * @param operator + * The operator that was parsed. + * @param ctx + * The parser context at this point. + * + * @return The tree that this method parsed. + * + * @throws ParserException + * If something went wrong while parsing. + */ + protected abstract ITree<Token<K, V>> intNullDenotation(Token<K, V> operator, + ParserContext<K, V, C> ctx) throws ParserException; }
\ No newline at end of file diff --git a/JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java b/JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java index 9cc4dc1..0b790ff 100644 --- a/JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java +++ b/JPratt/src/main/java/bjc/pratt/commands/BinaryCommand.java @@ -12,31 +12,38 @@ 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); } + /** + * The right-binding power (right-precedence) of this command. + * + * @return The right binding power of this command. + */ protected abstract int rightBinding(); @Override - 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>> opr = ctx.parse.parseExpression(rightBinding(), 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>> opr + = ctx.parse.parseExpression(rightBinding(), ctx.tokens, ctx.state, false); return new Tree<>(operator, operand, opr); } |
