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
|
|
@ -6,6 +6,9 @@
|
|||
#include "DDefineSsm.hpp"
|
||||
#include "DExpectSymbolSsm.hpp"
|
||||
#include "ssm/ISyntaxStateMachine_DDefineSsm.hpp"
|
||||
#include "ssm/IPrintable_DDefineSsm.hpp"
|
||||
#include <xo/expression2/detail/IPrintable_DDefineExpr.hpp>
|
||||
#include <xo/printable2/Printable.hpp>
|
||||
|
||||
#ifdef NOT_YET
|
||||
#include "parserstatemachine.hpp"
|
||||
|
|
@ -16,6 +19,7 @@
|
|||
#endif
|
||||
|
||||
namespace xo {
|
||||
using xo::print::APrintable;
|
||||
using xo::facet::with_facet;
|
||||
using xo::facet::typeseq;
|
||||
|
||||
|
|
@ -497,10 +501,13 @@ namespace xo {
|
|||
bool
|
||||
DDefineSsm::pretty(const ppindentinfo & ppii) const
|
||||
{
|
||||
auto expr = with_facet<APrintable>::mkobj(def_expr_.data());
|
||||
|
||||
return ppii.pps()->pretty_struct
|
||||
(ppii,
|
||||
"DDefineSsm",
|
||||
refrtag("defstate", defstate_));
|
||||
refrtag("defstate", defstate_),
|
||||
refrtag("def_expr", expr));
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
|
|
|||
|
|
@ -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*/
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,28 @@ namespace xo {
|
|||
<< xtag("has_stack", (psm_.stack() != nullptr))
|
||||
<< ">" << std::endl;
|
||||
}
|
||||
|
||||
bool
|
||||
SchematikaParser::pretty(const ppindentinfo & ppii) const {
|
||||
auto * pps = ppii.pps();
|
||||
|
||||
if (ppii.upto())
|
||||
return false;
|
||||
|
||||
// TODO: consider printing:
|
||||
// psm.stringtable_
|
||||
// psm.parser_alloc_
|
||||
// psm.parser_alloc_ckp_
|
||||
// psm.expr_alloc_
|
||||
// psm.result_
|
||||
// psm.debug_flag_
|
||||
//
|
||||
|
||||
return pps->pretty_struct
|
||||
(ppii,
|
||||
"SchematikaParser",
|
||||
refrtag("stack", psm_.stack()));
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue