diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-02-20 20:44:59 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-02-20 20:44:59 -0800 |
commit | 791c5eb1398bff36c74b1f7581ddff70d298cbc5 (patch) | |
tree | a782dba0829ef439ee3691cfd54100972c77d623 /059shape_shifting_recipe.cc | |
parent | 65c905fe84c0e8b7acd6839469d7bb9727f0632b (diff) | |
download | mu-791c5eb1398bff36c74b1f7581ddff70d298cbc5.tar.gz |
2679
Diffstat (limited to '059shape_shifting_recipe.cc')
-rw-r--r-- | 059shape_shifting_recipe.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/059shape_shifting_recipe.cc b/059shape_shifting_recipe.cc index e8c3fcdf..79f4094c 100644 --- a/059shape_shifting_recipe.cc +++ b/059shape_shifting_recipe.cc @@ -430,6 +430,28 @@ void replace_type_ingredients(string_tree* type, const map<string, const string_ replace_type_ingredients(type->right, mappings); } +string inspect(const string_tree* x) { + ostringstream out; + dump_inspect(x, out); + return out.str(); +} + +void dump_inspect(const string_tree* x, ostream& out) { + if (!x->left && !x->right) { + out << x->value; + return; + } + out << '('; + for (const string_tree* curr = x; curr; curr = curr->right) { + if (curr != x) out << ' '; + if (curr->left) + dump_inspect(curr->left, out); + else + out << curr->value; + } + out << ')'; +} + void ensure_all_concrete_types(/*const*/ recipe& new_recipe, const recipe& exemplar) { for (long long int i = 0; i < SIZE(new_recipe.ingredients); ++i) ensure_all_concrete_types(new_recipe.ingredients.at(i), exemplar); |