X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftextparser.cpp;h=c87a32df666924e163ee83e8d53f06d7d181b2e3;hb=ed78b585cfc4ecb44972e346857e887b183fd7a7;hp=225425b4e23166eea05fe0697f16974c327ab1c0;hpb=6653c7d83dbe1fe81a541a125be8bb808b234eb7;p=libs%2Fdatafile.git diff --git a/source/textparser.cpp b/source/textparser.cpp index 225425b..c87a32d 100644 --- a/source/textparser.cpp +++ b/source/textparser.cpp @@ -1,5 +1,6 @@ #include #include +#include "except.h" #include "input.h" #include "textparser.h" #include "token.h" @@ -9,33 +10,11 @@ using namespace std; namespace Msp { namespace DataFile { -class parse_error: public runtime_error -{ -public: - parse_error(const std::string &t): - runtime_error(t.empty() ? "at end of input" : format("after '%s'", t)) - { } - - virtual ~parse_error() throw() { } -}; - - -class syntax_error: public runtime_error -{ -public: - syntax_error(const std::string &t): - runtime_error(t.empty() ? "at end of input" : format("at '%s'", t)) - { } - - virtual ~syntax_error() throw() { } -}; - - TextParser::TextParser(Input &i, const string &s): ParserMode(i, s) { } -Statement TextParser::parse(bool) +Statement TextParser::parse() { return parse_statement(0); } @@ -124,9 +103,9 @@ Token TextParser::parse_token() c = in.get(); int next = in.peek(); - if(c=='/' && next=='/') + if(c=='/' && next=='/' && !comment) comment = 1; - else if(c=='/' && next=='*') + else if(c=='/' && next=='*' && !comment) comment = 2; else if(c=='\n' && comment==1) comment = 0;