2026-08-07 13:10:07 -05:00
|
|
|
#pragma once
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2026-08-21 15:52:12 -05:00
|
|
|
typedef int (*FUNCTION)(const std::string &s);
|
2026-08-07 13:10:07 -05:00
|
|
|
|
|
|
|
|
static std::vector<std::string> Verbs{"Quit", "Exit", "Go", "Move", "Look"};
|
2026-09-11 16:07:17 -05:00
|
|
|
static std::vector<std::string> Nouns{"Object", "Door", "North", "South", "East", "West",
|
|
|
|
|
"Up", "Down", "Left", "Right", "To", "At"};
|
2026-08-07 13:10:07 -05:00
|
|
|
|
|
|
|
|
class CommandParser {
|
|
|
|
|
private:
|
|
|
|
|
std::map<std::string, FUNCTION> commands;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
CommandParser();
|
|
|
|
|
|
|
|
|
|
bool AddCommand(std::string c, FUNCTION f);
|
|
|
|
|
void RemoveCommand(std::string c);
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> Verb(std::stringstream &sentences);
|
|
|
|
|
std::vector<std::string> Noun(std::stringstream &sentences);
|
|
|
|
|
|
|
|
|
|
static inline void CommandUnrecognized() { printf("I don't know how to do that.\n"); }
|
|
|
|
|
int Parse();
|
|
|
|
|
};
|