xo-expression: + GeneralizedExpression pretty-printing [WIP]

This commit is contained in:
Roland Conybeare 2025-07-13 21:20:19 -05:00
commit 0b0d8ffdc0
11 changed files with 204 additions and 1 deletions

View file

@ -1,6 +1,8 @@
/* @file GeneralizedExpression.cpp */
#include "GeneralizedExpression.hpp"
#include "pretty_expression.hpp"
#include <cstdint>
namespace xo {
namespace ast {
@ -8,6 +10,20 @@ namespace xo {
GeneralizedExpression::display_string() const {
return tostr(*this);
}
std::uint32_t
GeneralizedExpression::pretty_print(ppstate * pps, bool upto) const {
// Slooooow fallback for subtypes that don't implement pretty printing support
// Currently have support for:
// - Lambda
std::uint32_t saved = pps->pos();
pps->write(display_string());
if (upto && !pps->has_margin())
return false;
return upto ? pps->scan_no_newline(saved) : true;
}
} /*namespace ast*/
} /*namespace xo*/