From: Mikko Rasa Date: Sat, 5 Nov 2016 07:47:56 +0000 (+0200) Subject: Provide access to the keyword of the current statement X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1a3b30ea35fbc19e56bbd35e4ee1811d8d5e02a4;p=libs%2Fdatafile.git Provide access to the keyword of the current statement --- diff --git a/source/loader.cpp b/source/loader.cpp index 81fd27e..997e7c9 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -205,5 +205,12 @@ const string &Loader::get_source() const return cur_st->source; } +const string &Loader::get_keyword() const +{ + if(!cur_st) + throw logic_error("no current statement"); + return cur_st->keyword; +} + } // namespace DataFile } // namespace Msp diff --git a/source/loader.h b/source/loader.h index 8a1103d..fe92804 100644 --- a/source/loader.h +++ b/source/loader.h @@ -141,6 +141,10 @@ protected: source may not necessarily be a file. */ const std::string &get_source() const; + /** Returns the keyword of the statement being processed. Can be used to + implement dynamic keywords. */ + const std::string &get_keyword() const; + virtual void finish() { } };