expect_type_xs: refactor: simplify api

This commit is contained in:
Roland Conybeare 2024-08-18 23:47:47 -04:00
commit 2b6b15480e
4 changed files with 12 additions and 3 deletions

View file

@ -16,11 +16,14 @@ namespace xo {
public:
expect_type_xs();
static std::unique_ptr<expect_type_xs> make();
static void start(exprstatestack * p_stack);
virtual void on_symbol_token(const token_type & tk,
exprstatestack * p_stack,
rp<Expression> * p_emit_expr) override;
private:
static std::unique_ptr<expect_type_xs> make();
};
} /*namespace scm*/
} /*namespace xo*/

View file

@ -116,7 +116,7 @@ namespace xo {
if (this->defxs_type_ == defexprstatetype::def_2) {
this->defxs_type_ = defexprstatetype::def_3;
p_stack->push_exprstate(expect_type_xs::make());
expect_type_xs::start(p_stack);
} else {
exprstate::on_colon_token(tk, p_stack);
}

View file

@ -60,7 +60,8 @@ namespace xo {
{
if (this->formalxs_type_ == formalstatetype::formal_1) {
this->formalxs_type_ = formalstatetype::formal_2;
p_stack->push_exprstate(expect_type_xs::make());
expect_type_xs::start(p_stack);
/* control reenters via expect_formal_xs::on_typedescr() */
} else {
exprstate::on_colon_token(tk,
p_stack);

View file

@ -17,6 +17,11 @@ namespace xo {
return std::make_unique<expect_type_xs>(expect_type_xs());
}
void
expect_type_xs::start(exprstatestack * p_stack) {
p_stack->push_exprstate(expect_type_xs::make());
}
expect_type_xs::expect_type_xs()
: exprstate(exprstatetype::expect_type)
{}