xo-reader2 xo-expression2: define example working and printing
def foo : f64 = 3.141593;
This commit is contained in:
parent
15e1e50659
commit
f6224eefea
2 changed files with 32 additions and 3 deletions
|
|
@ -11,6 +11,7 @@
|
||||||
#include "ssm/IPrintable_DDefineSsm.hpp"
|
#include "ssm/IPrintable_DDefineSsm.hpp"
|
||||||
#include <xo/expression2/detail/IPrintable_DDefineExpr.hpp>
|
#include <xo/expression2/detail/IPrintable_DDefineExpr.hpp>
|
||||||
#include <xo/printable2/Printable.hpp>
|
#include <xo/printable2/Printable.hpp>
|
||||||
|
#include <xo/facet/FacetRegistry.hpp>
|
||||||
|
|
||||||
#ifdef NOT_YET
|
#ifdef NOT_YET
|
||||||
#include "parserstatemachine.hpp"
|
#include "parserstatemachine.hpp"
|
||||||
|
|
@ -22,6 +23,7 @@
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
using xo::print::APrintable;
|
using xo::print::APrintable;
|
||||||
|
using xo::facet::FacetRegistry;
|
||||||
using xo::facet::with_facet;
|
using xo::facet::with_facet;
|
||||||
using xo::facet::typeseq;
|
using xo::facet::typeseq;
|
||||||
|
|
||||||
|
|
@ -617,7 +619,7 @@ namespace xo {
|
||||||
bool
|
bool
|
||||||
DDefineSsm::pretty(const ppindentinfo & ppii) const
|
DDefineSsm::pretty(const ppindentinfo & ppii) const
|
||||||
{
|
{
|
||||||
auto expr = with_facet<APrintable>::mkobj(def_expr_.data());
|
auto expr = FacetRegistry::instance().variant<APrintable,AExpression>(def_expr_);
|
||||||
|
|
||||||
return ppii.pps()->pretty_struct
|
return ppii.pps()->pretty_struct
|
||||||
(ppii,
|
(ppii,
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,10 @@
|
||||||
|
|
||||||
#include "DProgressSsm.hpp"
|
#include "DProgressSsm.hpp"
|
||||||
#include "ssm/ISyntaxStateMachine_DProgressSsm.hpp"
|
#include "ssm/ISyntaxStateMachine_DProgressSsm.hpp"
|
||||||
|
#include <xo/printable2/Printable.hpp>
|
||||||
|
#include <xo/facet/FacetRegistry.hpp>
|
||||||
#include <xo/reflectutil/typeseq.hpp>
|
#include <xo/reflectutil/typeseq.hpp>
|
||||||
|
#include <xo/indentlog/print/cond.hpp>
|
||||||
|
|
||||||
#ifdef NOT_YET
|
#ifdef NOT_YET
|
||||||
#include "apply_xs.hpp"
|
#include "apply_xs.hpp"
|
||||||
|
|
@ -25,6 +28,8 @@ namespace xo {
|
||||||
using xo::scm::Variable;
|
using xo::scm::Variable;
|
||||||
using xo::scm::Apply;
|
using xo::scm::Apply;
|
||||||
#endif
|
#endif
|
||||||
|
using xo::print::APrintable;
|
||||||
|
using xo::facet::FacetRegistry;
|
||||||
using xo::facet::with_facet;
|
using xo::facet::with_facet;
|
||||||
using xo::reflect::typeseq;
|
using xo::reflect::typeseq;
|
||||||
|
|
||||||
|
|
@ -211,12 +216,23 @@ namespace xo {
|
||||||
DProgressSsm::on_semicolon_token(const Token & tk,
|
DProgressSsm::on_semicolon_token(const Token & tk,
|
||||||
ParserStateMachine * p_psm)
|
ParserStateMachine * p_psm)
|
||||||
{
|
{
|
||||||
|
constexpr bool c_debug_flag = true;
|
||||||
|
scope log(XO_DEBUG(c_debug_flag));
|
||||||
|
|
||||||
/* note: implementation should parallel .on_rightparen_token() */
|
/* note: implementation should parallel .on_rightparen_token() */
|
||||||
|
|
||||||
(void)tk;
|
(void)tk;
|
||||||
|
|
||||||
obj<AExpression> expr = this->assemble_expr(p_psm);
|
obj<AExpression> expr = this->assemble_expr(p_psm);
|
||||||
|
|
||||||
|
{
|
||||||
|
obj<APrintable> expr_pr = FacetRegistry::instance().variant<APrintable,AExpression>(expr);
|
||||||
|
|
||||||
|
assert(expr_pr);
|
||||||
|
|
||||||
|
log && log(xtag("expr", expr_pr));
|
||||||
|
}
|
||||||
|
|
||||||
p_psm->pop_ssm();
|
p_psm->pop_ssm();
|
||||||
p_psm->on_parsed_expression_with_semicolon(expr);
|
p_psm->on_parsed_expression_with_semicolon(expr);
|
||||||
|
|
||||||
|
|
@ -951,12 +967,23 @@ namespace xo {
|
||||||
bool
|
bool
|
||||||
DProgressSsm::pretty(const xo::print::ppindentinfo & ppii) const
|
DProgressSsm::pretty(const xo::print::ppindentinfo & ppii) const
|
||||||
{
|
{
|
||||||
|
scope log(XO_DEBUG(true));
|
||||||
|
log && log(xtag("lhs_.tseq", lhs_._typeseq()));
|
||||||
|
log && log(xtag("rhs_.tseq", rhs_._typeseq()));
|
||||||
|
|
||||||
|
obj<APrintable> lhs
|
||||||
|
= FacetRegistry::instance().variant<APrintable,AExpression>(lhs_);
|
||||||
|
|
||||||
|
obj<APrintable> rhs;
|
||||||
|
if (rhs_)
|
||||||
|
rhs = FacetRegistry::instance().variant<APrintable,AExpression>(rhs_);
|
||||||
|
|
||||||
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_),
|
||||||
refrtag("rhs", rhs_));
|
cond(rhs, refrtag("rhs", rhs), "nullptr"));
|
||||||
|
|
||||||
#ifdef NOPE
|
#ifdef NOPE
|
||||||
if (ppii.upto()) {
|
if (ppii.upto()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue