]> git.tdb.fi Git - libs/datafile.git/blobdiff - source/parser.cpp
Introduce the concept of future objects
[libs/datafile.git] / source / parser.cpp
index 957018f7a35c1e302e659da5f4ac5650f14aeca6..50948404921bd9903031946a8cc7f537ab37d1bc 100644 (file)
@@ -1,5 +1,6 @@
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
 #include "binaryparser.h"
+#include "dataerror.h"
 #include "parser.h"
 #include "statement.h"
 #include "textparser.h"
@@ -25,7 +26,7 @@ Parser::~Parser()
 Statement Parser::parse()
 {
        if(!good)
-               throw Exception("Parser is not good");
+               throw logic_error("Parser::parse() !good");
 
        try
        {
@@ -42,6 +43,8 @@ Statement Parser::parse()
                                delete mode;
                                mode = new TextParser(in, src);
                        }
+                       else if(st.keyword=="__z")
+                               in.set_decompress();
                        else if(st.keyword=="__src")
                        {
                                string s = st.args[0].get<string>();
@@ -54,10 +57,13 @@ Statement Parser::parse()
                                return st;
                }
        }
-       catch(const Exception &e)
+       catch(const exception &e)
        {
                good = false;
-               throw;
+               if(dynamic_cast<const data_error *>(&e))
+                       throw;
+               else
+                       throw data_error(src, in.get_line_number(), e);
        }
 }