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/BranchInitialCommand.java | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 JPratt/src/main/java/com/ashardalon/pratt/commands/BranchInitialCommand.java (limited to 'JPratt/src/main/java/com/ashardalon/pratt/commands/BranchInitialCommand.java') diff --git a/JPratt/src/main/java/com/ashardalon/pratt/commands/BranchInitialCommand.java b/JPratt/src/main/java/com/ashardalon/pratt/commands/BranchInitialCommand.java new file mode 100644 index 0000000..0e17287 --- /dev/null +++ b/JPratt/src/main/java/com/ashardalon/pratt/commands/BranchInitialCommand.java @@ -0,0 +1,39 @@ +package com.ashardalon.pratt.commands; + +import java.util.Map; + +import com.ashardalon.pratt.ParserContext; +import com.ashardalon.pratt.tokens.Token; + +import bjc.utils.parserutils.ParserException; + +/** + * Represents a initial command that has a number of 'sub-commands' in the way that Go/Git CLI does. + * + * @author bjcul + * + * @param Token key type + * @param Token value type + * @param Parser context type + */ +public class BranchInitialCommand implements InitialCommand { + private Map> comMap; + + /** + * Create a new branch initial command + * + * @param mep The map containing the commands + */ + public BranchInitialCommand(Map> mep) { + this.comMap = mep; + } + + @Override + public CommandResult denote(Token operator, ParserContext ctx) throws ParserException { + Token curToken = ctx.tokens.current(); + ctx.tokens.expect(comMap.keySet()); + + return comMap.get(curToken.getKey()).denote(curToken, ctx); + } + +} -- cgit v1.2.3