1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Grammer::Grammer(std::istream& in)
{
std::string line;
while(std::getline(in,line))
{
std::string category = getCategory(&line);
line = extractCollection(&category,&line);
Value entry = getValueCollection(&line);
// herer the error occur
std::transform(entry.begin(),entry.end(),
std::back_inserter(rule[category]), &Grammer::getValue);
}
}
std::string Grammer::getCategory( std::string* line )
{
std::string::iterator b,e;
b = find_if(line->begin(),line->end(),not_space);
e = find_if(line->begin(),line->end(), space);
return std::string(b,e);
}
std::string Grammer::extractCollection( const std::string* category,const std::string* line )
{
std::string::const_iterator b;
b = std::search(line->begin(),line->end(),category->begin(),category->end());
b = b+category->size();
return std::string(b,line->end());
}
Value Grammer::getValueCollection( std::string* line )
{
Value ret;
split(line,"/",&ret);
return ret;
}
Value Grammer::getValue( std::string& line )
{
Value ret;
split(&line," ",&ret);
return ret;
}
|