xo-reader: streamline: drop redundant admits_xxx() methods

This commit is contained in:
Roland Conybeare 2024-08-10 23:57:01 -05:00
commit e9e0d5255f
8 changed files with 29 additions and 44 deletions

View file

@ -47,7 +47,9 @@ namespace xo {
bool admits_semicolon() const;
virtual bool admits_symbol() const override;
virtual bool admits_singleassign() const override;
#ifdef OBSOLETE
bool admits_singleassign() const;
#endif
// virtual void on_f64(..) override
virtual void on_expr(ref::brw<Expression> expr,

View file

@ -75,11 +75,9 @@ namespace xo {
/** true iff this parsing state admits a symbol as next token **/
virtual bool admits_symbol() const;
#ifdef OBSOLETE
/** true iff this parsing state admits a semicolon as next token **/
virtual bool admits_semicolon() const;
#endif
/** true iff this parsing state admits a singleassign '=' as next token **/
virtual bool admits_singleassign() const;
#endif
/** update exprstate in response to incoming token @p tk,
* forward instructions to parent parser

View file

@ -35,7 +35,6 @@ namespace xo {
bool admits_rightparen() const;
virtual bool admits_symbol() const override;
virtual bool admits_singleassign() const override;
virtual void on_expr(ref::brw<Expression> expr,
exprstatestack * p_stack,

View file

@ -25,7 +25,9 @@ namespace xo {
bool admits_f64() const;
virtual bool admits_symbol() const override;
virtual bool admits_singleassign() const override;
#ifdef OBSOLETE
bool admits_singleassign() const;
#endif
virtual void on_expr(ref::brw<Expression> expr,
exprstatestack * p_stack,

View file

@ -88,24 +88,11 @@ namespace xo {
return false;
}
#ifdef OBSOLETE
bool
define_xs::admits_singleassign() const {
switch (defxs_type_) {
/*
* def foo = 1 ;
* def foo : f64 = 1 ;
* ^ ^ ^ ^ ^ ^ ^
* | | | | | | (done)
* | | | | | def_4:expect_rhs_expression
* | | | | def_3
* | | | def_2:expect_type
* | | def_1
* | def_0:expect_symbol
* expect_toplevel_expression_sequence
*
* note that we skip from def_1 -> def_4 if '=' instead of ':'
*/
case defexprstatetype::def_0:
return false;
@ -131,6 +118,7 @@ namespace xo {
return false;
}
#endif
#ifdef OBSOLETE
bool
@ -367,10 +355,20 @@ namespace xo {
constexpr const char * self_name = "exprstate::on_singleassign";
if (!this->admits_singleassign()) {
this->illegal_input_error(self_name, tk);
}
/*
* def foo = 1 ;
* def foo : f64 = 1 ;
* ^ ^ ^ ^ ^ ^ ^
* | | | | | | (done)
* | | | | | def_4:expect_rhs_expression
* | | | | def_3
* | | | def_2:expect_type
* | | def_1
* | def_0:expect_symbol
* expect_toplevel_expression_sequence
*
* note that we skip from def_1 -> def_4 if '=' instead of ':'
*/
if ((this->defxs_type_ == defexprstatetype::def_1)
|| (this->defxs_type_ == defexprstatetype::def_3))
{
@ -378,7 +376,7 @@ namespace xo {
p_stack->push_exprstate(expect_expr_xs::expect_rhs_expression());
} else {
assert(false);
this->illegal_input_error(self_name, tk);
}
}

View file

@ -76,6 +76,7 @@ namespace xo {
return false;
}
#ifdef OBSOLETE
bool
exprstate::admits_singleassign() const {
switch (exs_type_) {
@ -118,6 +119,7 @@ namespace xo {
return false;
}
#endif
void
exprstate::on_def_token(const token_type & tk,
@ -193,14 +195,9 @@ namespace xo {
constexpr const char * self_name = "exprstate::on_singleassign_token";
if (!this->admits_singleassign())
{
throw std::runtime_error(tostr(self_name,
": unexpected equals for parsing state",
xtag("state", *this)));
}
assert(false);
throw std::runtime_error(tostr(self_name,
": unexpected equals for parsing state",
xtag("state", *this)));
}
void

View file

@ -17,9 +17,6 @@ namespace xo {
bool
paren_xs::admits_symbol() const { return true; }
bool
paren_xs::admits_singleassign() const { return false; }
bool
paren_xs::admits_rightparen() const {
switch (parenxs_type_) {

View file

@ -17,14 +17,6 @@ namespace xo {
bool
progress_xs::admits_symbol() const { return false; }
#ifdef OSBOLETE
bool
progress_xs::admits_semicolon() const { return true; }
#endif
bool
progress_xs::admits_singleassign() const { return false; }
bool
progress_xs::admits_f64() const { return false; }