From 15a2b29e48f134bc93cfd0a3d8512001e9242f3d Mon Sep 17 00:00:00 2001 From: Benjamin Culkin Date: Mon, 3 Jun 2024 17:33:53 -0400 Subject: Rename package to new domain Rename the package to the new domain --- .../pratt/commands/impls/ConstantCommand.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 JPratt/src/main/java/com/ashardalon/pratt/commands/impls/ConstantCommand.java (limited to 'JPratt/src/main/java/com/ashardalon/pratt/commands/impls/ConstantCommand.java') diff --git a/JPratt/src/main/java/com/ashardalon/pratt/commands/impls/ConstantCommand.java b/JPratt/src/main/java/com/ashardalon/pratt/commands/impls/ConstantCommand.java new file mode 100644 index 0000000..dd80205 --- /dev/null +++ b/JPratt/src/main/java/com/ashardalon/pratt/commands/impls/ConstantCommand.java @@ -0,0 +1,43 @@ +package com.ashardalon.pratt.commands.impls; + +import com.ashardalon.pratt.ParserContext; +import com.ashardalon.pratt.commands.CommandResult; +import com.ashardalon.pratt.commands.InitialCommand; +import com.ashardalon.pratt.tokens.Token; + +import bjc.data.Tree; +import bjc.utils.parserutils.ParserException; + +/** + * A command that represents a specific tree. + * + * @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 ConstantCommand implements InitialCommand { + private final Tree> val; + + /** + * Create a new constant. + * + * @param con + * The tree this constant represents. + */ + public ConstantCommand(final Tree> con) { + val = con; + } + + @Override + public CommandResult denote(final Token operator, final ParserContext ctx) + throws ParserException { + return CommandResult.success(val); + } +} \ No newline at end of file -- cgit v1.2.3