Returns the offset of the current Token and moves cursor to next
| 157 | // Returns the offset of the current Token and moves cursor to next |
| 158 | // |
| 159 | Token IfcSpfLexer::Next() { |
| 160 | |
| 161 | if (stream->eof()) { |
| 162 | return Token{}; |
| 163 | } |
| 164 | |
| 165 | while ((skipWhitespace() != 0U) || (skipComment() != 0U)) { |
| 166 | } |
| 167 | |
| 168 | if (stream->eof()) { |
| 169 | return Token{}; |
| 170 | } |
| 171 | |
| 172 | auto& str = GetTempString(); |
| 173 | auto pos = stream->tell(); |
| 174 | char character = stream->read(); |
| 175 | |
| 176 | // If the cursor is at [()=,;$*] we know token consists of single char |
| 177 | if (character == '(' || |
| 178 | character == ')' || |
| 179 | character == '=' || |
| 180 | character == ',' || |
| 181 | character == ';' || |
| 182 | character == '$' || |
| 183 | character == '*') |
| 184 | { |
| 185 | return OperatorTokenPtr(this, pos, character); |
| 186 | } |
| 187 | |
| 188 | if (character == '\'') { |
| 189 | // If a string is encountered defer processing to the IfcCharacterDecoder |
| 190 | str = *decoder_; |
| 191 | } else { |
| 192 | str.assign(&character, 1); |
| 193 | |
| 194 | while (!stream->eof()) { |
| 195 | // Read character and increment pointer if not starting a new token |
| 196 | character = stream->peek(); |
| 197 | if (character == '(' || |
| 198 | character == ')' || |
| 199 | character == '=' || |
| 200 | character == ',' || |
| 201 | character == ';' || |
| 202 | character == '/') { |
| 203 | break; |
| 204 | } |
| 205 | if (!(character == ' ' || character == '\r' || character == '\n' || character == '\t')) { |
| 206 | str.push_back(character); |
| 207 | } |
| 208 | stream->increment(); |
| 209 | } |
| 210 | } |
| 211 | return GeneralTokenPtr(this, pos, str); |
| 212 | } |
| 213 | |
| 214 | // |
| 215 | // Reads a std::string from the file at specified offset |
no test coverage detected