pretty printing -- copmlete for xo::ast::GeneralizedExpression
This commit is contained in:
parent
96aa415920
commit
2e0846823b
67 changed files with 1230 additions and 478 deletions
|
|
@ -10,66 +10,67 @@
|
|||
|
||||
namespace xo {
|
||||
namespace print {
|
||||
#ifndef ppdetail_atomic
|
||||
template <>
|
||||
struct ppdetail<xo::ref::Refcount *> {
|
||||
static bool print_upto(ppstate * pps, const xo::ref::Refcount * x) {
|
||||
return ppdetail_atomic<const xo::ref::Refcount *>::print_upto(pps, x);
|
||||
}
|
||||
static void print_pretty(ppstate * pps, const xo::ref::Refcount * x) {
|
||||
ppdetail_atomic<const xo::ref::Refcount *>::print_pretty(pps, x);
|
||||
static bool print_pretty(const ppindentinfo & ppii, const xo::ref::Refcount * x) {
|
||||
return ppdetail_atomic<const xo::ref::Refcount *>::print_pretty(ppii, x);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
struct ppdetail<rp<T>> {
|
||||
static bool print_upto(ppstate * pps, const rp<T> & x) {
|
||||
if (auto p = x.get()) {
|
||||
return ppdetail<T>::print_upto(pps, *p);
|
||||
static bool print_pretty(const ppindentinfo & ppii, const rp<T> & x) {
|
||||
if (ppii.upto()) {
|
||||
if (auto p = x.get()) {
|
||||
return ppdetail<T>::print_pretty(ppii, *p);
|
||||
} else {
|
||||
/* note: degenerate case here, since never write newline for nullptr */
|
||||
|
||||
ppii.pps()->write("<nullptr ");
|
||||
ppii.pps()->write(reflect::type_name<T>());
|
||||
ppii.pps()->write(">");
|
||||
|
||||
return ppii.pps()->has_margin();
|
||||
}
|
||||
} else {
|
||||
/* note: degenerate case here, since never write newline for nullptr */
|
||||
|
||||
pps->write("<nullptr ");
|
||||
pps->write(reflect::type_name<T>());
|
||||
pps->write(">");
|
||||
|
||||
return pps->has_margin();
|
||||
}
|
||||
}
|
||||
|
||||
static void print_pretty(ppstate * pps, const rp<T> & x) {
|
||||
if (auto p = x.get()) {
|
||||
ppdetail<T>::print_pretty(pps, *p);
|
||||
} else {
|
||||
pps->write("<nullptr ");
|
||||
pps->write(reflect::type_name<T>());
|
||||
pps->write(">");
|
||||
if (auto p = x.get()) {
|
||||
ppdetail<T>::print_pretty(ppii, *p);
|
||||
} else {
|
||||
ppii.pps()->write("<nullptr ");
|
||||
ppii.pps()->write(reflect::type_name<T>());
|
||||
ppii.pps()->write(">");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct ppdetail<bp<T>> {
|
||||
static bool print_upto(ppstate * pps, const bp<T> & x) {
|
||||
if (auto p = x.get()) {
|
||||
return ppdetail<T>::print_upto(pps, *p);
|
||||
static bool print_pretty(const ppindentinfo & ppii, const bp<T> & x) {
|
||||
if (ppii.upto()) {
|
||||
if (auto p = x.get()) {
|
||||
return ppdetail<T>::print_pretty(ppii, *p);
|
||||
} else {
|
||||
/* note: degenerate case here, since never write newline for nullptr */
|
||||
|
||||
ppii.pps()->write("<nullptr ");
|
||||
ppii.pps()->write(reflect::type_name<T>());
|
||||
ppii.pps()->write(">");
|
||||
|
||||
return ppii.pps()->has_margin();
|
||||
}
|
||||
} else {
|
||||
/* note: degenerate case here, since never write newline for nullptr */
|
||||
|
||||
pps->write("<nullptr ");
|
||||
pps->write(reflect::type_name<T>());
|
||||
pps->write(">");
|
||||
|
||||
return pps->has_margin();
|
||||
}
|
||||
}
|
||||
|
||||
static void print_pretty(ppstate * pps, const bp<T> & x) {
|
||||
if (auto p = x.get()) {
|
||||
ppdetail<T>::print_pretty(pps, *p);
|
||||
} else {
|
||||
pps->write("<nullptr ");
|
||||
pps->write(reflect::type_name<T>());
|
||||
pps->write(">");
|
||||
if (auto p = x.get()) {
|
||||
ppdetail<T>::print_pretty(ppii, *p);
|
||||
} else {
|
||||
ppii.pps()->write("<nullptr ");
|
||||
ppii.pps()->write(reflect::type_name<T>());
|
||||
ppii.pps()->write(">");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue