Remove C-style casts
Report location with "Wrong number of arguments" errors
version "0.2";
description "Mikkosoft Productions datafile parser";
version "0.2";
description "Mikkosoft Productions datafile parser";
int get();
int peek();
unsigned get_line_number() const { return line; }
int get();
int peek();
unsigned get_line_number() const { return line; }
- operator bool() const { return (bool)in; }
+ operator bool() const { return in; }
private:
std::istream ∈
unsigned line;
private:
std::istream ∈
unsigned line;
#include <fstream>
#include <map>
#include <fstream>
#include <map>
#include "parser.h"
#include "statement.h"
#include "value.h"
#include "parser.h"
#include "statement.h"
#include "value.h"
LoaderFunc0(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
LoaderFunc0(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
- if(st.args.size()!=0) throw TypeError("Wrong number of arguments");
+ if(st.args.size()!=0) throw TypeError(st.get_location()+": Wrong number of arguments");
(dynamic_cast<L &>(l).*func)();
};
private:
(dynamic_cast<L &>(l).*func)();
};
private:
LoaderFunc1(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
LoaderFunc1(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
- if(st.args.size()!=1) throw TypeError("Wrong number of arguments");
+ if(st.args.size()!=1) throw TypeError(st.get_location()+": Wrong number of arguments");
(dynamic_cast<L &>(l).*func)(st.args[0].get<A0>());
}
private:
(dynamic_cast<L &>(l).*func)(st.args[0].get<A0>());
}
private:
LoaderFunc2(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
LoaderFunc2(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
- if(st.args.size()!=2) throw TypeError("Wrong number of arguments");
+ if(st.args.size()!=2) throw TypeError(st.get_location()+": Wrong number of arguments");
(dynamic_cast<L &>(l).*func)(st.args[0].get<A0>(), st.args[1].get<A1>());
}
private:
(dynamic_cast<L &>(l).*func)(st.args[0].get<A0>(), st.args[1].get<A1>());
}
private:
LoaderFunc3(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
LoaderFunc3(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
- if(st.args.size()!=3) throw TypeError("Wrong number of arguments");
+ if(st.args.size()!=3) throw TypeError(st.get_location()+": Wrong number of arguments");
(dynamic_cast<L &>(l).*func)(st.args[0].get<A0>(), st.args[1].get<A1>(), st.args[2].get<A2>());
}
private:
(dynamic_cast<L &>(l).*func)(st.args[0].get<A0>(), st.args[1].get<A1>(), st.args[2].get<A2>());
}
private:
LoaderFunc4(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
LoaderFunc4(FuncType f): func(f) { }
void execute(Loader &l, const Statement &st) const
{
- if(st.args.size()!=4) throw TypeError("Wrong number of arguments");
+ if(st.args.size()!=4) throw TypeError(st.get_location()+": Wrong number of arguments");
(dynamic_cast<L &>(l).*func)(st.args[0].get<A0>(), st.args[1].get<A1>(), st.args[2].get<A2>(), st.args[3].get<A3>());
}
private:
(dynamic_cast<L &>(l).*func)(st.args[0].get<A0>(), st.args[1].get<A1>(), st.args[2].get<A2>(), st.args[3].get<A3>());
}
private:
LoadValue(PointerType p): ptr(p) { }
void execute(Loader &l, const Statement &st) const
{
LoadValue(PointerType p): ptr(p) { }
void execute(Loader &l, const Statement &st) const
{
- if(st.args.size()!=1) throw TypeError("Wrong number of arguments");
+ if(st.args.size()!=1) throw TypeError(st.get_location()+": Wrong number of arguments");
dynamic_cast<typename L::Loader &>(l).get_object().*ptr=st.args[0].get<T>();
}
private:
dynamic_cast<typename L::Loader &>(l).get_object().*ptr=st.args[0].get<T>();
}
private:
public:
Parser(std::istream &, const std::string &);
Statement parse();
public:
Parser(std::istream &, const std::string &);
Statement parse();
- operator bool() const { return (bool)in; }
+ operator bool() const { return in; }
private:
Input in;
std::string src;
private:
Input in;
std::string src;