]> git.tdb.fi Git - libs/datafile.git/commitdiff
Provide access to the keyword of the current statement
authorMikko Rasa <tdb@tdb.fi>
Sat, 5 Nov 2016 07:47:56 +0000 (09:47 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 5 Nov 2016 07:52:57 +0000 (09:52 +0200)
source/loader.cpp
source/loader.h

index 81fd27eecebf87c16e3418ae6d11e3ead9ba8d80..997e7c9eec27f7f480c711291f6a47f997c7039e 100644 (file)
@@ -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
index 8a1103d11f14d4c251033a20a1189a2a886599e8..fe928048508d208aafe339def238a4cdc722dc2d 100644 (file)
@@ -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() { }
 };