pretty printing -- copmlete for xo::ast::GeneralizedExpression

This commit is contained in:
Roland Conybeare 2025-07-19 11:47:03 -05:00
commit 2e0846823b
67 changed files with 1230 additions and 478 deletions

View file

@ -4,6 +4,8 @@
*/
#include "envframestack.hpp"
#include "pretty_envframestack.hpp"
#include "pretty_localenv.hpp"
namespace xo {
using xo::ast::LocalEnv;
@ -92,6 +94,45 @@ namespace xo {
os << ">" << std::endl;
}
bool
envframestack::pretty_print(const ppindentinfo & ppii) const
{
ppstate * pps = ppii.pps();
if (ppii.upto()) {
if (stack_.size() > 1)
return false;
if (!pps->print_upto("<envframestack"))
return false;
if (!pps->print_upto_tag("size", stack_.size()))
return false;
if ((stack_.size() > 0)
&& !pps->print_upto_tag("[0]", stack_[0]))
{
return false;
}
pps->write(">");
return true;
} else {
pps->write("<envframestack");
pps->newline_pretty_tag(ppii.ci1(), "size", stack_.size());
for (std::size_t i = 0, z = stack_.size(); i < z; ++i) {
std::string i_str = tostr("[", z-i-1, "]");
pps->newline_pretty_tag(ppii.ci1(), i_str, stack_[i]);
}
pps->write(">");
return false;
}
}
} /*namespace scm*/
} /*namespace xo*/