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

@ -11,19 +11,28 @@ namespace xo {
return tostr(*this);
}
#ifdef SUPERSEDED // currently all derived expression types support pretty printing
std::uint32_t
GeneralizedExpression::pretty_print(ppstate * pps, bool upto) const {
GeneralizedExpression::pretty_print(const ppindentinfo & ppii) const {
// Slooooow fallback for subtypes that don't implement pretty printing support
// Currently have support for:
// - Variable
// - Lambda
// - DefineExpr
// - Sequence
// - Apply
// - Primitive
// - IfExpr
ppstate * pps = ppii.pps();
std::uint32_t saved = pps->pos();
pps->write(display_string());
if (upto && !pps->has_margin())
if (ppii.upto() && !pps->has_margin())
return false;
return upto ? pps->scan_no_newline(saved) : true;
return ppii.upto() ? pps->scan_no_newline(saved) : true;
}
#endif
} /*namespace ast*/
} /*namespace xo*/