xo-reader: refactor: parserstatemachine to consolidate on_input()

This commit is contained in:
Roland Conybeare 2024-08-19 11:39:27 -04:00
commit b02d1e17e4
16 changed files with 124 additions and 148 deletions

View file

@ -86,18 +86,15 @@ namespace xo {
virtual void on_def_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_colon_token(const token_type & tk,
exprstatestack * p_stack) override;
parserstatemachine * p_psm) override;
virtual void on_semicolon_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
virtual void on_singleassign_token(const token_type & tk,
exprstatestack * p_stack) override;
parserstatemachine * p_psm) override;
virtual void on_rightparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
virtual void on_f64_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
virtual void print(std::ostream & os) const override;

View file

@ -21,16 +21,15 @@ namespace xo {
virtual void on_lambda_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_leftparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
virtual void on_symbol_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_f64_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
/** update exprstate in response to a successfully-parsed subexpression **/
virtual void on_expr(ref::brw<Expression> expr,

View file

@ -56,17 +56,14 @@ namespace xo {
static void start(exprstatestack * p_stack);
virtual void on_leftparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
virtual void on_formal(const rp<Variable> & formal,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
virtual void on_comma_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
virtual void on_rightparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
virtual void print(std::ostream & os) const override;
private:

View file

@ -54,8 +54,7 @@ namespace xo {
rp<Expression> * p_emit_expr) override;
virtual void on_colon_token(const token_type & tk,
exprstatestack * p_stack
/*rp<Expression> * p_emit_expr*/) override;
parserstatemachine * p_psm) override;
// virtual void on_comma_token(...) override;

View file

@ -129,34 +129,30 @@ namespace xo {
parserstatemachine * p_psm);
/** handle incoming ',' token **/
virtual void on_comma_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr);
parserstatemachine * p_psm);
/** handle incoming ':' token **/
virtual void on_colon_token(const token_type & tk,
exprstatestack * p_stack);
parserstatemachine * p_psm);
/** handle incoming ';' token **/
virtual void on_semicolon_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr);
parserstatemachine * p_psm);
/** handle incoming '=' token **/
virtual void on_singleassign_token(const token_type & tk,
exprstatestack * p_stack);
parserstatemachine * p_psm);
/** handle incoming '(' token **/
virtual void on_leftparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr);
parserstatemachine * p_psm);
/** handle incoming ')' token **/
virtual void on_rightparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr);
parserstatemachine * p_psm);
/** handle incoming operator token **/
virtual void on_operator_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr);
parserstatemachine * p_psm);
/** handle incoming floating-point-literal token **/
virtual void on_f64_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr);
parserstatemachine * p_psm);
protected:
/** throw exception when next token is inconsistent with

View file

@ -51,8 +51,7 @@ namespace xo {
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
virtual void on_semicolon_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
private:
static std::unique_ptr<lambda_xs> make();

View file

@ -49,21 +49,17 @@ namespace xo {
virtual void on_symbol_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_colon_token(const token_type & tk,
exprstatestack * p_stack) override;
parserstatemachine * p_psm) override;
virtual void on_semicolon_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
virtual void on_singleassign_token(const token_type & tk,
exprstatestack * p_stack) override;
parserstatemachine * p_psm) override;
virtual void on_leftparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
virtual void on_rightparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
virtual void on_f64_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
virtual void print(std::ostream & os) const override;

View file

@ -67,27 +67,22 @@ namespace xo {
virtual void on_def_token(const token_type & tk,
parserstatemachine * p_psm) override;
virtual void on_colon_token(const token_type & tk,
exprstatestack * p_stack) override;
parserstatemachine * p_psm) override;
virtual void on_semicolon_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
virtual void on_singleassign_token(const token_type & tk,
exprstatestack * p_stack) override;
parserstatemachine * p_psm) override;
virtual void on_leftparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
virtual void on_rightparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
/* entry point for an infix operator token */
virtual void on_operator_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
parserstatemachine * p_psm) override;
virtual void on_f64_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/) override;
parserstatemachine * p_psm) override;
virtual void print(std::ostream & os) const override;

View file

