MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / _read_string

Method _read_string

src/Chain/libraries/glua/glua_tokenparser.cpp:351–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349 }
350
351 void GluaTokenParser::_read_string(std::string &code, int delimiter)
352 {
353 std::stringstream literal_str;
354 literal_str << (char)_current_char(code);
355 _save_to_buff_and_next(_current_char(code));
356 while (_current_char(code) != delimiter) {
357 if (_current_char(code) != '\\' || _next_token_char(code) != 'z')
358 literal_str << (char)_current_char(code);
359 switch (_current_char(code)) {
360 case EOF_TOKEN_CHAR:
361 THROW_PERROR("unfinished string");
362 return;
363 case '\n':
364 case '\r':
365 THROW_PERROR("unfinished string");
366 return;
367 case '\\': { /* escape sequences */
368 int c; /* final character to be saved */
369 _save_to_buff_and_next(_current_char(code)); /* keep '\\' for error messages */
370 switch (_current_char(code)) {
371 case 'a': c = '\a'; goto read_save;
372 case 'b': c = '\b'; goto read_save;
373 case 'f': c = '\f'; goto read_save;
374 case 'n': c = '\n'; goto read_save;
375 case 'r': c = '\r'; goto read_save;
376 case 't': c = '\t'; goto read_save;
377 case 'v': c = '\v'; goto read_save;
378 case 'x': literal_str << 'x'; ++_parsing_pos; _loadhexaesc(code, &literal_str); goto no_save;
379 case 'u': literal_str << "u{"; ++_parsing_pos; _loadutf8esc(code, &literal_str); literal_str << "}"; goto no_save;
380 case '\n': case '\r':
381 {
382 _inc_line(code); c = '\n'; goto only_save;
383 }
384 case '\\': case '\"': case '\'':
385 c = _current_char(code); goto read_save;
386 case EOZ: goto no_save; // will raise an error next loop
387 case 'z': { // zap following span of spaces
388 --_parsing_buff_len; // remove '\\'
389 ++_parsing_pos;
390 while (is_space(_current_char(code))) {
391 if (is_new_line_start(_current_char(code)))
392 _inc_line(code);
393 else
394 ++_parsing_pos;
395 }
396 goto no_save;
397 }
398
399 default: {
400 if (!is_digit(_current_char(code)))
401 {
402 THROW_PERROR("invalid escape sequence");
403 ++_parsing_pos;
404 return;
405 }
406 _loaddecesc(code, &literal_str); // digital escape '\ddd'
407 goto no_save;
408 }

Callers

nothing calls this directly

Calls 8

is_new_line_startFunction · 0.85
is_spaceFunction · 0.70
is_digitFunction · 0.70
substrMethod · 0.45
lengthMethod · 0.45
strMethod · 0.45
pop_backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected