diff options
author | David Robillard <d@drobilla.net> | 2010-12-30 22:35:49 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-30 22:35:49 +0000 |
commit | 766a688d8235bb69d1133496d6c70d5d40db9bdd (patch) | |
tree | d0baefa3121f396c6c09d04aff6fa9add12114d7 /src | |
parent | 4dcee9c7f9e0451ffda6880f3ca32943fb7b1ab7 (diff) | |
download | resp-766a688d8235bb69d1133496d6c70d5d40db9bdd.tar.gz resp-766a688d8235bb69d1133496d6c70d5d40db9bdd.tar.bz2 resp-766a688d8235bb69d1133496d6c70d5d40db9bdd.zip |
Pretty-print annotations.
git-svn-id: http://svn.drobilla.net/resp/resp@379 ad02d1e2-f140-0410-9f75-f8b11f17cedd
Diffstat (limited to 'src')
-rw-r--r-- | src/pprint.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/pprint.cpp b/src/pprint.cpp index ba29e3b..0ea80ef 100644 --- a/src/pprint.cpp +++ b/src/pprint.cpp @@ -35,12 +35,14 @@ newline(ostream& out, unsigned indent) } static inline void -print_annotation(ostream& out, CEnv* cenv, const AST* ast, bool print) +print_annotation(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool print) { if (print) { const AST* var = cenv->tenv.var(ast); - if (var) - out << " :" << cenv->tsubst.apply(var); + if (var) { + out << " :"; + print_to(out, cenv->tsubst.apply(var), indent + 2, cenv, print); + } } } @@ -53,7 +55,7 @@ print_list_one_line(ostream& out, const ATuple* tup, ATuple::const_iterator i, ++next; print_to(out, *i, indent, cenv, types); - print_annotation(out, cenv, *i, elem_types); + print_annotation(out, *i, indent, cenv, elem_types); if (next != tup->end()) out << " "; @@ -138,7 +140,7 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types) out << (*i++); // Print symbol unsigned child_indent = types ? indent + 2 : indent; if (types) { - print_annotation(out, cenv, tup->list_ref(2), true); + print_annotation(out, tup->list_ref(2), indent + head_width + 1, cenv, true); newline(out, child_indent); } out << " "; @@ -168,7 +170,7 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types) const ATuple* vars = (*i)->as_tuple(); for (ATuple::const_iterator v = vars->begin(); v != vars->end();) { out << (*v); - print_annotation(out, cenv, *v, types); + print_annotation(out, *v, indent, cenv, types); out << " " << (*++v); @@ -180,7 +182,7 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types) newline(out, indent + 2); print_list(out, tup, tup->iter_at(2), indent + 2, cenv, types, false); out << ")"; - print_annotation(out, cenv, tup->list_last(), types); + print_annotation(out, tup->list_last(), indent, cenv, types); } else if (form == "match") { out << (*i++); @@ -203,8 +205,6 @@ print_to(ostream& out, const AST* ast, unsigned indent, CEnv* cenv, bool types) // Print on single line if list contains only atoms print_list_one_line(out, tup, i, indent + head_width, cenv, types, false); } - if (indent == 0) - newline(out, 0); return out; } @@ -235,6 +235,6 @@ void pprint(ostream& out, const AST* ast, CEnv* cenv, bool types) { print_to(out, ast, 0, cenv, types); - print_annotation(out, cenv, ast, types); - out << endl; + print_annotation(out, ast, 0, cenv, types); + out << endl << endl; } |