package bjc.pratt.commands.impls; import bjc.pratt.ParserContext; import bjc.pratt.commands.AbstractInitialCommand; import bjc.pratt.commands.InitialCommand; import bjc.pratt.tokens.Token; import bjc.data.Tree; import bjc.utils.parserutils.ParserException; /** * A command that denests a input tree. * * Useful for processing the result of passing a complex parse group to a * command. * * @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 DenestingCommand extends AbstractInitialCommand { private final InitialCommand wrapped; /** * Create a new transforming initial command. * * @param internal * The initial command to delegate to. */ public DenestingCommand(final InitialCommand internal) { wrapped = internal; } @Override protected Tree> intNullDenotation(final Token operator, final ParserContext ctx) throws ParserException { return wrapped.denote(operator, ctx).getChild(0); } }