xo-reader: refactor: use parserstatemachine for parser.on_input()

This commit is contained in:
Roland Conybeare 2024-08-19 00:48:53 -04:00
commit e5dc8d14d4
2 changed files with 6 additions and 7 deletions

View file

@ -63,7 +63,7 @@ namespace xo {
return os;
}
class parserstatemachine;
class parserstatemachine; /* see parserstatemachine.hpp */
class exprstatestack;
class formal_arg;
@ -91,8 +91,7 @@ namespace xo {
* forward instructions to parent parser
**/
void on_input(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr);
parserstatemachine * p_psm);
/** update exprstate in response to a successfully-parsed subexpression **/
virtual void on_expr(ref::brw<Expression> expr,

View file

@ -247,20 +247,20 @@ namespace xo {
void
exprstate::on_input(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));
log && log(xtag("tk", tk));
log && log(xtag("state", *this));
parserstatemachine psm(p_stack, p_emit_expr);
auto p_stack = p_psm->p_stack_;
auto p_emit_expr = p_psm->p_emit_expr_;
switch (tk.tk_type()) {
case tokentype::tk_def:
this->on_def_token(tk, &psm);
this->on_def_token(tk, p_psm);
return;
case tokentype::tk_lambda: