| 129 | //--------------------------------------------------------------------------- |
| 130 | |
| 131 | void TokenList::addtoken(const std::string& str, const nonneg int lineno, const nonneg int column, const nonneg int fileno, bool split) |
| 132 | { |
| 133 | if (str.empty()) |
| 134 | return; |
| 135 | |
| 136 | // If token contains # characters, split it up |
| 137 | if (split) { |
| 138 | size_t begin = 0; |
| 139 | size_t end = 0; |
| 140 | while ((end = str.find("##", begin)) != std::string::npos) { |
| 141 | addtoken(str.substr(begin, end - begin), lineno, fileno, false); |
| 142 | addtoken("##", lineno, column, fileno, false); |
| 143 | begin = end+2; |
| 144 | } |
| 145 | if (begin != 0) { |
| 146 | addtoken(str.substr(begin), lineno, column, fileno, false); |
| 147 | return; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | if (mTokensFrontBack->back) { |
| 152 | mTokensFrontBack->back->insertToken(str); |
| 153 | } else { |
| 154 | mTokensFrontBack->front = new Token(*this, mTokensFrontBack); |
| 155 | mTokensFrontBack->back = mTokensFrontBack->front; |
| 156 | mTokensFrontBack->back->str(str); |
| 157 | } |
| 158 | |
| 159 | mTokensFrontBack->back->linenr(lineno); |
| 160 | mTokensFrontBack->back->column(column); |
| 161 | mTokensFrontBack->back->fileIndex(fileno); |
| 162 | } |
| 163 | |
| 164 | void TokenList::addtoken(const std::string& str, const Token *locationTok) |
| 165 | { |