xo-expression: + GeneralizedExpression pretty-printing [WIP]
This commit is contained in:
parent
55602c83cc
commit
0b0d8ffdc0
11 changed files with 204 additions and 1 deletions
|
|
@ -1,9 +1,13 @@
|
|||
/* @file Lambda.cpp */
|
||||
|
||||
#include "Lambda.hpp"
|
||||
#include "exprtype.hpp"
|
||||
#include "pretty_expression.hpp"
|
||||
#include "xo/reflect/TypeDescr.hpp"
|
||||
#include "xo/reflect/function/FunctionTdx.hpp"
|
||||
#include "xo/indentlog/print/vector.hpp"
|
||||
#include "xo/indentlog/print/pretty_vector.hpp"
|
||||
#include "xo/indentlog/print/pretty_tag.hpp"
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
|
|
@ -317,6 +321,50 @@ namespace xo {
|
|||
<< ">";
|
||||
} /*display*/
|
||||
|
||||
std::uint32_t
|
||||
Lambda::pretty_print(ppstate * pps, bool upto) const
|
||||
{
|
||||
if (upto) {
|
||||
std::uint32_t saved = pps->pos();
|
||||
|
||||
if (!pps->has_margin())
|
||||
return false;
|
||||
|
||||
if (!pps->print_upto("<Lambda"))
|
||||
return false;
|
||||
|
||||
if (!pps->print_upto(xtag("name", name_)))
|
||||
return false;
|
||||
|
||||
if (!pps->print_upto(xtag("argv", local_env_->argv())))
|
||||
return false;
|
||||
|
||||
if (!pps->print_upto(xtag("body", body_)))
|
||||
return false;
|
||||
|
||||
pps->write(">");
|
||||
|
||||
return pps->scan_no_newline(saved);
|
||||
} else {
|
||||
std::uint32_t ci0 = pps->lpos();
|
||||
std::uint32_t ci1 = ci0 + pps->indent_width();
|
||||
|
||||
pps->write("<Lambda");
|
||||
|
||||
pps->newline_indent(ci1);
|
||||
pps->pretty(xtag("name", name_));
|
||||
|
||||
pps->newline_indent(ci1);
|
||||
pps->pretty(xtag("argv", local_env_->argv()));
|
||||
|
||||
pps->newline_indent(ci1);
|
||||
pps->pretty(xtag("body", body_));
|
||||
pps->write(">");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Lambda Access -----
|
||||
|
||||
rp<LambdaAccess>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue