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
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "Variable.hpp"
|
||||
#include "Environment.hpp"
|
||||
#include "pretty_expression.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace ast {
|
||||
|
|
@ -37,6 +38,59 @@ namespace xo {
|
|||
os << xtag("type", "nullptr");
|
||||
os << ">";
|
||||
} /*display*/
|
||||
|
||||
std::uint32_t
|
||||
Variable::pretty_print(const ppindentinfo & ppii) const {
|
||||
/* 1. rtag instead of refrtag:
|
||||
* print::quot() is a temporary rvalue; lifetime ends before control enters pretty_struct()
|
||||
*/
|
||||
return ppii.pps()->pretty_struct(ppii, "Variable",
|
||||
refrtag("name", name_),
|
||||
rtag("type", print::quot(this->valuetype()
|
||||
? this->valuetype()->short_name()
|
||||
: "nullptr")));
|
||||
|
||||
#ifdef OBSOLETE
|
||||
ppstate * pps = ppii.pps();
|
||||
|
||||
if (ppii.upto()) {
|
||||
if (!pps->print_upto("<Variable"))
|
||||
return false;
|
||||
|
||||
if (!pps->print_upto_tag("name", name_))
|
||||
return false;
|
||||
|
||||
if (this->valuetype()) {
|
||||
if (!pps->print_upto_tag("type", this->valuetype()->short_name()))
|
||||
return false;
|
||||
} else {
|
||||
if (!pps->print_upto_tag("type", "nullptr"))
|
||||
return false;
|
||||
}
|
||||
|
||||
pps->write(">");
|
||||
|
||||
return true;
|
||||
} else {
|
||||
pps->write("<Variable");
|
||||
|
||||
pps->newline_pretty_tag(ppii.ci1(), "name", name_);
|
||||
|
||||
/* use tag instead of rtag for type,
|
||||
* since not guaranteed to print machine-readably
|
||||
*/
|
||||
if (this->valuetype()) {
|
||||
pps->newline_indent(ppii.ci1());
|
||||
pps->pretty(xtag("type", this->valuetype()->short_name()));
|
||||
} else {
|
||||
pps->newline_pretty_tag(ppii.ci1(), "type", "nullptr");
|
||||
}
|
||||
pps->write(">");
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} /*namespace ast*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue