12 inline bool notSpecialChar(
const std::string& s, size_t pos) {
return pos<2 || s[pos-1]!=
'#' || s[pos-2]!=
'\\'; }
13 inline bool isChar(
const std::string& s, size_t pos,
char c) {
return s[pos]==c && notSpecialChar(s, pos); }
14 inline std::string char2Str(
char c) { std::string s; s.push_back(c);
return s; }
15 inline bool cond(
const std::string& s) {
return !s.size(); }
28 for (size_t i=0; i<lines.size(); ++i)
34 if (pos>=lines[i].length())
38 while(pos<lines[i].size() && !isChar(lines[i], pos,
'"'))
39 rawTokens.rbegin() -> push_back(lines[i][pos++]);
40 if (pos<lines[i].size())
51 while (pos<lines[i].length() && (lines[i][pos]==
' ' || lines[i][pos]==
'\t'))
53 size_t until = std::min( lines[i].find(
' ', pos), lines[i].find(
'\t', pos));
55 if (until == lines[i].npos)
56 t=lines[i].substr(pos);
58 t=lines[i].substr(pos, until-pos);
64 for(size_t j=0; j<t.size(); ++j)
69 if (isChar(t, j,
'"'))
73 if (isChar(t, j,
'(') || isChar(t, j,
')'))
78 else if (isChar(t, j,
'"'))
Tokenizer(const std::vector< std::string > &lines)
void split(const std::vector< std::string > &lines)
std::list< std::string > rawTokens