...
int main()
{
char const* str = "myvalue=2*(yourvalue=1);myvalue=myvalue+1;";
typedef AstParseInfo<char const*> parse_info_t;
parse_info_t tpi =
ast_parse(str, str+strlen(str), MyGrammar(), *ch_p(' '));
typedef std::map<std::string, int> context_t;
context_t context;
int v = evaluate(tpi.nodes[0], context);
std::cout << "CONTEXT: " << std::endl;
typedef context_t::const_iterator context_iter_t;
for(context_iter_t it = context.begin(); it != context.end(); ++it)
{
std::cout
<< " '"
<< (*it).first
<< "' is "
<< (*it).second
<< std::endl;
}
}
...
debug: set 'yourvalue' to 1
debug: set 'myvalue' to 2
debug: set 'myvalue' to 3
CONTEXT:
'myvalue' is 3
'yourvalue' is 1
Press [Enter] to close the terminal ...
P.S. Наконец-то отпуск.
No comments:
Post a Comment