xo-reader: simplify: drop exprstate.admits_colon()

This commit is contained in:
Roland Conybeare 2024-08-10 17:12:52 -05:00
commit 2b436850cf
7 changed files with 4 additions and 49 deletions

View file

@ -76,35 +76,6 @@ namespace xo {
return false;
}
bool
exprstate::admits_colon() const {
switch (exs_type_) {
case exprstatetype::expect_toplevel_expression_sequence:
case exprstatetype::defexpr:
case exprstatetype::parenexpr:
/* unreachable -- redirects to define_xs::admits_colon() etc */
assert(false);
return false;
case exprstatetype::expect_rhs_expression:
case exprstatetype::expect_symbol:
case exprstatetype::expect_type:
return false;
case exprstatetype::expr_progress:
/* unreachable */
assert(false);
return false;
case exprstatetype::invalid:
case exprstatetype::n_exprstatetype:
/* unreachable */
return false;
}
return false;
}
bool
exprstate::admits_semicolon() const {
switch (exs_type_) {
@ -214,12 +185,9 @@ namespace xo {
constexpr const char * self_name = "exprstate::on_colon";
/* lots of illegal states */
if (!this->admits_colon())
{
throw std::runtime_error(tostr(self_name,
": unexpected colon for parsing state",
xtag("state", *this)));
}
throw std::runtime_error(tostr(self_name,
": unexpected colon for parsing state",
xtag("state", *this)));
assert(false);
}