xo-reader: ++ typename error reporting
This commit is contained in:
parent
5ed8999ccf
commit
c39d369dbc
2 changed files with 17 additions and 6 deletions
|
|
@ -18,6 +18,8 @@ namespace xo {
|
|||
|
||||
static void start(parserstatemachine * p_stack);
|
||||
|
||||
virtual const char * get_expect_str() const override;
|
||||
|
||||
virtual void on_symbol_token(const token_type & tk,
|
||||
parserstatemachine * p_psm) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,12 @@ namespace xo {
|
|||
: exprstate(exprstatetype::expect_type)
|
||||
{}
|
||||
|
||||
const char *
|
||||
expect_type_xs::get_expect_str() const
|
||||
{
|
||||
return "typename";
|
||||
}
|
||||
|
||||
void
|
||||
expect_type_xs::on_symbol_token(const token_type & tk,
|
||||
parserstatemachine * p_psm)
|
||||
|
|
@ -49,11 +55,15 @@ namespace xo {
|
|||
td = Reflect::require<std::int64_t>();
|
||||
|
||||
if (!td) {
|
||||
throw std::runtime_error
|
||||
(tostr(c_self_name,
|
||||
": unknown type name",
|
||||
" (expecting f64|f32|i16|i32|i64)",
|
||||
xtag("typename", tk.text())));
|
||||
const char * exp = get_expect_str();
|
||||
|
||||
std::string errmsg = tostr("unexpected token for parsing state",
|
||||
xtag("expecting", exp),
|
||||
xtag("token", tk.tk_type()),
|
||||
xtag("text", tk.text()),
|
||||
xtag("state", this->exs_type()));
|
||||
|
||||
p_psm->on_error(c_self_name, std::move(errmsg));
|
||||
}
|
||||
|
||||
std::unique_ptr<exprstate> self = p_psm->pop_exprstate();
|
||||
|
|
@ -62,5 +72,4 @@ namespace xo {
|
|||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
/* end expect_type_xs.cpp */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue