-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterpreter.cpp
More file actions
32 lines (23 loc) · 888 Bytes
/
interpreter.cpp
File metadata and controls
32 lines (23 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "interpreter.hpp"
namespace example {
void interpreter::parse_input(std::string const & text) const
{
boost::char_separator<char> s(" ,()\t\n\r");
//boost::escaped_list_separator<char> s;
token_parser parser
( boost::make_token_iterator<std::string>(text.begin(), text.end(), s)
, boost::make_token_iterator<std::string>(text.end() , text.end(), s) );
while (parser.has_more_tokens())
{
// read function name
std::string func_name = parser.get<std::string>();
// look up function
dictionary::const_iterator entry = map_invokers.find( func_name );
if (entry == map_invokers.end())
//throw std::runtime_error("unknown function: " + func_name);
throw NotAFunction(func_name);
// call the invoker which controls argument parsing
entry->second(parser);
}
}
} // namespace example