xo-reader2: formatting + asserts
This commit is contained in:
parent
3f8a57cef5
commit
1e83e9aaba
9 changed files with 47 additions and 39 deletions
|
|
@ -75,23 +75,36 @@ namespace xo {
|
||||||
bool
|
bool
|
||||||
DDefineExpr::pretty(const ppindentinfo & ppii) const
|
DDefineExpr::pretty(const ppindentinfo & ppii) const
|
||||||
{
|
{
|
||||||
|
assert(lhs_var_);
|
||||||
|
|
||||||
auto lhs = obj<APrintable,DVariable>(lhs_var_);
|
auto lhs = obj<APrintable,DVariable>(lhs_var_);
|
||||||
auto rhs = FacetRegistry::instance().try_variant<APrintable,
|
auto rhs = FacetRegistry::instance().try_variant<APrintable,
|
||||||
AExpression>(rhs_);
|
AExpression>(rhs_);
|
||||||
|
|
||||||
|
if (lhs_var_)
|
||||||
|
assert(lhs.data());
|
||||||
|
|
||||||
|
(void)lhs;
|
||||||
|
(void)rhs;
|
||||||
|
|
||||||
|
if (rhs_)
|
||||||
|
assert(rhs.data());
|
||||||
|
|
||||||
// note: xo::print::cond() doesn't resolve the way we want here
|
// note: xo::print::cond() doesn't resolve the way we want here
|
||||||
|
|
||||||
if (rhs) {
|
if (rhs) {
|
||||||
return ppii.pps()->pretty_struct
|
return ppii.pps()->pretty_struct
|
||||||
(ppii,
|
(ppii,
|
||||||
"DDefineExpr",
|
"DDefineExpr"
|
||||||
refrtag("lhs", lhs),
|
, refrtag("lhs", lhs)
|
||||||
refrtag("rhs", rhs));
|
, refrtag("rhs", rhs)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return ppii.pps()->pretty_struct
|
return ppii.pps()->pretty_struct
|
||||||
(ppii,
|
(ppii,
|
||||||
"DDefineExpr",
|
"DDefineExpr"
|
||||||
refrtag("lhs", lhs));
|
, refrtag("lhs", lhs)
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,10 @@ namespace xo {
|
||||||
|
|
||||||
return ppii.pps()->pretty_struct
|
return ppii.pps()->pretty_struct
|
||||||
(ppii,
|
(ppii,
|
||||||
"DVariable",
|
"DVariable"
|
||||||
refrtag("name", quot(name)),
|
, refrtag("name", quot(name))
|
||||||
refrtag("typeref", typeref_));
|
, refrtag("typeref", typeref_)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "TypeRef.hpp"
|
#include "TypeRef.hpp"
|
||||||
|
#include <xo/indentlog/print/cond.hpp>
|
||||||
#include <xo/indentlog/print/pretty.hpp>
|
#include <xo/indentlog/print/pretty.hpp>
|
||||||
#include <xo/indentlog/print/quoted.hpp>
|
#include <xo/indentlog/print/quoted.hpp>
|
||||||
|
|
||||||
|
|
@ -71,9 +72,10 @@ namespace xo {
|
||||||
|
|
||||||
return ppii.pps()->pretty_struct
|
return ppii.pps()->pretty_struct
|
||||||
(ppii,
|
(ppii,
|
||||||
"TypeRef",
|
"TypeRef"
|
||||||
refrtag("id", quot(id_)),
|
, refrtag("id", quot(id_))
|
||||||
refrtag("td", td_));
|
, refrtag("td", cond(td_, td_, "null"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
|
|
|
||||||
|
|
@ -733,13 +733,18 @@ namespace xo {
|
||||||
bool
|
bool
|
||||||
DDefineSsm::pretty(const ppindentinfo & ppii) const
|
DDefineSsm::pretty(const ppindentinfo & ppii) const
|
||||||
{
|
{
|
||||||
auto expr = FacetRegistry::instance().variant<APrintable,AExpression>(def_expr_);
|
auto expr
|
||||||
|
= FacetRegistry::instance().variant<APrintable,
|
||||||
|
AExpression>(def_expr_);
|
||||||
|
assert(expr.data());
|
||||||
|
(void)expr;
|
||||||
|
|
||||||
return ppii.pps()->pretty_struct
|
return ppii.pps()->pretty_struct
|
||||||
(ppii,
|
(ppii,
|
||||||
"DDefineSsm",
|
"DDefineSsm",
|
||||||
refrtag("defstate", defstate_),
|
refrtag("defstate", defstate_),
|
||||||
refrtag("def_expr", expr));
|
refrtag("def_expr", expr)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,8 @@ namespace xo {
|
||||||
(ppii,
|
(ppii,
|
||||||
"DExpectExprSsm",
|
"DExpectExprSsm",
|
||||||
refrtag("allow_defs", allow_defs_),
|
refrtag("allow_defs", allow_defs_),
|
||||||
refrtag("cxl_on_rightbrace", cxl_on_rightbrace_));
|
refrtag("cxl_on_rightbrace", cxl_on_rightbrace_)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NOT_YET
|
#ifdef NOT_YET
|
||||||
|
|
|
||||||
|
|
@ -1115,32 +1115,16 @@ namespace xo {
|
||||||
if (rhs_)
|
if (rhs_)
|
||||||
rhs = FacetRegistry::instance().variant<APrintable,AExpression>(rhs_);
|
rhs = FacetRegistry::instance().variant<APrintable,AExpression>(rhs_);
|
||||||
|
|
||||||
|
(void)lhs;
|
||||||
|
|
||||||
return ppii.pps()->pretty_struct
|
return ppii.pps()->pretty_struct
|
||||||
(ppii,
|
(ppii,
|
||||||
"DProgressSsm",
|
"DProgressSsm",
|
||||||
refrtag("lhs", lhs),
|
refrtag("lhs", lhs),
|
||||||
refrtag("op", op_type_),
|
refrtag("op", op_type_),
|
||||||
cond(rhs, refrtag("rhs", rhs), "nullptr"));
|
cond(rhs, refrtag("rhs", rhs), "nullptr")
|
||||||
|
);
|
||||||
|
|
||||||
#ifdef NOPE
|
|
||||||
if (ppii.upto()) {
|
|
||||||
return (ppii.pps()->print_upto("<progress_xs")
|
|
||||||
&& (lhs_ ? ppii.pps()->print_upto(refrtag("lhs", lhs_)) : true)
|
|
||||||
&& (op_type_ != optype::invalid ? ppii.pps()->print_upto(refrtag("op", op_type_)) : true)
|
|
||||||
&& (rhs_ ? ppii.pps()->print_upto(refrtag("rhs", rhs_)) : true)
|
|
||||||
&& ppii.pps()->print_upto(">"));
|
|
||||||
} else {
|
|
||||||
ppii.pps()->write("<progress_xs ");
|
|
||||||
if (lhs_)
|
|
||||||
ppii.pps()->pretty(refrtag("lhs", lhs_));
|
|
||||||
if (op_type_ != optype::invalid)
|
|
||||||
ppii.pps()->pretty(refrtag("op", op_type_));
|
|
||||||
if (rhs_)
|
|
||||||
ppii.pps()->pretty(refrtag("rhs", rhs_));
|
|
||||||
ppii.pps()->write(">");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
obj<AExpression>
|
obj<AExpression>
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,9 @@ namespace xo {
|
||||||
char buf[80];
|
char buf[80];
|
||||||
snprintf(buf, sizeof(buf), "[%lu]", i_frame);
|
snprintf(buf, sizeof(buf), "[%lu]", i_frame);
|
||||||
|
|
||||||
auto ssm = FacetRegistry::instance().variant<APrintable,
|
auto ssm = (FacetRegistry::instance().variant
|
||||||
ASyntaxStateMachine> (frame->top());
|
<APrintable, ASyntaxStateMachine> (frame->top()));
|
||||||
|
assert(ssm.data());
|
||||||
|
|
||||||
pps->newline_pretty_tag(ppii.ci1(), buf, ssm);
|
pps->newline_pretty_tag(ppii.ci1(), buf, ssm);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,8 @@ namespace xo {
|
||||||
return pps->pretty_struct
|
return pps->pretty_struct
|
||||||
(ppii,
|
(ppii,
|
||||||
"SchematikaParser",
|
"SchematikaParser",
|
||||||
refrtag("stack", psm_.stack()));
|
refrtag("stack", psm_.stack())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ namespace xo {
|
||||||
using xo::scm::SchematikaParser;
|
using xo::scm::SchematikaParser;
|
||||||
using xo::scm::ASyntaxStateMachine;
|
using xo::scm::ASyntaxStateMachine;
|
||||||
using xo::scm::syntaxstatetype;
|
using xo::scm::syntaxstatetype;
|
||||||
using xo::scm::DDefineSsm;
|
// using xo::scm::DDefineSsm;
|
||||||
using xo::scm::DExpectExprSsm;
|
using xo::scm::DExpectExprSsm;
|
||||||
using xo::scm::defexprstatetype;
|
// using xo::scm::defexprstatetype;
|
||||||
//using xo::scm::ParserResult;
|
//using xo::scm::ParserResult;
|
||||||
//using xo::scm::parser_result_type;
|
//using xo::scm::parser_result_type;
|
||||||
using xo::scm::Token;
|
using xo::scm::Token;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue