1 #include <msp/strings/format.h>
2 #include "binaryparser.h"
6 #include "textparser.h"
13 Parser::Parser(IO::Base &i, const string &s):
18 mode(new TextParser(in, src))
26 Statement Parser::parse(bool raw)
29 throw logic_error("Parser::parse() !good");
35 Statement st = mode->parse(raw);
36 if(st.keyword=="__bin")
39 mode = new BinaryParser(in, src);
41 else if(st.keyword=="__text")
44 mode = new TextParser(in, src);
46 else if(st.keyword=="__z")
48 else if(st.keyword=="__src")
50 string s = st.args[0].get<string>();
54 src = format("%s[%s]", main_src, s);
56 else if(st.keyword=="__end")
59 return raw ? st : Statement();
68 catch(const exception &e)
71 if(dynamic_cast<const data_error *>(&e))
74 throw data_error(src, in.get_line_number(), e);
78 } // namespace DataFile