Refactor the AST pretty-printing functions.