package bjc.pratt.commands; import java.util.Map; import bjc.pratt.ParserContext; import bjc.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); } }