diff --git a/include/xo/reader/define_xs.hpp b/include/xo/reader/define_xs.hpp index b83ada71..e32d47a8 100644 --- a/include/xo/reader/define_xs.hpp +++ b/include/xo/reader/define_xs.hpp @@ -41,6 +41,7 @@ namespace xo { virtual void on_colon(exprstatestack * p_stack) override; virtual void on_semicolon(exprstatestack * p_stack, rp * /*p_emit_expr*/) override; + virtual void on_singleassign(exprstatestack * p_stack) override; private: /** diff --git a/src/reader/define_xs.cpp b/src/reader/define_xs.cpp index d5513bf2..df468503 100644 --- a/src/reader/define_xs.cpp +++ b/src/reader/define_xs.cpp @@ -475,6 +475,32 @@ namespace xo { assert(false); } } + + void + define_xs::on_singleassign(exprstatestack * p_stack) + { + constexpr bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag)); + + constexpr const char * self_name = "exprstate::on_singleassign"; + + if (!this->admits_singleassign()) + { + throw std::runtime_error(tostr(self_name, + ": unexpected equals for parsing state", + xtag("state", *this))); + } + + if ((this->exs_type_ == exprstatetype::def_1) + || (this->exs_type_ == exprstatetype::def_3)) + { + this->exs_type_ = exprstatetype::def_4; + + p_stack->push_exprstate(exprstate::expect_rhs_expression()); + } else { + assert(false); + } + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/reader/exprstate.cpp b/src/reader/exprstate.cpp index 77a376c3..a0e9b0c7 100644 --- a/src/reader/exprstate.cpp +++ b/src/reader/exprstate.cpp @@ -658,7 +658,7 @@ namespace xo { } void - exprstate::on_singleassign(exprstatestack * p_stack) { + exprstate::on_singleassign(exprstatestack * /*p_stack*/) { constexpr bool c_debug_flag = true; scope log(XO_DEBUG(c_debug_flag)); @@ -671,15 +671,7 @@ namespace xo { xtag("state", *this))); } - if ((this->exs_type_ == exprstatetype::def_1) - || (this->exs_type_ == exprstatetype::def_3)) - { - this->exs_type_ = exprstatetype::def_4; - - p_stack->push_exprstate(exprstate::expect_rhs_expression()); - } else { - assert(false); - } + assert(false); } void