xo-reader: simplify progress_xs.start() using psm
This commit is contained in:
parent
e74e55832e
commit
8db0bf11d0
4 changed files with 11 additions and 15 deletions
|
|
@ -49,9 +49,9 @@ namespace xo {
|
|||
|
||||
static void start(rp<Expression> valex,
|
||||
optype optype,
|
||||
exprstatestack * p_stack);
|
||||
parserstatemachine * p_psm);
|
||||
static void start(rp<Expression> valex,
|
||||
exprstatestack * p_stack);
|
||||
parserstatemachine * p_psm);
|
||||
|
||||
bool admits_f64() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ namespace xo {
|
|||
*/
|
||||
progress_xs::start
|
||||
(Constant<double>::make(tk.f64_value()),
|
||||
p_psm->p_stack_);
|
||||
p_psm);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -181,9 +181,7 @@ namespace xo {
|
|||
switch (this->parenxs_type_) {
|
||||
case parenexprstatetype::lparen_0: {
|
||||
this->parenxs_type_ = parenexprstatetype::lparen_1; /* wants on_rightparen */
|
||||
auto p_stack = p_psm->p_stack_;
|
||||
|
||||
progress_xs::start(expr.promote(), p_stack);
|
||||
progress_xs::start(expr.promote(), p_psm);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,13 +55,13 @@ namespace xo {
|
|||
}
|
||||
|
||||
void
|
||||
progress_xs::start(rp<Expression> valex, optype op, exprstatestack * p_stack) {
|
||||
p_stack->push_exprstate(progress_xs::make(valex, op));
|
||||
progress_xs::start(rp<Expression> valex, optype op, parserstatemachine * p_psm) {
|
||||
p_psm->push_exprstate(progress_xs::make(valex, op));
|
||||
}
|
||||
|
||||
void
|
||||
progress_xs::start(rp<Expression> valex, exprstatestack * p_stack) {
|
||||
p_stack->push_exprstate(progress_xs::make(valex));
|
||||
progress_xs::start(rp<Expression> valex, parserstatemachine * p_psm) {
|
||||
p_psm->push_exprstate(progress_xs::make(valex));
|
||||
}
|
||||
|
||||
progress_xs::progress_xs(rp<Expression> valex, optype op)
|
||||
|
|
@ -313,8 +313,6 @@ namespace xo {
|
|||
{
|
||||
constexpr const char * c_self_name = "progress_xs::on_operator_token";
|
||||
|
||||
auto p_stack = p_psm->p_stack_;
|
||||
|
||||
if (op_type_ == optype::invalid) {
|
||||
this->op_type_ = tk2op(tk.tk_type());
|
||||
|
||||
|
|
@ -345,7 +343,7 @@ namespace xo {
|
|||
std::unique_ptr<exprstate> self = p_psm->pop_exprstate();
|
||||
|
||||
/* 3. replace with new progress_xs: */
|
||||
progress_xs::start(expr, op2, p_stack);
|
||||
progress_xs::start(expr, op2, p_psm);
|
||||
|
||||
/* infix operator must be followed by non-empty expression */
|
||||
expect_expr_xs::start(p_psm);
|
||||
|
|
@ -366,9 +364,9 @@ namespace xo {
|
|||
std::unique_ptr<exprstate> self = p_psm->pop_exprstate();
|
||||
|
||||
/* 1. replace with nested incomplete infix exprs */
|
||||
progress_xs::start(lhs_, op_type_, p_stack);
|
||||
progress_xs::start(lhs_, op_type_, p_psm);
|
||||
expect_expr_xs::start(p_psm);
|
||||
progress_xs::start(rhs_, op2, p_stack);
|
||||
progress_xs::start(rhs_, op2, p_psm);
|
||||
expect_expr_xs::start(p_psm);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue