xo-interpreter: handle assignment expressions
This commit is contained in:
parent
9e8a0e5cf6
commit
fc2c9a5629
4 changed files with 33 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ namespace xo {
|
|||
bp<Expression> 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<Expression> 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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue