xo-reader: refactor: simplify lambda_xs api

This commit is contained in:
Roland Conybeare 2024-08-19 00:24:11 -04:00
commit 7767833afb
3 changed files with 16 additions and 4 deletions

View file

@ -40,7 +40,7 @@ namespace xo {
public:
lambda_xs();
static std::unique_ptr<lambda_xs> make();
static void start(exprstatestack * p_stack, rp<Expression> * p_emit_expr);
virtual void on_lambda_token(const token_type & tk,
exprstatestack * p_stack,
@ -55,6 +55,9 @@ namespace xo {
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
private:
static std::unique_ptr<lambda_xs> make();
private:
/** parsing state-machine state **/
lambdastatetype lmxs_type_ = lambdastatetype::lm_0;

View file

@ -31,7 +31,7 @@ namespace xo {
{}
void
expect_expr_xs::on_lambda_token(const token_type & tk,
expect_expr_xs::on_lambda_token(const token_type & /*tk*/,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
{
@ -41,8 +41,8 @@ namespace xo {
//constexpr const char * self_name = "exprstate::on_leftparen";
/* push lparen_0 to remember to look for subsequent rightparen. */
p_stack->push_exprstate(lambda_xs::make());
p_stack->top_exprstate().on_lambda_token(tk, p_stack, p_emit_expr);
lambda_xs::start(p_stack, p_emit_expr);
//p_stack->top_exprstate().on_lambda_token(tk, p_stack, p_emit_expr);
//p_stack->push_exprstate(expect_expr_xs::expect_rhs_expression());
}

View file

@ -14,6 +14,15 @@ namespace xo {
return std::make_unique<lambda_xs>(lambda_xs());
}
void
lambda_xs::start(exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
{
p_stack->push_exprstate(lambda_xs::make());
p_stack->top_exprstate()
.on_lambda_token(token_type::lambda(), p_stack, p_emit_expr);
}
lambda_xs::lambda_xs() : exprstate(exprstatetype::lambdaexpr) {}
void