xo-reader: refactor: parserstatemachine w/ exprstate.on_lambda_token

This commit is contained in:
Roland Conybeare 2024-08-19 00:54:45 -04:00
commit 8cae38817b
7 changed files with 22 additions and 16 deletions

View file

@ -1,6 +1,7 @@
/* @file lambda_xs.cpp */
#include "lambda_xs.hpp"
#include "parserstatemachine.hpp"
#include "expect_formal_arglist_xs.hpp"
#include "expect_expr_xs.hpp"
#include "xo/expression/Lambda.hpp"
@ -18,23 +19,26 @@ namespace xo {
lambda_xs::start(exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
{
parserstatemachine psm(p_stack, 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);
.on_lambda_token(token_type::lambda(), &psm);
}
lambda_xs::lambda_xs() : exprstate(exprstatetype::lambdaexpr) {}
void
lambda_xs::on_lambda_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr)
parserstatemachine * p_psm)
{
auto p_stack = p_psm->p_stack_;
if (lmxs_type_ == lambdastatetype::lm_0) {
this->lmxs_type_ = lambdastatetype::lm_1;
expect_formal_arglist_xs::start(p_stack);
} else {
exprstate::on_lambda_token(tk, p_stack, p_emit_expr);
exprstate::on_lambda_token(tk, p_psm);
}
}