From 1a3b30ea35fbc19e56bbd35e4ee1811d8d5e02a4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 5 Nov 2016 09:47:56 +0200 Subject: [PATCH] Provide access to the keyword of the current statement --- source/loader.cpp | 7 +++++++ source/loader.h | 4 ++++ 2 files changed, 11 insertions(+) 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() { } }; -- 2.43.0