| 162 | } |
| 163 | |
| 164 | void GluaTokenParser::_push_new_token(int type, size_t line) |
| 165 | { |
| 166 | _parsing_buff[_parsing_buff_len] = '\0'; |
| 167 | char buff[LUA_TOKEN_MAX_LENGTH]; |
| 168 | for (size_t i = 0; i < _parsing_buff_len; ++i) |
| 169 | { |
| 170 | buff[i] = (char)_parsing_buff[i]; |
| 171 | } |
| 172 | buff[_parsing_buff_len] = '\0'; |
| 173 | std::string token_str(buff); |
| 174 | GluaParserToken token; |
| 175 | token.token = token_str; |
| 176 | auto enum_type = static_cast<enum TOKEN_RESERVED>(type); |
| 177 | if (enum_type == LTK_NAME) |
| 178 | enum_type = get_token_type_by_symbol_name(token_str); |
| 179 | token.type = enum_type; |
| 180 | token.linenumber = line > 0 ? line : _parsing_linenumber; |
| 181 | token.position = _parsing_pos - token_str.length(); |
| 182 | token.end_linenumber = token.linenumber + glua::util::string_lines_count(token_str) - 1; |
| 183 | _tokens.push_back(token); |
| 184 | _reset_parse_buff(); |
| 185 | } |
| 186 | |
| 187 | GluaParserToken GluaTokenParser::_last_token() const |
| 188 | { |
nothing calls this directly
no test coverage detected