void do_op(char C) { switch(C) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': push(C-'0'); break; case '+': addition(); break; case '-': subtraction(); break; case '*': multiplication(); break; case '/': division(); break; case '%': modulo(); break; case '^': north(); break; case '>': east(); break; case 'V': case 'v': south(); break; case '<': west(); break; case '?': spin(); break; case '!': lnot(); break; case '`': gt(); break; case '_': hif(); break; case '|': vif(); break; case '"': tsm(); break; case ':': dup(); break; case '\\': swap(); break; case '$': chomp(); break; case '#': jump(); break; case 'p': put(); break; case 'g': get(); break; case 'H': gate(); break; case '.': print_i(); break; case ',': print_c(); break; case '&': input_i(); break; case '~': input_c(); break; case '@': hacf(); break; case '{': left_b(); break; case '}': right_b(); break; case '[': carry_l(); break; case ']': carry_r(); break; case ';': empty(); break; case 'O': portal_o(); break; case 'B': portal_b(); break; default: /* DO NOTHING! */ break; } }
int main() { { node::ptr_t left_d(create_left_tree_from("d")); boost::coroutines::coroutine<std::string>::pull_type left_d_reader( [&]( boost::coroutines::coroutine<std::string>::push_type & out) { traverse(left_d,out); }); std::cout << "left tree from d:\n"; std::copy(std::begin(left_d_reader), std::end(left_d_reader), std::ostream_iterator<std::string>(std::cout, " ")); std::cout << std::endl; node::ptr_t right_b(create_right_tree_from("b")); boost::coroutines::coroutine<std::string>::pull_type right_b_reader( [&]( boost::coroutines::coroutine<std::string>::push_type & out) { traverse(right_b,out); }); std::cout << "right tree from b:\n"; std::copy(std::begin(right_b_reader), std::end(right_b_reader), std::ostream_iterator<std::string>(std::cout, " ")); std::cout << std::endl; node::ptr_t right_x(create_right_tree_from("x")); boost::coroutines::coroutine<std::string>::pull_type right_x_reader( [&]( boost::coroutines::coroutine<std::string>::push_type & out) { traverse(right_x,out); }); std::cout << "right tree from x:\n"; std::copy(std::begin(right_x_reader), std::end(right_x_reader), std::ostream_iterator<std::string>(std::cout, " ")); std::cout << std::endl; } { node::ptr_t left_d(create_left_tree_from("d")); boost::coroutines::coroutine<std::string>::pull_type left_d_reader( [&]( boost::coroutines::coroutine<std::string>::push_type & out) { traverse(left_d,out); }); node::ptr_t right_b(create_right_tree_from("b")); boost::coroutines::coroutine<std::string>::pull_type right_b_reader( [&]( boost::coroutines::coroutine<std::string>::push_type & out) { traverse(right_b,out); }); std::cout << "left tree from d == right tree from b? " << std::boolalpha << std::equal(std::begin(left_d_reader), std::end(left_d_reader), std::begin(right_b_reader)) << std::endl; } { node::ptr_t left_d(create_left_tree_from("d")); boost::coroutines::coroutine<std::string>::pull_type left_d_reader( [&]( boost::coroutines::coroutine<std::string>::push_type & out) { traverse(left_d,out); }); node::ptr_t right_x(create_right_tree_from("x")); boost::coroutines::coroutine<std::string>::pull_type right_x_reader( [&]( boost::coroutines::coroutine<std::string>::push_type & out) { traverse(right_x,out); }); std::cout << "left tree from d == right tree from x? " << std::boolalpha << std::equal(std::begin(left_d_reader), std::end(left_d_reader), std::begin(right_x_reader)) << std::endl; } std::cout << "Done" << std::endl; return EXIT_SUCCESS; }