From 5916ac874ff14ceae950cb863dc2c0fdaf0410f2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 18 Aug 2024 23:59:01 -0400 Subject: [PATCH] xo-reader: refactor: simplify expect_formal_arglist_xs api --- include/xo/reader/expect_formal_arglist_xs.hpp | 5 ++++- src/reader/expect_formal_arglist_xs.cpp | 6 ++++++ src/reader/lambda_xs.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/xo/reader/expect_formal_arglist_xs.hpp b/include/xo/reader/expect_formal_arglist_xs.hpp index 82116133..442dde62 100644 --- a/include/xo/reader/expect_formal_arglist_xs.hpp +++ b/include/xo/reader/expect_formal_arglist_xs.hpp @@ -53,7 +53,7 @@ namespace xo { public: expect_formal_arglist_xs(); - static std::unique_ptr make(); + static void start(exprstatestack * p_stack); virtual void on_leftparen_token(const token_type & tk, exprstatestack * p_stack, @@ -69,6 +69,9 @@ namespace xo { rp * p_emit_expr) override; virtual void print(std::ostream & os) const override; + private: + static std::unique_ptr make(); + private: /** parsing state-machine state **/ formalarglstatetype farglxs_type_ = formalarglstatetype::argl_0; diff --git a/src/reader/expect_formal_arglist_xs.cpp b/src/reader/expect_formal_arglist_xs.cpp index 2c67c474..6f2a4e13 100644 --- a/src/reader/expect_formal_arglist_xs.cpp +++ b/src/reader/expect_formal_arglist_xs.cpp @@ -35,6 +35,12 @@ namespace xo { (expect_formal_arglist_xs()); } + void + expect_formal_arglist_xs::start(exprstatestack * p_stack) + { + p_stack->push_exprstate(expect_formal_arglist_xs::make()); + } + expect_formal_arglist_xs::expect_formal_arglist_xs() : exprstate(exprstatetype::expect_formal_arglist), farglxs_type_{formalarglstatetype::argl_0} diff --git a/src/reader/lambda_xs.cpp b/src/reader/lambda_xs.cpp index 82b91ae2..c9c131ac 100644 --- a/src/reader/lambda_xs.cpp +++ b/src/reader/lambda_xs.cpp @@ -23,7 +23,7 @@ namespace xo { { if (lmxs_type_ == lambdastatetype::lm_0) { this->lmxs_type_ = lambdastatetype::lm_1; - p_stack->push_exprstate(expect_formal_arglist_xs::make()); + expect_formal_arglist_xs::start(p_stack); } else { exprstate::on_lambda_token(tk, p_stack, p_emit_expr); }