ParserMode(i, s),
first(true)
{
- dict[1] = DictEntry("__kwd", "iss");
- dict[2] = DictEntry("__str", "is");
+ dict[-1] = DictEntry("__kwd", "iss");
+ dict[-2] = DictEntry("__str", "is");
}
Statement BinaryParser::parse()
if(st.args.size()!=3)
throw bad_definition("__kwd");
- const unsigned id = st.args[0].get<unsigned>();
+ const int id = st.args[0].get<unsigned>();
const string &kw = st.args[1].get<const string &>();
const string &args = st.args[2].get<const string &>();
dict[id] = DictEntry(kw, args);
in.get();
first = false;
- unsigned id = parse_int();
+ int id = parse_int();
if(!in)
return Statement();
class BinaryParser: public ParserMode
{
private:
- typedef std::map<unsigned, DictEntry> Dictionary;
+ typedef std::map<int, DictEntry> Dictionary;
typedef std::map<unsigned, std::string> StringMap;
Dictionary dict;
BinaryWriter::BinaryWriter(IO::Base &o):
WriterMode(o),
- next_kwd_id(3),
+ next_kwd_id(1),
next_str_id(1)
{
- dict[DictEntry("__kwd", "iss")] = 1;
- dict[DictEntry("__str", "is")] = 2;
+ dict[DictEntry("__kwd", "iss")] = -1;
+ dict[DictEntry("__str", "is")] = -2;
}
void BinaryWriter::write(const Statement &st)
void BinaryWriter::write_(const Statement &st)
{
- unsigned id = get_item(dict, DictEntry(st.keyword, st.get_signature()));
+ int id = get_item(dict, DictEntry(st.keyword, st.get_signature()));
write_int(id);
for(Statement::Arguments::const_iterator j = st.args.begin(); j!=st.args.end(); ++j)
class BinaryWriter: public WriterMode
{
private:
- typedef std::map<DictEntry, unsigned> Dictionary;
+ typedef std::map<DictEntry, int> Dictionary;
typedef std::map<std::string, unsigned> StringMap;
Dictionary dict;