From dc056cbc37792fe0daf78ceef38cc7c5e0890870 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 28 Jul 2025 15:16:11 -0400 Subject: [PATCH] minor logging adds --- .../include/xo/expression/pretty_expression.hpp | 1 + xo-expression/include/xo/expression/pretty_localenv.hpp | 7 +++++++ xo-expression/include/xo/expression/pretty_variable.hpp | 9 ++++++++- .../include/xo/indentlog/print/ppdetail_atomic.hpp | 2 +- xo-reader/include/xo/reader/parser.hpp | 1 + xo-reader/src/reader/exprstate.cpp | 3 +-- xo-reader/src/reader/lambda_xs.cpp | 4 +++- xo-reader/src/reader/reader.cpp | 5 +++++ 8 files changed, 27 insertions(+), 5 deletions(-) diff --git a/xo-expression/include/xo/expression/pretty_expression.hpp b/xo-expression/include/xo/expression/pretty_expression.hpp index a4e07a84..066ce379 100644 --- a/xo-expression/include/xo/expression/pretty_expression.hpp +++ b/xo-expression/include/xo/expression/pretty_expression.hpp @@ -26,5 +26,6 @@ namespace xo { return x.pretty_print(ppii); } }; + } } diff --git a/xo-expression/include/xo/expression/pretty_localenv.hpp b/xo-expression/include/xo/expression/pretty_localenv.hpp index 275ec095..7a09b187 100644 --- a/xo-expression/include/xo/expression/pretty_localenv.hpp +++ b/xo-expression/include/xo/expression/pretty_localenv.hpp @@ -8,6 +8,13 @@ namespace xo { namespace print { + template <> + struct ppdetail { + static bool print_pretty(const ppindentinfo & ppii, const xo::scm::Environment & x) { + return x.pretty_print(ppii); + } + }; + template <> struct ppdetail { static bool print_pretty(const ppindentinfo & ppii, const xo::scm::LocalEnv & x) { diff --git a/xo-expression/include/xo/expression/pretty_variable.hpp b/xo-expression/include/xo/expression/pretty_variable.hpp index d0440b8e..c53c11a3 100644 --- a/xo-expression/include/xo/expression/pretty_variable.hpp +++ b/xo-expression/include/xo/expression/pretty_variable.hpp @@ -12,9 +12,16 @@ namespace xo { namespace print { template <> struct ppdetail { - static bool print_pretty(const ppindentinfo & ppii, const xo::scm::Expression & x) { + static bool print_pretty(const ppindentinfo & ppii, const xo::scm::Variable & x) { return x.pretty_print(ppii); } }; + + template <> + struct ppdetail { + static bool print_pretty(const ppindentinfo & ppii, const xo::scm::Variable * x) { + return x->pretty_print(ppii); + } + }; } } diff --git a/xo-indentlog/include/xo/indentlog/print/ppdetail_atomic.hpp b/xo-indentlog/include/xo/indentlog/print/ppdetail_atomic.hpp index dfeaf415..3f460a76 100644 --- a/xo-indentlog/include/xo/indentlog/print/ppdetail_atomic.hpp +++ b/xo-indentlog/include/xo/indentlog/print/ppdetail_atomic.hpp @@ -16,7 +16,7 @@ namespace xo { // Defining this means ppdetail_atomic is not used. // In that case where not explicitly specialized ppdetail will revert to ordinary printing for a type, // instead of giving compile-time error about missing template specialization of ppdetail. -#define ppdetail_atomic ppdetail +//#define ppdetail_atomic ppdetail struct ppindentinfo { ppindentinfo(ppstate * pps, std::uint32_t ci0, std::uint32_t indent_width, bool upto) diff --git a/xo-reader/include/xo/reader/parser.hpp b/xo-reader/include/xo/reader/parser.hpp index d13f36ed..952fa9d6 100644 --- a/xo-reader/include/xo/reader/parser.hpp +++ b/xo-reader/include/xo/reader/parser.hpp @@ -54,6 +54,7 @@ namespace xo { * * deftype point :: {x : f64, y : f64}; * deftype polar :: {arg : f64, mag : f64}; + * deftype converter :: (point -> polar); * * def polar2rect(pt : polar) -> point { * point(x = pt.mag * cos(arg), diff --git a/xo-reader/src/reader/exprstate.cpp b/xo-reader/src/reader/exprstate.cpp index cbcc3560..476c6420 100644 --- a/xo-reader/src/reader/exprstate.cpp +++ b/xo-reader/src/reader/exprstate.cpp @@ -221,8 +221,7 @@ namespace xo { exprstate::on_leftparen_token(const token_type & tk, parserstatemachine * p_psm) { - constexpr bool c_debug_flag = true; - scope log(XO_DEBUG(c_debug_flag)); + scope log(XO_DEBUG(p_psm->debug_flag())); constexpr const char * c_self_name = "exprstate::on_leftparen_token"; const char * exp = get_expect_str(); diff --git a/xo-reader/src/reader/lambda_xs.cpp b/xo-reader/src/reader/lambda_xs.cpp index 89e2f972..eb54ea62 100644 --- a/xo-reader/src/reader/lambda_xs.cpp +++ b/xo-reader/src/reader/lambda_xs.cpp @@ -7,6 +7,8 @@ #include "expect_formal_arglist_xs.hpp" #include "expect_expr_xs.hpp" #include "expect_type_xs.hpp" +#include "pretty_expression.hpp" +#include "pretty_variable.hpp" #include "xo/expression/Lambda.hpp" namespace xo { @@ -198,7 +200,7 @@ namespace xo { if (def_var->valuetype() == nullptr) { log && log("assign discovered lambda type T to enclosing define", - xtag("lhs", def_var), + xtag("lhs", def_var.get()), xtag("T", print::unq(this->lambda_td_->canonical_name()))); def_var->assign_valuetype(lambda_td_); diff --git a/xo-reader/src/reader/reader.cpp b/xo-reader/src/reader/reader.cpp index 2a615fd9..5889462a 100644 --- a/xo-reader/src/reader/reader.cpp +++ b/xo-reader/src/reader/reader.cpp @@ -56,9 +56,14 @@ namespace xo { expr_span += used_span; if (tk.is_valid()) { + log && log("input_state.current_line", tokenizer_.input_state().current_line()); + /* forward just-read token to parser */ auto parser_result = this->parser_.include_token(tk); + log && log("after parser.include_token"); + log && log("input_state.current_line", tokenizer_.input_state().current_line()); + if (parser_result.is_expression()) { log && log(xtag("outcome", "victory!"), xtag("expr", parser_result.result_expr()));