------------------------------------------------------------------------------------------------
| 132 | |
| 133 | // ------------------------------------------------------------------------------------------------ |
| 134 | void Tokenize(TokenList &output_tokens, const char *input, StackAllocator &token_allocator) { |
| 135 | ai_assert(input); |
| 136 | ASSIMP_LOG_DEBUG("Tokenizing ASCII FBX file"); |
| 137 | |
| 138 | // line and column numbers numbers are one-based |
| 139 | unsigned int line = 1; |
| 140 | unsigned int column = 1; |
| 141 | |
| 142 | bool comment = false; |
| 143 | bool in_double_quotes = false; |
| 144 | bool pending_data_token = false; |
| 145 | |
| 146 | const char *token_begin = nullptr, *token_end = nullptr; |
| 147 | for (const char* cur = input;*cur;column += (*cur == '\t' ? ASSIMP_FBX_TAB_WIDTH : 1), ++cur) { |
| 148 | const char c = *cur; |
| 149 | |
| 150 | if (IsLineEnd(c)) { |
| 151 | comment = false; |
| 152 | |
| 153 | column = 0; |
| 154 | ++line; |
| 155 | } |
| 156 | |
| 157 | if(comment) { |
| 158 | continue; |
| 159 | } |
| 160 | |
| 161 | if(in_double_quotes) { |
| 162 | if (c == '\"') { |
| 163 | in_double_quotes = false; |
| 164 | token_end = cur; |
| 165 | |
| 166 | ProcessDataToken(output_tokens, token_allocator, token_begin, token_end, line, column); |
| 167 | pending_data_token = false; |
| 168 | } |
| 169 | continue; |
| 170 | } |
| 171 | |
| 172 | switch(c) |
| 173 | { |
| 174 | case '\"': |
| 175 | if (token_begin) { |
| 176 | TokenizeError("unexpected double-quote", line, column); |
| 177 | } |
| 178 | token_begin = cur; |
| 179 | in_double_quotes = true; |
| 180 | continue; |
| 181 | |
| 182 | case ';': |
| 183 | ProcessDataToken(output_tokens, token_allocator, token_begin, token_end, line, column); |
| 184 | comment = true; |
| 185 | continue; |
| 186 | |
| 187 | case '{': |
| 188 | ProcessDataToken(output_tokens, token_allocator, token_begin, token_end, line, column); |
| 189 | output_tokens.push_back(new_Token(cur,cur+1,TokenType_OPEN_BRACKET,line,column)); |
| 190 | continue; |
| 191 |
no test coverage detected