dict[-3] = DictEntry("__flt", "i");
}
-Statement BinaryParser::parse()
+Statement BinaryParser::parse(bool raw)
{
while(1)
{
- Statement st = parse_statement();
+ Statement st = parse_statement(raw);
if(st.keyword=="__kwd")
{
int id = st.args[0].get<int>();
float_precision = st.args[0].get<unsigned>();
else
return st;
+
+ if(raw)
+ return st;
}
}
-Statement BinaryParser::parse_statement()
+Statement BinaryParser::parse_statement(bool raw)
{
while(first && in.peek()=='\n')
in.get();
unsigned nsub = parse_int();
for(unsigned j = 0; j<nsub; ++j)
- result.sub.push_back(parse());
+ result.sub.push_back(parse(raw));
result.valid = true;
public:
BinaryParser(Input &i, const std::string &s);
- virtual Statement parse();
+ virtual Statement parse(bool);
private:
- Statement parse_statement();
+ Statement parse_statement(bool);
IntType::Store parse_int();
FloatType::Store parse_float();
StringType::Store parse_string();
delete mode;
}
-Statement Parser::parse()
+Statement Parser::parse(bool raw)
{
if(!good)
throw logic_error("Parser::parse() !good");
{
while(1)
{
- Statement st = mode->parse();
+ Statement st = mode->parse(raw);
if(st.keyword=="__bin")
{
delete mode;
else if(st.keyword=="__end")
{
good = false;
- return Statement();
+ return raw ? st : Statement();
}
else
return st;
+
+ if(raw)
+ return st;
}
}
catch(const exception &e)
marked as bad and no more statements may be read, even if the exception was
caught.
*/
- Statement parse();
+ Statement parse(bool raw = false);
operator bool() const { return good && in; }
};
public:
virtual ~ParserMode() { }
- virtual Statement parse() = 0;
+ virtual Statement parse(bool) = 0;
};
} // namespace DataFile
ParserMode(i, s)
{ }
-Statement TextParser::parse()
+Statement TextParser::parse(bool)
{
return parse_statement(0);
}
public:
TextParser(Input &, const std::string &);
- virtual Statement parse();
+ virtual Statement parse(bool);
protected:
Statement parse_statement(const Token *);
Token parse_token();