From ca2e8bd78894d2d01d49ace423b97d9743d06999 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 6 Sep 2023 15:35:02 +0300 Subject: [PATCH] Get source from the parser if there's no current statement Binary format is loaded directly, without statement structures. --- source/loader.cpp | 7 +++++-- source/parser.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/loader.cpp b/source/loader.cpp index 8f443c3..75638a6 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -246,9 +246,12 @@ void Loader::unrecognized(const StatementKey &key) const const string &Loader::get_source() const { - if(!cur_st) + if(cur_st) + return cur_st->source; + else if(cur_parser) + return cur_parser->get_source(); + else throw logic_error("no current statement"); - return cur_st->source; } const string &Loader::get_keyword() const diff --git a/source/parser.h b/source/parser.h index 32a7760..84ba9de 100644 --- a/source/parser.h +++ b/source/parser.h @@ -52,6 +52,8 @@ public: statement's signature. */ bool parse_and_load(unsigned, Loader &, const LoaderAction &); + const std::string &get_source() const { return src; } + explicit operator bool() const { return good && in; } }; -- 2.45.2