@ -109,30 +109,34 @@ namespace xo {
void
define_xs::on_colon_token(const token_type & tk,
exprstatestack * p_stack)
parserstatemachine * p_psm)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
//constexpr const char * self_name = "define_xs::on_colon_token";
auto p_stack = p_psm->p_stack_;
if (this->defxs_type_ == defexprstatetype::def_2) {
this->defxs_type_ = defexprstatetype::def_3;
expect_type_xs::start(p_stack);
} else {
exprstate::on_colon_token(tk, p_stack);
exprstate::on_colon_token(tk, p_psm);
}
}
void
define_xs::on_semicolon_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
auto p_stack = p_psm->p_stack_;
auto p_emit_expr = p_psm->p_emit_expr_;
//constexpr const char * self_name = "exprstate::on_semicolon";
if (this->defxs_type_ == defexprstatetype::def_6) {
@ -144,13 +148,13 @@ namespace xo {
p_stack,
p_emit_expr);
} else {
exprstate::on_semicolon_token(tk, p_stack, p_emit_expr);
exprstate::on_semicolon_token(tk, p_psm);
}
}
void
define_xs::on_singleassign_token(const token_type & tk,
exprstatestack * p_stack)
parserstatemachine * p_psm)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -177,7 +181,7 @@ namespace xo {
{
this->defxs_type_ = defexprstatetype::def_5;
expect_expr_xs::start(p_stack);
expect_expr_xs::start(p_psm->p_stack_);
} else {
this->illegal_input_error(self_name, tk);
}
@ -185,8 +189,7 @@ namespace xo {
void
define_xs::on_rightparen_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -198,8 +201,7 @@ namespace xo {
void
define_xs::on_f64_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));

View file

@ -51,14 +51,15 @@ namespace xo {
void
expect_expr_xs::on_leftparen_token(const token_type & /*tk*/,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * p_psm)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
//constexpr const char * self_name = "exprstate::on_leftparen";
auto p_stack = p_psm->p_stack_;
/* push lparen_0 to remember to look for subsequent rightparen. */
paren_xs::start(p_stack);
}
@ -99,8 +100,7 @@ namespace xo {
void
expect_expr_xs::on_f64_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * p_psm)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -113,7 +113,7 @@ namespace xo {
*/
progress_xs::start
(Constant<double>::make(tk.f64_value()),
p_stack);
p_psm->p_stack_);
}
void

View file

@ -6,6 +6,7 @@
#include "expect_formal_arglist_xs.hpp"
#include "expect_formal_xs.hpp"
#include "expect_symbol_xs.hpp"
#include "parserstatemachine.hpp"
#include "xo/expression/Variable.hpp"
#include "xo/indentlog/print/vector.hpp"
@ -48,15 +49,16 @@ namespace xo {
void
expect_formal_arglist_xs::on_leftparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
auto p_stack = p_psm->p_stack_;
if (farglxs_type_ == formalarglstatetype::argl_0) {
this->farglxs_type_ = formalarglstatetype::argl_1a;
/* TODO: refactor to have setup method on each exprstate */
expect_formal_xs::start(p_stack);
} else {
exprstate::on_leftparen_token(tk, p_stack, p_emit_expr);
exprstate::on_leftparen_token(tk, p_psm);
}
}
@ -75,29 +77,32 @@ namespace xo {
void
expect_formal_arglist_xs::on_comma_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
auto p_stack = p_psm->p_stack_;
if (farglxs_type_ == formalarglstatetype::argl_1b) {
this->farglxs_type_ = formalarglstatetype::argl_1a;
expect_formal_xs::start(p_stack);
} else {
exprstate::on_comma_token(tk, p_stack, p_emit_expr);
exprstate::on_comma_token(tk, p_psm);
}
}
void
expect_formal_arglist_xs::on_rightparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
auto p_stack = p_psm->p_stack_;
auto p_emit_expr = p_psm->p_emit_expr_;
if (farglxs_type_ == formalarglstatetype::argl_1b) {
std::unique_ptr<exprstate> self = p_stack->pop_exprstate();
p_stack->top_exprstate().on_formal_arglist(this->argl_,
p_stack, p_emit_expr);
} else {
exprstate::on_rightparen_token(tk, p_stack, p_emit_expr);
exprstate::on_rightparen_token(tk, p_psm);
}
}

View file

@ -6,6 +6,7 @@
#include "expect_formal_xs.hpp"
#include "expect_symbol_xs.hpp"
#include "expect_type_xs.hpp"
#include "parserstatemachine.hpp"
#include "xo/expression/Variable.hpp"
namespace xo {
@ -63,16 +64,17 @@ namespace xo {
void
expect_formal_xs::on_colon_token(const token_type & tk,
exprstatestack * p_stack
/* rp<Expression> * p_emit_expr */)
parserstatemachine * p_psm)
{
auto p_stack = p_psm->p_stack_;
if (this->formalxs_type_ == formalstatetype::formal_1) {
this->formalxs_type_ = formalstatetype::formal_2;
expect_type_xs::start(p_stack);
/* control reenters via expect_formal_xs::on_typedescr() */
} else {
exprstate::on_colon_token(tk,
p_stack);
p_psm);
}
}

View file

@ -146,7 +146,7 @@ namespace xo {
void
exprstate::on_colon_token(const token_type & tk,
exprstatestack * /*p_stack*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -158,8 +158,7 @@ namespace xo {
void
exprstate::on_comma_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -171,8 +170,7 @@ namespace xo {
void
exprstate::on_semicolon_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -184,7 +182,7 @@ namespace xo {
void
exprstate::on_singleassign_token(const token_type & tk,
exprstatestack * /*p_stack*/) {
parserstatemachine * /*p_psm*/) {
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -195,8 +193,7 @@ namespace xo {
void
exprstate::on_leftparen_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -208,8 +205,7 @@ namespace xo {
void
exprstate::on_rightparen_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -221,8 +217,7 @@ namespace xo {
void
exprstate::on_operator_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -234,8 +229,7 @@ namespace xo {
void
exprstate::on_f64_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -254,9 +248,6 @@ namespace xo {
log && log(xtag("tk", tk));
log && log(xtag("state", *this));
auto p_stack = p_psm->p_stack_;
auto p_emit_expr = p_psm->p_emit_expr_;
switch (tk.tk_type()) {
case tokentype::tk_def:
@ -272,7 +263,7 @@ namespace xo {
return;
case tokentype::tk_f64:
this->on_f64_token(tk, p_stack, p_emit_expr);
this->on_f64_token(tk, p_psm);
return;
case tokentype::tk_string:
@ -284,11 +275,11 @@ namespace xo {
return;
case tokentype::tk_leftparen:
this->on_leftparen_token(tk, p_stack, p_emit_expr);
this->on_leftparen_token(tk, p_psm);
return;
case tokentype::tk_rightparen:
this->on_rightparen_token(tk, p_stack, p_emit_expr);
this->on_rightparen_token(tk, p_psm);
return;
case tokentype::tk_leftbracket:
@ -303,11 +294,11 @@ namespace xo {
return;
case tokentype::tk_comma:
this->on_comma_token(tk, p_stack, p_emit_expr);
this->on_comma_token(tk, p_psm);
return;
case tokentype::tk_colon:
this->on_colon_token(tk, p_stack);
this->on_colon_token(tk, p_psm);
return;
case tokentype::tk_doublecolon:
@ -315,11 +306,11 @@ namespace xo {
return;
case tokentype::tk_semicolon:
this->on_semicolon_token(tk, p_stack, p_emit_expr);
this->on_semicolon_token(tk, p_psm);
return;
case tokentype::tk_singleassign:
this->on_singleassign_token(tk, p_stack);
this->on_singleassign_token(tk, p_psm);
return;
case tokentype::tk_assign:
@ -329,7 +320,7 @@ namespace xo {
case tokentype::tk_minus:
case tokentype::tk_star:
case tokentype::tk_slash:
this->on_operator_token(tk, p_stack, p_emit_expr);
this->on_operator_token(tk, p_psm);
return;
case tokentype::tk_type:

View file

@ -71,9 +71,11 @@ namespace xo {
void
lambda_xs::on_semicolon_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
auto p_stack = p_psm->p_stack_;
auto p_emit_expr = p_psm->p_emit_expr_;
if (lmxs_type_ == lambdastatetype::lm_3) {
/* done! */
@ -84,12 +86,12 @@ namespace xo {
rp<Lambda> lm = Lambda::make(name, argl_, body_);
p_stack->top_exprstate().on_expr(lm, p_stack, p_emit_expr);
p_stack->top_exprstate().on_semicolon_token(tk, p_stack, p_emit_expr);
p_stack->top_exprstate().on_semicolon_token(tk, p_psm);
return;
}
exprstate::on_semicolon_token(tk, p_stack, p_emit_expr);
exprstate::on_semicolon_token(tk, p_psm);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -101,7 +101,7 @@ namespace xo {
void
paren_xs::on_colon_token(const token_type & tk,
exprstatestack * /*p_stack*/)
parserstatemachine * /*p_psm*/)
{
constexpr const char * c_self_name = "paren_xs::on_colon";
@ -110,8 +110,7 @@ namespace xo {
void
paren_xs::on_semicolon_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr const char * c_self_name = "paren_xs::on_semicolon";
@ -120,7 +119,7 @@ namespace xo {
void
paren_xs::on_singleassign_token(const token_type & tk,
exprstatestack * /*p_stack*/)
parserstatemachine * /*p_psm*/)
{
constexpr const char * c_self_name = "paren_xs::on_singleassign";
@ -129,8 +128,7 @@ namespace xo {
void
paren_xs::on_leftparen_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr const char * c_self_name = "paren_xs::on_leftparen";
@ -139,8 +137,7 @@ namespace xo {
void
paren_xs::on_rightparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -155,6 +152,9 @@ namespace xo {
if (this->parenxs_type_ == parenexprstatetype::lparen_1) {
rp<Expression> expr = this->gen_expr_;
auto p_stack = p_psm->p_stack_;
auto p_emit_expr = p_psm->p_emit_expr_;
std::unique_ptr<exprstate> self = p_stack->pop_exprstate();
p_stack->top_exprstate().on_expr(expr, p_stack, p_emit_expr);
@ -163,20 +163,14 @@ namespace xo {
void
paren_xs::on_f64_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
constexpr const char * c_self_name = "paren_xs::on_f64";
if (!this->admits_f64())
{
this->illegal_input_error(c_self_name, tk);
}
assert(false);
this->illegal_input_error(c_self_name, tk);
}
void

View file

@ -2,6 +2,7 @@
#include "progress_xs.hpp"
#include "expect_expr_xs.hpp"
#include "parserstatemachine.hpp"
#include "xo/expression/Apply.hpp"
namespace xo {
@ -183,7 +184,7 @@ namespace xo {
void
progress_xs::on_colon_token(const token_type & tk,
exprstatestack * /*p_stack*/)
parserstatemachine * /*p_psm*/)
{
constexpr const char * self_name = "progress_xs::on_colon";
@ -192,14 +193,16 @@ namespace xo {
void
progress_xs::on_semicolon_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
/* note: implementation parllels .on_rightparen_token() */
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
auto p_stack = p_psm->p_stack_;
auto p_emit_expr = p_psm->p_emit_expr_;
rp<Expression> expr = this->assemble_expr();
std::unique_ptr<exprstate> self = p_stack->pop_exprstate();
@ -222,12 +225,12 @@ namespace xo {
* f. now deliver semicolon; [lparen_1] rejects
*/
p_stack->top_exprstate().on_semicolon_token(tk, p_stack, p_emit_expr);
p_stack->top_exprstate().on_semicolon_token(tk, p_psm);
}
void
progress_xs::on_singleassign_token(const token_type & tk,
exprstatestack * /*p_stack*/)
parserstatemachine * /*p_psm*/)
{
constexpr const char * self_name = "progress_xs::on_singleassign";
@ -236,8 +239,7 @@ namespace xo {
void
progress_xs::on_leftparen_token(const token_type & tk,
exprstatestack * /*p_stack*/,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * /*p_psm*/)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -249,8 +251,7 @@ namespace xo {
void
progress_xs::on_rightparen_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
/* note: implementation parallels .on_semicolon_token() */
@ -260,6 +261,9 @@ namespace xo {
constexpr const char * self_name = "progress_xs::on_rightparen";
auto p_stack = p_psm->p_stack_;
auto p_emit_expr = p_psm->p_emit_expr_;
/* stack may be something like:
*
* lparen_0
@ -286,8 +290,7 @@ namespace xo {
p_stack->top_exprstate().on_expr(expr, p_stack, p_emit_expr);
/* now deliver rightparen */
p_stack->top_exprstate().on_rightparen_token(tk, p_stack, p_emit_expr);
p_stack->top_exprstate().on_rightparen_token(tk, p_psm);
}
namespace {
@ -312,11 +315,12 @@ namespace xo {
void
progress_xs::on_operator_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * /*p_emit_expr*/)
parserstatemachine * p_psm)
{
constexpr const char * c_self_name = "progress_xs::on_operator_token";
auto p_stack = p_psm->p_stack_;
if (op_type_ == optype::invalid) {
this->op_type_ = tk2op(tk.tk_type());
@ -383,8 +387,7 @@ namespace xo {
void
progress_xs::on_f64_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
constexpr bool c_debug_flag = true;
scope log(XO_DEBUG(c_debug_flag));
@ -394,8 +397,7 @@ namespace xo {
if (this->op_type_ == optype::invalid) {
this->illegal_input_error(self_name, tk);
} else {
assert(false);
exprstate::on_f64_token(tk, p_stack, p_emit_expr);
exprstate::on_f64_token(tk, p_psm);
}
}