package com.ashardalon.pratt.commands.impls; import bjc.data.Tree; import com.ashardalon.pratt.ParserContext; import com.ashardalon.pratt.commands.BinaryPostCommand; import com.ashardalon.pratt.commands.CommandResult; import com.ashardalon.pratt.tokens.Token; import bjc.data.SimpleTree; import bjc.utils.parserutils.ParserException; /** * A postfix operator. * * @author bjculkin * * @param * The key type of the tokens. * * @param * The value type of the tokens. * * @param * The state type of the parser. */ public class PostfixCommand extends BinaryPostCommand { /** * Create a new postfix operator. * * @param precedence * The precedence of the operator. */ public PostfixCommand(final int precedence) { super(precedence); } @Override public CommandResult denote(final Tree> operand, final Token operator, final ParserContext ctx) throws ParserException { return CommandResult.success(new SimpleTree<>(operator, operand)); } }