diff --git a/include/xo/reader/exprstate.hpp b/include/xo/reader/exprstate.hpp index f3b00d51..c21f453f 100644 --- a/include/xo/reader/exprstate.hpp +++ b/include/xo/reader/exprstate.hpp @@ -172,6 +172,9 @@ namespace xo { /** handle incoming '=' token **/ virtual void on_singleassign_token(const token_type & tk, parserstatemachine * p_psm); + /** handle incoming ':=' token **/ + virtual void on_assign_token(const token_type & tk, + parserstatemachine * p_psm); /** handle incoming '(' token **/ virtual void on_leftparen_token(const token_type & tk, parserstatemachine * p_psm); diff --git a/include/xo/reader/progress_xs.hpp b/include/xo/reader/progress_xs.hpp index ce77966d..780f5232 100644 --- a/include/xo/reader/progress_xs.hpp +++ b/include/xo/reader/progress_xs.hpp @@ -97,7 +97,7 @@ namespace xo { bp expr2, parserstatemachine * p_psm) const; - virtual const char * get_expect_str() const override; + virtual const char * get_expect_str() const final override; virtual void on_expr(bp expr, parserstatemachine * p_psm) override; @@ -116,6 +116,8 @@ namespace xo { parserstatemachine * p_psm) override; virtual void on_singleassign_token(const token_type & tk, parserstatemachine * p_psm) override; + virtual void on_assign_token(const token_type & tk, + parserstatemachine * p_psm) final override; virtual void on_leftparen_token(const token_type & tk, parserstatemachine * p_psm) override; virtual void on_rightparen_token(const token_type & tk, @@ -129,7 +131,7 @@ namespace xo { /* entry point for an infix operator token */ virtual void on_operator_token(const token_type & tk, - parserstatemachine * p_psm) override; + parserstatemachine * p_psm) final override; virtual void on_bool_token(const token_type & tk, parserstatemachine * p_psm) override; diff --git a/src/reader/exprstate.cpp b/src/reader/exprstate.cpp index 0a8b0d32..47e368d4 100644 --- a/src/reader/exprstate.cpp +++ b/src/reader/exprstate.cpp @@ -216,6 +216,20 @@ namespace xo { this->illegal_input_on_token(c_self_name, tk, exp, p_psm); } + void + exprstate::on_assign_token(const token_type & tk, + parserstatemachine * p_psm) + { + constexpr bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag)); + + constexpr const char * c_self_name = "exprstate::on_assign_token"; + const char * exp = get_expect_str(); + + this->illegal_input_on_token(c_self_name, tk, exp, p_psm); + } + + void exprstate::on_leftparen_token(const token_type & tk, parserstatemachine * p_psm) @@ -445,6 +459,9 @@ namespace xo { return; case tokentype::tk_assign: + this->on_assign_token(tk, p_psm); + return; + case tokentype::tk_yields: assert(false); break; diff --git a/src/reader/progress_xs.cpp b/src/reader/progress_xs.cpp index c99aaaa6..d47c8cf9 100644 --- a/src/reader/progress_xs.cpp +++ b/src/reader/progress_xs.cpp @@ -434,6 +434,13 @@ namespace xo { this->illegal_input_on_token(c_self_name, tk, exp, p_psm); } + void + progress_xs::on_assign_token(const token_type & tk, + parserstatemachine * p_psm) + { + this->on_operator_token(tk, p_psm); + } + void progress_xs::on_leftparen_token(const token_type & tk, parserstatemachine * p_psm) @@ -573,6 +580,8 @@ namespace xo { optype tk2op(const tokentype & tktype) { switch (tktype) { + case tokentype::tk_assign: + return optype::op_assign; case tokentype::tk_plus: return optype::op_add; case tokentype::tk_minus: