xo-reader2 xo-expression2: pprint for DDefineExpr + DVariable
This commit is contained in:
parent
ca2be0172a
commit
480294ae05
21 changed files with 455 additions and 8 deletions
|
|
@ -5,8 +5,12 @@
|
|||
|
||||
#include "ParserStack.hpp"
|
||||
#include "SyntaxStateMachine.hpp"
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::print::APrintable;
|
||||
using xo::facet::FacetRegistry;
|
||||
using xo::facet::typeseq;
|
||||
|
||||
namespace scm {
|
||||
|
|
@ -41,6 +45,48 @@ namespace xo {
|
|||
return stack->parent();
|
||||
}
|
||||
|
||||
void
|
||||
ParserStack::print(std::ostream & os) const
|
||||
{
|
||||
os << "<ParserStack>";
|
||||
os << xtag("ssm", "*placeholder*");
|
||||
os << xtag("parent", "*placeholder*");
|
||||
os << ">";
|
||||
}
|
||||
|
||||
bool
|
||||
ParserStack::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
auto * pps = ppii.pps();
|
||||
|
||||
/* always use multiple lines */
|
||||
|
||||
if (ppii.upto())
|
||||
return false;
|
||||
|
||||
pps->write("<ParserStack");
|
||||
|
||||
const ParserStack * frame = this;
|
||||
std::size_t i_frame = 0;
|
||||
|
||||
while (frame) {
|
||||
char buf[80];
|
||||
snprintf(buf, sizeof(buf), "[%lu]", i_frame);
|
||||
|
||||
auto ssm = FacetRegistry::instance().variant<APrintable,
|
||||
ASyntaxStateMachine> (frame->top());
|
||||
|
||||
pps->newline_pretty_tag(ppii.ci1(), buf, ssm);
|
||||
|
||||
++i_frame;
|
||||
frame = frame->parent_;
|
||||
}
|
||||
|
||||
pps->write(">");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue