#pragma once #include #include #include typedef int (*FUNCTION)(const std::string &s); static std::vector Verbs{"Quit", "Exit", "Go", "Move", "Look"}; static std::vector Nouns{"Object", "Door", "North", "South", "East", "West", "Up", "Down", "Left", "right"}; class CommandParser { private: std::map commands; public: CommandParser(); bool AddCommand(std::string c, FUNCTION f); void RemoveCommand(std::string c); std::vector Verb(std::stringstream &sentences); std::vector Noun(std::stringstream &sentences); inline friend void swap(CommandParser& lhs, CommandParser& rhs) { using std::swap; swap(lhs.commands, rhs.commands); } static inline void CommandUnrecognized() { printf("I don't know how to do that.\n"); } int Parse(); };