xo-reader2: formatting + asserts

This commit is contained in:
Roland Conybeare 2026-01-26 21:36:10 -05:00
commit 5033b65ef2
3 changed files with 27 additions and 11 deletions

View file

@ -75,23 +75,36 @@ namespace xo {
bool
DDefineExpr::pretty(const ppindentinfo & ppii) const
{
assert(lhs_var_);
auto lhs = obj<APrintable,DVariable>(lhs_var_);
auto rhs = FacetRegistry::instance().try_variant<APrintable,
AExpression>(rhs_);
if (lhs_var_)
assert(lhs.data());
(void)lhs;
(void)rhs;
if (rhs_)
assert(rhs.data());
// note: xo::print::cond() doesn't resolve the way we want here
if (rhs) {
return ppii.pps()->pretty_struct
(ppii,
"DDefineExpr",
refrtag("lhs", lhs),
refrtag("rhs", rhs));
"DDefineExpr"
, refrtag("lhs", lhs)
, refrtag("rhs", rhs)
);
} else {
return ppii.pps()->pretty_struct
(ppii,
"DDefineExpr",
refrtag("lhs", lhs));
"DDefineExpr"
, refrtag("lhs", lhs)
);
}
}

View file

@ -47,9 +47,10 @@ namespace xo {
return ppii.pps()->pretty_struct
(ppii,
"DVariable",
refrtag("name", quot(name)),
refrtag("typeref", typeref_));
"DVariable"
, refrtag("name", quot(name))
, refrtag("typeref", typeref_)
);
}
} /*namespace scm*/

View file

@ -4,6 +4,7 @@
**/
#include "TypeRef.hpp"
#include <xo/indentlog/print/cond.hpp>
#include <xo/indentlog/print/pretty.hpp>
#include <xo/indentlog/print/quoted.hpp>
@ -71,9 +72,10 @@ namespace xo {
return ppii.pps()->pretty_struct
(ppii,
"TypeRef",
refrtag("id", quot(id_)),
refrtag("td", td_));
"TypeRef"
, refrtag("id", quot(id_))
, refrtag("td", cond(td_, td_, "null"))
);
}
} /*namespace scm*/