#include <limits>
-#include <sys/param.h>
#include <msp/core/maputils.h>
#include <msp/strings/format.h>
#include "argumentstore.h"
#include "binaryparser.h"
#include "binfloat.h"
+#include "except.h"
#include "input.h"
#include "loaderaction.h"
namespace Msp {
namespace DataFile {
-class bad_definition: public runtime_error
-{
-public:
- bad_definition(const std::string &w):
- runtime_error(w)
- { }
-
- virtual ~bad_definition() throw() { }
-};
-
-class nesting_error: public logic_error
-{
-public:
- nesting_error(const std::string &w):
- logic_error(w)
- { }
-
- virtual ~nesting_error() throw() { }
-};
-
-
BinaryParser::BinaryParser(Input &i, const string &s):
- ParserMode(i, s),
- float_precision(32),
- cur_info(0)
+ ParserMode(i, s)
{
dict[-1] = StatementInfo("__kwd", "iss");
dict[-2] = StatementInfo("__str", "is");
if(cur_info)
{
key = &cur_info->key;
- cur_info = 0;
+ cur_info = nullptr;
}
else
{
result.args.push_back(parse_bool());
break;
case SymbolType::signature:
- result.args.push_back(parse_symbol());
+ result.args.push_back(Value(parse_symbol()));
break;
}
}
const string &kw = st.args[1].get<const string &>();
const string &args = st.args[2].get<const string &>();
- for(string::const_iterator i=args.begin(); i!=args.end(); ++i)
- for(unsigned j=0; valid_signatures[j]!=*i; ++j)
+ for(char c: args)
+ for(unsigned j=0; valid_signatures[j]!=c; ++j)
if(!valid_signatures[j])
throw bad_definition("__kwd");
for(unsigned i=sub_remaining.back(); i-->0; )
parse();
sub_remaining.pop_back();
- cur_info = 0;
+ cur_info = nullptr;
}
if(!sub_remaining.empty() && sub_remaining.back()==0)
{
// No more substatements on this level
- cur_info = 0;
- return 0;
+ cur_info = nullptr;
+ return nullptr;
}
if(cur_info)
int id = parse_int();
if(!in)
- return 0;
+ return nullptr;
cur_info = &get_item(dict, id);
return &cur_info->key;
if(!sub_remaining.empty())
--sub_remaining.back();
sub_remaining.push_back(parse_int());
- cur_info = 0;
+ cur_info = nullptr;
act.execute(ldr, args);
FloatType::Store BinaryParser::parse_float()
{
- UInt64 encoded = 0;
+ uint64_t encoded = 0;
for(unsigned i=0; i<float_precision; i+=8)
{
int c = in.get();