X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fparser.cpp;h=443c3c8c3d72a4d0951e076f260b6262d511c25f;hb=8d6360cbcd8fe92d97dcba5e68e3adb6f2c0c3bc;hp=ade1dd98e40904412e842a91666b6670e6a124aa;hpb=4371289ed39d8135d407bc7bbbfbedea0cfd6dde;p=libs%2Fdatafile.git diff --git a/source/parser.cpp b/source/parser.cpp index ade1dd9..443c3c8 100644 --- a/source/parser.cpp +++ b/source/parser.cpp @@ -1,11 +1,6 @@ -/* $Id$ - -This file is part of libmspdatafile -Copyright © 2006 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ -#include +#include #include "binaryparser.h" +#include "dataerror.h" #include "parser.h" #include "statement.h" #include "textparser.h" @@ -31,39 +26,42 @@ Parser::~Parser() Statement Parser::parse() { if(!good) - throw Exception("Parser is not good"); + throw logic_error("Parser::parse() !good"); try { while(1) { - Statement st=mode->parse(); + Statement st = mode->parse(); if(st.keyword=="__bin") { delete mode; - mode=new BinaryParser(in, src); + mode = new BinaryParser(in, src); } else if(st.keyword=="__text") { delete mode; - mode=new TextParser(in, src); + mode = new TextParser(in, src); } else if(st.keyword=="__src") { - string s=st.args[0].get(); + string s = st.args[0].get(); if(s.empty()) - src=main_src; + src = main_src; else - src=format("%s[%s]", main_src, s); + src = format("%s[%s]", main_src, s); } else return st; } } - catch(const Exception &e) + catch(const exception &e) { - good=false; - throw; + good = false; + if(dynamic_cast(&e)) + throw; + else + throw data_error(src, in.get_line_number(), e); } }