summaryrefslogtreecommitdiff
path: root/JPratt/src/main/java/bjc/pratt/commands/impls/BlockInitialCommand.java
blob: 1d5499672b565133708b5ba146cbf52bc6f5549d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package bjc.pratt.commands.impls;

import bjc.pratt.ParserContext;
import bjc.pratt.blocks.ParseBlock;
import bjc.pratt.commands.AbstractInitialCommand;
import bjc.pratt.commands.CommandResult;
import bjc.pratt.tokens.Token;
import bjc.data.Tree;
import bjc.utils.parserutils.ParserException;

/**
 * An initial command that delegates all the work to a {@link ParseBlock}
 *
 * @author bjculkin
 * @param <K>
 *        The token key type.
 *
 * @param <V>
 *        The token value type.
 *
 * @param <C>
 *        The parser state type.
 *
 */
public class BlockInitialCommand<K, V, C> extends AbstractInitialCommand<K, V, C> {
	private final ParseBlock<K, V, C> blck;

	/**
	 * Create a new block initial command.
	 *
	 * @param block
	 *        The block to delegate to.
	 */
	public BlockInitialCommand(final ParseBlock<K, V, C> block) {
		blck = block;
	}

	@Override
	protected CommandResult<K, V> intNullDenotation(final Token<K, V> operator, final ParserContext<K, V, C> ctx)
			throws ParserException {
		return blck.parse(ctx);
	}
}