X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Floader.cpp;h=997e7c9eec27f7f480c711291f6a47f997c7039e;hb=1a3b30ea35fbc19e56bbd35e4ee1811d8d5e02a4;hp=e1a0d4abd7bcd80adfa4040c2a9bdf43ffb43ee7;hpb=3b78eeb8b92dc3524d6a0456b4daf0a0f3dbf813;p=libs%2Fdatafile.git diff --git a/source/loader.cpp b/source/loader.cpp index e1a0d4a..997e7c9 100644 --- a/source/loader.cpp +++ b/source/loader.cpp @@ -1,6 +1,6 @@ #include #include -#include "dataerror.h" +#include "except.h" #include "loader.h" #include "type.h" @@ -24,7 +24,7 @@ bool signature_match(const string &st_sig, const string &act_sig) else if(act_sig.size()==2 && act_sig[1]=='*') { for(string::const_iterator i=st_sig.begin(); i!=st_sig.end(); ++i) - if(*i!=act_sig[0]) + if(!signature_match(*i, act_sig[0])) return false; return true; @@ -47,28 +47,6 @@ bool signature_match(const string &st_sig, const string &act_sig) namespace Msp { namespace DataFile { -class unknown_keyword: public runtime_error -{ -public: - unknown_keyword(const std::string &k): - runtime_error(k) - { } - - virtual ~unknown_keyword() throw() { } -}; - - -class invalid_signature: public runtime_error -{ -public: - invalid_signature(const std::string &k, const std::string &s): - runtime_error(format("%s %s", k, s)) - { } - - virtual ~invalid_signature() throw() { } -}; - - Loader::Loader(): cur_st(0), direct(false), @@ -87,7 +65,7 @@ void Loader::load(Parser &p) { if(p.peek(0)) load_direct(p, 0); - else + else if(p) // Peek may have processed an __end, so recheck goodness { // Parse in raw mode so we can peek immediately after a mode change Statement st = p.parse(true); @@ -227,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