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);
|
static void start(parserstatemachine * p_stack);
|
||||||
|
|
||||||
|
virtual const char * get_expect_str() const override;
|
||||||
|
|
||||||
virtual void on_symbol_token(const token_type & tk,
|
virtual void on_symbol_token(const token_type & tk,
|
||||||
parserstatemachine * p_psm) override;
|
parserstatemachine * p_psm) override;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,12 @@ namespace xo {
|
||||||
: exprstate(exprstatetype::expect_type)
|
: exprstate(exprstatetype::expect_type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
expect_type_xs::get_expect_str() const
|
||||||
|
{
|
||||||
|
return "typename";
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
expect_type_xs::on_symbol_token(const token_type & tk,
|
expect_type_xs::on_symbol_token(const token_type & tk,
|
||||||
parserstatemachine * p_psm)
|
parserstatemachine * p_psm)
|
||||||
|
|
@ -49,11 +55,15 @@ namespace xo {
|
||||||
td = Reflect::require<std::int64_t>();
|
td = Reflect::require<std::int64_t>();
|
||||||
|
|
||||||
if (!td) {
|
if (!td) {
|
||||||
throw std::runtime_error
|
const char * exp = get_expect_str();
|
||||||
(tostr(c_self_name,
|
|
||||||
": unknown type name",
|
std::string errmsg = tostr("unexpected token for parsing state",
|
||||||
" (expecting f64|f32|i16|i32|i64)",
|
xtag("expecting", exp),
|
||||||
xtag("typename", tk.text())));
|
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();
|
std::unique_ptr<exprstate> self = p_psm->pop_exprstate();
|
||||||
|
|
@ -62,5 +72,4 @@ namespace xo {
|
||||||
} /*namespace scm*/
|
} /*namespace scm*/
|
||||||
} /*namespace xo*/
|
} /*namespace xo*/
|
||||||
|
|
||||||
|
|
||||||
/* end expect_type_xs.cpp */
|
/* end expect_type_xs.cpp */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue