]> git.tdb.fi Git - libs/datafile.git/commitdiff
Get source from the parser if there's no current statement
authorMikko Rasa <tdb@tdb.fi>
Wed, 6 Sep 2023 12:35:02 +0000 (15:35 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 6 Sep 2023 12:35:02 +0000 (15:35 +0300)
Binary format is loaded directly, without statement structures.

source/loader.cpp
source/parser.h

index 8f443c3ce038c978643b4e753e40417aaddb41b8..75638a6b50ff3532083b253bb0f98a49f7a5a6c0 100644 (file)
@@ -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
index 32a776082de1896e20fbe5aa001a78669e33ea66..84ba9de32e1350d6f9bcb2ac2c452995fee4d9b0 100644 (file)
@@ -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; }
 };