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

Method _read_long_string

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

Source from the content-addressed store, hash-verified

439 }
440
441 void GluaTokenParser::_read_long_string(std::string &code, bool is_string, int sep)
442 {
443 ++_cycle_count;
444 if (end_cycle(_cycle_count))
445 return;
446 auto line = _parsing_linenumber; // initial linenumber, the string may over-lines
447 auto what = is_string ? "string" : "comment";
448 _save_to_buff_and_next(_current_char(code));
449 if (_parsing_pos < code.length() && is_new_line_start(_current_char(code)))
450 {
451 _inc_line(code);
452 }
453 while (_parsing_pos < code.length())
454 {
455 if (_parsing_buff_len >= LUA_TOKEN_MAX_LENGTH - 1)
456 {
457 if(!is_string)
458 {
459 // is too long comment
460 _parsing_buff_len = 0;
461 }
462 else
463 {
464 global_glua_chain_api->throw_exception(_L, THINKYOUNG_API_COMPILE_ERROR, std::string("too long token").c_str());
465 return;
466 }
467 }
468 switch (_current_char(code))
469 {
470 case EOF_TOKEN_CHAR:
471 global_glua_chain_api->throw_exception(_L, THINKYOUNG_API_COMPILE_ERROR, "undefined long %s (starting at line %d)", what, line);
472 return;
473 case ']':
474 {
475 if (!is_string && code.length() > _parsing_pos + 1 && code[_parsing_pos + 1] == ']'
476 )
477 {
478 _save_to_buff_and_next(_current_char(code));
479 _save_to_buff_and_next(_current_char(code));
480 goto endloop;
481 }
482 if (_skip_sep(code) == sep)
483 {
484 _save_to_buff_and_next(_current_char(code));
485 goto endloop;
486 }
487 else if (!is_string)
488 {
489 ++_parsing_pos; // ignore any thing in comment
490 }
491 else
492 {
493 _save_to_buff_and_next(_current_char(code)); // ?
494 }
495 break;
496 }
497 case '\n': case '\r':
498 _save_to_buff(_current_char(code));

Callers

nothing calls this directly

Calls 6

end_cycleFunction · 0.85
is_new_line_startFunction · 0.85
stringClass · 0.50
lengthMethod · 0.45
throw_exceptionMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected