Last active
January 29, 2017 14:29
-
-
Save deque-blog/fdac42fab6e01b233f380f2004a2727c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename Tag> | |
std::string print_op(op<Tag, std::string> const& e, std::string const& op_repr) | |
{ | |
return std::string("(") + op_repr + " " + boost::algorithm::join(e.rands(), " ") + ")"; | |
} | |
std::string print_alg(expression_r<std::string> const& e) | |
{ | |
if (auto* o = get_as_add(e)) return print_op(*o, "+"); | |
if (auto* o = get_as_mul(e)) return print_op(*o, "*"); | |
if (auto* i = get_as_cst(e)) return std::to_string(*i); | |
if (auto* v = get_as_var(e)) return *v; | |
throw_missing_pattern_matching_clause(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment